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

Unified Diff: gin/modules/module_registry_unittest.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « gin/isolate_holder.cc ('k') | gin/shell/gin_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/modules/module_registry_unittest.cc
diff --git a/gin/modules/module_registry_unittest.cc b/gin/modules/module_registry_unittest.cc
index 3d784dc7f9f8db20b83c4a3ed8b43689f948c4e3..ed725fc8cb8d09addff1024c428363e0b67eac43 100644
--- a/gin/modules/module_registry_unittest.cc
+++ b/gin/modules/module_registry_unittest.cc
@@ -70,6 +70,10 @@ void OnModuleLoaded(TestHelper* helper,
->LoadModule(isolate, "two", base::Bind(NestedCallback));
}
+void OnModuleLoadedNoOp(v8::Handle<v8::Value> value) {
+ ASSERT_TRUE(value->IsNumber());
+}
+
} // namespace
typedef V8Test ModuleRegistryTest;
@@ -133,4 +137,28 @@ TEST_F(ModuleRegistryTest, LoadModuleTest) {
EXPECT_EQ(3, counter);
}
+// Verifies that explicitly loading a module that's already pending does
+// not cause the ModuleRegistry's unsatisfied_dependency set to grow.
+TEST_F(ModuleRegistryTest, UnsatisfiedDependenciesTest) {
+ TestHelper helper(instance_->isolate());
+ std::string source =
+ "define('one', ['no_such_module'], function(nsm) {"
+ " return 1;"
+ "});";
+ ModuleRegistry* registry =
+ ModuleRegistry::From(helper.runner->GetContextHolder()->context());
+
+ std::set<std::string> no_such_module_set;
+ no_such_module_set.insert("no_such_module");
+
+ // Adds one unsatisfied dependency on "no-such-module".
+ helper.runner->Run(source, "script");
+ EXPECT_EQ(no_such_module_set, registry->unsatisfied_dependencies());
+
+ // Should have no effect on the unsatisfied_dependencies set.
+ ModuleRegistry::LoadModuleCallback callback = base::Bind(OnModuleLoadedNoOp);
+ registry->LoadModule(instance_->isolate(), "one", callback);
+ EXPECT_EQ(no_such_module_set, registry->unsatisfied_dependencies());
+}
+
} // namespace gin
« no previous file with comments | « gin/isolate_holder.cc ('k') | gin/shell/gin_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698