Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: extensions/renderer/native_extension_bindings_system_unittest.cc

Issue 2722463006: [Extensions Bindings] Notify of event unregistration on invalidation (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/renderer/native_extension_bindings_system.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/native_extension_bindings_system_unittest.cc
diff --git a/extensions/renderer/native_extension_bindings_system_unittest.cc b/extensions/renderer/native_extension_bindings_system_unittest.cc
index 404c24996658b5900659db2e4db3c88e9d928f6c..a009e2db3fcce5d7c51e9f09aa4b0c248b7f24f2 100644
--- a/extensions/renderer/native_extension_bindings_system_unittest.cc
+++ b/extensions/renderer/native_extension_bindings_system_unittest.cc
@@ -99,8 +99,12 @@ class NativeExtensionBindingsSystemUnittest : public APIBindingTest {
}
void TearDown() override {
- for (auto* context : raw_script_contexts_)
+ event_change_handler_.reset();
+
+ for (auto* context : raw_script_contexts_) {
+ bindings_system_->WillReleaseScriptContext(context);
script_context_set_->Remove(context);
+ }
base::RunLoop().RunUntilIdle();
script_context_set_.reset();
bindings_system_.reset();
@@ -141,6 +145,20 @@ class NativeExtensionBindingsSystemUnittest : public APIBindingTest {
return raw_script_context;
}
+ void DisposeMainScriptContext() {
+ v8::Local<v8::Context> context = ContextLocal();
+ auto iter =
+ std::find_if(raw_script_contexts_.begin(), raw_script_contexts_.end(),
+ [context](ScriptContext* script_context) {
+ return script_context->v8_context() == context;
+ });
+ ASSERT_TRUE(iter != raw_script_contexts_.end());
+ bindings_system_->WillReleaseScriptContext(*iter);
+ DisposeContext();
+ script_context_set_->Remove(*iter);
+ raw_script_contexts_.erase(iter);
+ }
+
void RegisterExtension(const ExtensionId& id) { extension_ids_.insert(id); }
void InitEventChangeHandler() {
@@ -361,7 +379,7 @@ TEST_F(NativeExtensionBindingsSystemUnittest,
ASSERT_FALSE(first_idle_object.IsEmpty());
EXPECT_TRUE(first_idle_object->IsObject());
- DisposeContext();
+ DisposeMainScriptContext();
// Check an API that was instantiated....
v8::Local<v8::Value> second_idle_object =
« no previous file with comments | « extensions/renderer/native_extension_bindings_system.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698