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

Unified Diff: chrome/renderer/module_system_unittest.cc

Issue 9812025: Implement lazy JS module initialisation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
« chrome/renderer/module_system.cc ('K') | « chrome/renderer/module_system.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/module_system_unittest.cc
diff --git a/chrome/renderer/module_system_unittest.cc b/chrome/renderer/module_system_unittest.cc
index ff520ac26927976bea4c791fc1666bd0e074e982..4aa74ee9f617e37c99aef6490fb4c2ad50fd2b34 100644
--- a/chrome/renderer/module_system_unittest.cc
+++ b/chrome/renderer/module_system_unittest.cc
@@ -166,33 +166,17 @@ TEST_F(ModuleSystemTest, TestDisableNativesPreventsNativeModulesBeingLoaded) {
module_system_->Require("test");
}
-TEST_F(ModuleSystemTest, TestLazyObject) {
- v8::Handle<v8::String> source = v8::String::New("({x: 5})");
- v8::Handle<v8::Object> lazy_object =
- ModuleSystem::CreateLazyObject("lazy.js", source);
- v8::Context::GetCurrent()->Global()->Set(v8::String::New("lazy"),
- lazy_object);
- RegisterModule("test",
- "var assert = requireNative('assert');"
- "assert.AssertTrue(lazy.x == 5);"
- "assert.AssertTrue(lazy.x == 5);");
- module_system_->Require("test");
-}
+TEST_F(ModuleSystemTest, TestLazyField) {
+ RegisterModule("lazy",
+ "exports.x = 5;");
+
+ v8::Handle<v8::Object> object = v8::Object::New();
+ v8::Context::GetCurrent()->Global()->Set(v8::String::New("object"), object);
+
+ module_system_->SetLazyField(object, "blah", "lazy", "x");
not at google - send to devlin 2012/03/22 00:35:53 can you do the same sort of thing you did below, t
koz (OOO until 15th September) 2012/03/22 01:13:01 That's a good idea for a test. I've added it as a
-TEST_F(ModuleSystemTest, TestLazyInstanceOnlyGetsEvaledOnce) {
- v8::Context::GetCurrent()->Global()->Set(v8::String::New("evalCount"),
- v8::Integer::New(0));
- v8::Handle<v8::String> source = v8::String::New("evalCount++; ({x: 5})");
- v8::Handle<v8::Object> lazy_object =
- ModuleSystem::CreateLazyObject("lazy.js", source);
- v8::Context::GetCurrent()->Global()->Set(v8::String::New("lazy"),
- lazy_object);
RegisterModule("test",
"var assert = requireNative('assert');"
- "assert.AssertTrue(evalCount == 0);"
- "lazy.x;"
- "assert.AssertTrue(evalCount == 1);"
- "lazy.x;"
- "assert.AssertTrue(evalCount == 1);");
+ "assert.AssertTrue(object.blah == 5);");
module_system_->Require("test");
}
« chrome/renderer/module_system.cc ('K') | « chrome/renderer/module_system.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698