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

Side by Side 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, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/DEPS » ('j') | extensions/renderer/module_system.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "chrome/test/base/module_system_test.h" 6 #include "chrome/test/base/module_system_test.h"
7 #include "extensions/renderer/module_system.h" 7 #include "extensions/renderer/module_system.h"
8 8
9 // TODO(cduvall/kalman): Put this file in extensions namespace. 9 // TODO(cduvall/kalman): Put this file in extensions namespace.
10 using extensions::ModuleSystem; 10 using extensions::ModuleSystem;
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 266
267 TEST_F(ModuleSystemTest, TestOverrideNonExistentNativeHandler) { 267 TEST_F(ModuleSystemTest, TestOverrideNonExistentNativeHandler) {
268 ModuleSystem::NativesEnabledScope natives_enabled_scope( 268 ModuleSystem::NativesEnabledScope natives_enabled_scope(
269 context_->module_system()); 269 context_->module_system());
270 OverrideNativeHandler("thing", "exports.x = 5;"); 270 OverrideNativeHandler("thing", "exports.x = 5;");
271 RegisterModule("test", 271 RegisterModule("test",
272 "var assert = requireNative('assert');" 272 "var assert = requireNative('assert');"
273 "assert.AssertTrue(requireNative('thing').x == 5);"); 273 "assert.AssertTrue(requireNative('thing').x == 5);");
274 context_->module_system()->Require("test"); 274 context_->module_system()->Require("test");
275 } 275 }
276
277 TEST_F(ModuleSystemTest, TestRequireAsync) {
278 ModuleSystem::NativesEnabledScope natives_enabled_scope(
279 context_->module_system());
280 RegisterModule("add",
281 "define('add', [], function() {"
282 " return { Add: function(x, y) { return x + y; } };"
283 "});");
284 RegisterModule("math",
285 "define('math', ['add'], function(add) {"
286 " return { Add: add.Add };"
287 "});");
288 RegisterModule("test",
289 "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.
290 " requireNative('assert').AssertTrue(math.Add(3, 5) == 8);"
291 "});");
292 context_->module_system()->Require("test");
293
294 // The requireAsync promise is resolved asynchronously so we need to let it
295 // run.
296 isolate_holder_.isolate()->RunMicrotasks();
297 }
OLDNEW
« 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