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

Unified Diff: chrome/renderer/extensions/module_system_unittest.cc

Issue 359413004: Add support for using AMD modules from extensions modules. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 6 years, 6 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 | « no previous file | chrome/test/DEPS » ('j') | extensions/renderer/module_system.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/module_system_unittest.cc
diff --git a/chrome/renderer/extensions/module_system_unittest.cc b/chrome/renderer/extensions/module_system_unittest.cc
index 84ccd7fc1dd0da957e85d4a3c23b710fef643885..ac24fde906a881dc9cd30ed631edcbc7d457f7ed 100644
--- a/chrome/renderer/extensions/module_system_unittest.cc
+++ b/chrome/renderer/extensions/module_system_unittest.cc
@@ -273,3 +273,25 @@ TEST_F(ModuleSystemTest, TestOverrideNonExistentNativeHandler) {
"assert.AssertTrue(requireNative('thing').x == 5);");
context_->module_system()->Require("test");
}
+
+TEST_F(ModuleSystemTest, TestRequireAsync) {
+ ModuleSystem::NativesEnabledScope natives_enabled_scope(
+ context_->module_system());
+ RegisterModule("add",
+ "define('add', [], function() {"
+ " return { Add: function(x, y) { return x + y; } };"
+ "});");
+ RegisterModule("math",
+ "define('math', ['add'], function(add) {"
+ " return { Add: add.Add };"
+ "});");
+ RegisterModule("test",
+ "requireAsync('math').then(function(math) {"
not at google - send to devlin 2014/07/02 22:07:45 could you also test - a chain of requireAsync call
Sam McNally 2014/07/03 10:56:53 Done.
Sam McNally 2014/07/07 05:58:37 Added some cross-context tests too.
+ " requireNative('assert').AssertTrue(math.Add(3, 5) == 8);"
+ "});");
+ context_->module_system()->Require("test");
+
+ // The requireAsync promise is resolved asynchronously so we need to let it
+ // run.
+ isolate_holder_.isolate()->RunMicrotasks();
+}
« no previous file with comments | « no previous file | chrome/test/DEPS » ('j') | extensions/renderer/module_system.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698