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

Unified Diff: extensions/renderer/native_extension_bindings_system_unittest.cc

Issue 2722463006: [Extensions Bindings] Notify of event unregistration on invalidation (Closed)
Patch Set: nits Created 3 years, 10 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
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 74c42f6219a64fb4a71b0286c58b7464b0414b05..7c62c70512e08bfef67b74f776e8d54f1541a26b 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();
@@ -140,6 +144,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() {
@@ -360,7 +378,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 =

Powered by Google App Engine
This is Rietveld 408576698