#include "extensions/renderer/bindings/api_binding.h"
#include <string_view>
#include <tuple>
#include "base/auto_reset.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.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.h"
#include "extensions/renderer/bindings/api_binding_test_util.h"
#include "extensions/renderer/bindings/api_binding_types.h"
#include "extensions/renderer/bindings/api_binding_util.h"
#include "extensions/renderer/bindings/api_event_handler.h"
#include "extensions/renderer/bindings/api_invocation_errors.h"
#include "extensions/renderer/bindings/api_request_handler.h"
#include "extensions/renderer/bindings/api_signature.h"
#include "extensions/renderer/bindings/api_type_reference_map.h"
#include "extensions/renderer/bindings/binding_access_checker.h"
#include "extensions/renderer/bindings/exception_handler.h"
#include "extensions/renderer/bindings/test_interaction_provider.h"
#include "extensions/renderer/bindings/test_js_runner.h"
#include "gin/arguments.h"
#include "gin/converter.h"
#include "gin/public/context_holder.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "v8/include/v8.h"
namespace extensions {
namespace {
const char kBindingName[] = …;
const char kFunctions[] = …;
constexpr char kFunctionsWithCallbackSignatures[] = …;
constexpr char kFunctionsWithPromiseSignatures[] = …;
bool AllowAllFeatures(v8::Local<v8::Context> context, const std::string& name) { … }
bool DisallowPromises(v8::Local<v8::Context> context) { … }
void OnEventListenersChanged(const std::string& event_name,
binding::EventListenersChanged change,
const base::Value::Dict* filter,
bool was_manual,
v8::Local<v8::Context> context) { … }
}
class APIBindingUnittest : public APIBindingTest { … };
APIBindingDeathTest;
v8::Local<v8::Value> APIBindingUnittest::RunTest(
v8::Local<v8::Context> context,
v8::Local<v8::Object> object,
const std::string& script_source,
bool should_pass,
const std::string& expected_json_arguments,
bool expect_async_handler,
const std::string& expected_error) { … }
TEST_F(APIBindingUnittest, TestEmptyAPI) { … }
TEST_F(APIBindingUnittest, TestBasicAPICalls) { … }
TEST_F(APIBindingUnittest, EnumValues) { … }
TEST_F(APIBindingUnittest, EnumWithEmptyEntry) { … }
TEST_F(APIBindingUnittest, TypeRefsTest) { … }
TEST_F(APIBindingUnittest, RestrictedAPIs) { … }
TEST_F(APIBindingUnittest, TestEventCreation) { … }
TEST_F(APIBindingUnittest, TestProperties) { … }
TEST_F(APIBindingUnittest, TestRefProperties) { … }
TEST_F(APIBindingUnittest, TestDisposedContext) { … }
TEST_F(APIBindingUnittest, TestInvalidatedContext) { … }
TEST_F(APIBindingUnittest, MultipleContexts) { … }
TEST_F(APIBindingUnittest, TestCustomHooks) { … }
TEST_F(APIBindingUnittest, TestJSCustomHook) { … }
TEST_F(APIBindingUnittest, TestUpdateArgumentsPreValidate) { … }
TEST_F(APIBindingUnittest, TestThrowInUpdateArgumentsPreValidate) { … }
TEST_F(APIBindingUnittest, TestReturningResultFromCustomJSHook) { … }
TEST_F(APIBindingUnittest, TestReturningPromiseFromHandleRequestHook) { … }
TEST_F(APIBindingUnittest, TestThrowingFromCustomJSHook) { … }
TEST_F(APIBindingUnittest, TestHandleRequestFailureCallback) { … }
TEST_F(APIBindingUnittest, TestHandleRequestHookCalledTwiceGracefulRegression) { … }
TEST_F(APIBindingUnittest, TestInvalidatingInCustomHook) { … }
TEST_F(APIBindingUnittest,
TestReturningResultAndThrowingExceptionFromCustomNativeHook) { … }
TEST_F(APIBindingUnittest, TestUpdateArgumentsPostValidate) { … }
TEST_F(APIBindingUnittest, TestUpdateArgumentsPostValidateViolatingSchema) { … }
TEST_F(APIBindingUnittest, TestUserGestures) { … }
TEST_F(APIBindingUnittest, FilteredEvents) { … }
TEST_F(APIBindingUnittest, HooksTemplateInitializer) { … }
TEST_F(APIBindingUnittest, HooksInstanceInitializer) { … }
TEST_F(APIBindingUnittest, TestSendingRequestsAndSilentRequestsWithHooks) { … }
TEST_F(APIBindingUnittest, TestHooksWithCustomCallback) { … }
TEST_F(APIBindingUnittest, TestHooksWithResultModifier) { … }
TEST_F(APIBindingUnittest, TestHooksWithResultModifierAndJSHook) { … }
TEST_F(APIBindingUnittest, AccessAPIMethodsAndEventsAfterInvalidation) { … }
TEST_F(APIBindingUnittest, CallbackSignaturesAreAdded) { … }
TEST_F(APIBindingUnittest,
CallbackSignaturesAreNotAddedWhenValidationDisabled) { … }
TEST_F(APIBindingUnittest, PromiseBasedAPIs) { … }
TEST_F(APIBindingUnittest, TestPromisesWithJSCustomCallback) { … }
TEST_F(APIBindingUnittest, TestPromiseWithJSUpdateArgumentsPreValidate) { … }
TEST_F(APIBindingUnittest, TestPromiseWithJSUpdateArgumentsPostValidate) { … }
}