#include "extensions/renderer/bindings/api_bindings_system_unittest.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/stringprintf.h"
#include "extensions/common/mojom/event_dispatcher.mojom.h"
#include "extensions/renderer/bindings/api_binding.h"
#include "extensions/renderer/bindings/api_binding_hooks.h"
#include "extensions/renderer/bindings/api_binding_hooks_test_delegate.h"
#include "extensions/renderer/bindings/api_binding_test_util.h"
#include "extensions/renderer/bindings/api_binding_types.h"
#include "extensions/renderer/bindings/api_bindings_system.h"
#include "extensions/renderer/bindings/api_invocation_errors.h"
#include "extensions/renderer/bindings/test_interaction_provider.h"
#include "gin/arguments.h"
#include "gin/converter.h"
#include "gin/try_catch.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace extensions {
namespace {
const char kAlphaAPIName[] = …;
const char kAlphaAPISpec[] = …;
const char kBetaAPIName[] = …;
const char kBetaAPISpec[] = …;
const char kGammaAPIName[] = …;
const char kGammaAPISpec[] = …;
const char kCustomCallbackHook[] = …;
const char kCustomCallbackThrowHook[] = …;
bool AllowAllAPIs(v8::Local<v8::Context> context, const std::string& name) { … }
bool AllowPromises(v8::Local<v8::Context> context) { … }
}
APIBindingsSystemTest::APIBindingsSystemTest() = default;
APIBindingsSystemTest::~APIBindingsSystemTest() = default;
void APIBindingsSystemTest::SetUp() { … }
void APIBindingsSystemTest::TearDown() { … }
void APIBindingsSystemTest::OnWillDisposeContext(
v8::Local<v8::Context> context) { … }
std::vector<APIBindingsSystemTest::FakeSpec> APIBindingsSystemTest::GetAPIs() { … }
v8::Local<v8::Object> APIBindingsSystemTest::GetLastErrorParent(
v8::Local<v8::Context> context,
v8::Local<v8::Object>* secondary_parent) { … }
void APIBindingsSystemTest::AddConsoleError(v8::Local<v8::Context> context,
const std::string& error) { … }
const base::Value::Dict& APIBindingsSystemTest::GetAPISchema(
const std::string& api_name) { … }
void APIBindingsSystemTest::OnAPIRequest(
std::unique_ptr<APIRequestHandler::Request> request,
v8::Local<v8::Context> context) { … }
void APIBindingsSystemTest::OnEventListenersChanged(
const std::string& event_name,
binding::EventListenersChanged changed,
const base::Value::Dict* filter,
bool was_manual,
v8::Local<v8::Context> context) { … }
void APIBindingsSystemTest::ValidateLastRequest(
const std::string& expected_name,
const std::string& expected_arguments) { … }
v8::Local<v8::Value> APIBindingsSystemTest::CallFunctionOnObject(
v8::Local<v8::Context> context,
v8::Local<v8::Object> object,
const std::string& script_source) { … }
TEST_F(APIBindingsSystemTest, TestInitializationAndCallbacks) { … }
TEST_F(APIBindingsSystemTest, TestCustomHooks) { … }
TEST_F(APIBindingsSystemTest, TestSetCustomCallback_SuccessWithCallback) { … }
TEST_F(APIBindingsSystemTest, TestSetCustomCallback_SuccessWithPromise) { … }
TEST_F(APIBindingsSystemTest, TestSetCustomCallback_ErrorWithCallback) { … }
TEST_F(APIBindingsSystemTest, TestSetCustomCallback_ErrorWithPromise) { … }
TEST_F(APIBindingsSystemTest, CrossAPIReferences) { … }
TEST_F(APIBindingsSystemTest, TestCustomEvent) { … }
}