| Index: extensions/renderer/api_binding_unittest.cc
|
| diff --git a/extensions/renderer/api_binding_unittest.cc b/extensions/renderer/api_binding_unittest.cc
|
| index c8d7d22515d9f401d00cf81d8e7150571ab86708..70333ce5603babc8ca0bce393ad0980f6b7c5e73 100644
|
| --- a/extensions/renderer/api_binding_unittest.cc
|
| +++ b/extensions/renderer/api_binding_unittest.cc
|
| @@ -147,12 +147,18 @@ class APIBindingUnittest : public APIBindingTest {
|
| }
|
|
|
| void TearDown() override {
|
| + DisposeAllContexts();
|
| request_handler_.reset();
|
| event_handler_.reset();
|
| binding_.reset();
|
| APIBindingTest::TearDown();
|
| }
|
|
|
| + void OnWillDisposeContext(v8::Local<v8::Context> context) override {
|
| + event_handler_->InvalidateContext(context);
|
| + request_handler_->InvalidateContext(context);
|
| + }
|
| +
|
| void SetFunctions(const char* functions) {
|
| binding_functions_ = ListValueFromString(functions);
|
| ASSERT_TRUE(binding_functions_);
|
| @@ -496,7 +502,7 @@ TEST_F(APIBindingUnittest, TypeRefsTest) {
|
| }
|
|
|
| TEST_F(APIBindingUnittest, RestrictedAPIs) {
|
| - const char kRestrictedFunctions[] =
|
| + const char kFunctions[] =
|
| "[{"
|
| " 'name': 'allowedOne',"
|
| " 'parameters': []"
|
| @@ -510,18 +516,22 @@ TEST_F(APIBindingUnittest, RestrictedAPIs) {
|
| " 'name': 'restrictedTwo',"
|
| " 'parameters': []"
|
| "}]";
|
| - SetFunctions(kRestrictedFunctions);
|
| + SetFunctions(kFunctions);
|
| + const char kEvents[] =
|
| + "[{'name': 'allowedEvent'}, {'name': 'restrictedEvent'}]";
|
| + SetEvents(kEvents);
|
| InitializeBinding();
|
|
|
| v8::HandleScope handle_scope(isolate());
|
| v8::Local<v8::Context> context = MainContext();
|
|
|
| auto is_available = [](const std::string& name) {
|
| - std::set<std::string> functions = {"test.allowedOne", "test.allowedTwo",
|
| - "test.restrictedOne",
|
| - "test.restrictedTwo"};
|
| - EXPECT_TRUE(functions.count(name));
|
| - return name == "test.allowedOne" || name == "test.allowedTwo";
|
| + std::set<std::string> allowed = {"test.allowedOne", "test.allowedTwo",
|
| + "test.allowedEvent"};
|
| + std::set<std::string> restricted = {
|
| + "test.restrictedOne", "test.restrictedTwo", "test.restrictedEvent"};
|
| + EXPECT_TRUE(allowed.count(name) || restricted.count(name)) << name;
|
| + return allowed.count(name) != 0;
|
| };
|
|
|
| v8::Local<v8::Object> binding_object =
|
| @@ -536,8 +546,10 @@ TEST_F(APIBindingUnittest, RestrictedAPIs) {
|
|
|
| EXPECT_TRUE(is_defined("allowedOne"));
|
| EXPECT_TRUE(is_defined("allowedTwo"));
|
| + EXPECT_TRUE(is_defined("allowedEvent"));
|
| EXPECT_FALSE(is_defined("restrictedOne"));
|
| EXPECT_FALSE(is_defined("restrictedTwo"));
|
| + EXPECT_FALSE(is_defined("restrictedEvent"));
|
| }
|
|
|
| // Tests that events specified in the API are created as properties of the API
|
|
|