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

Unified Diff: chrome/renderer/module_system_unittest.cc

Issue 9835039: Make app_custom_bindings.js lazily evaluated so it doesn't execute on every page load. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lazy load webstore bindings as well 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
Index: chrome/renderer/module_system_unittest.cc
diff --git a/chrome/renderer/module_system_unittest.cc b/chrome/renderer/module_system_unittest.cc
index 6b9b0206e4750e432ed405ae4c8c602bc18a3c03..8c888f62b4693137b695d26d1dda20e3470343de 100644
--- a/chrome/renderer/module_system_unittest.cc
+++ b/chrome/renderer/module_system_unittest.cc
@@ -181,3 +181,42 @@ TEST_F(ModuleSystemTest, TestLazyField) {
"assert.AssertTrue(object.blah == 5);");
module_system_->Require("test");
}
+
+TEST_F(ModuleSystemTest, TestLazyFieldYieldingObject) {
+ RegisterModule("lazy",
+ "var object = {};"
+ "object.__defineGetter__('z', function() { return 1; });"
+ "object.x = 5;"
+ "object.y = 10;"
+ "exports.object = object;");
+
+ v8::Handle<v8::Object> object = v8::Object::New();
+ v8::Context::GetCurrent()->Global()->Set(v8::String::New("object"), object);
+
+ module_system_->SetLazyField(object, "thing", "lazy", "object");
+
+ RegisterModule("test",
+ "var assert = requireNative('assert');"
+ "assert.AssertTrue(object.thing.x == 5);"
not at google - send to devlin 2012/03/25 22:42:58 Once again, could you have a global "count" and ch
koz (OOO until 15th September) 2012/03/26 01:36:09 Done in a separate test.
+ "assert.AssertTrue(object.thing.y == 10);"
not at google - send to devlin 2012/03/25 22:42:58 I don't see the advantage in having x and y be bot
koz (OOO until 15th September) 2012/03/26 01:36:09 Done.
+ "assert.AssertTrue(object.thing.z == 1);"
+ );
+ module_system_->Require("test");
+}
+
+TEST_F(ModuleSystemTest, TestTransitiveRequire) {
+ RegisterModule("dependency",
+ "exports.x = 5;");
+ RegisterModule("lazy",
+ "exports.output = require('dependency');");
+
+ v8::Handle<v8::Object> object = v8::Object::New();
+ v8::Context::GetCurrent()->Global()->Set(v8::String::New("object"), object);
+
+ module_system_->SetLazyField(object, "thing", "lazy", "output");
+
+ RegisterModule("test",
+ "var assert = requireNative('assert');"
+ "assert.AssertTrue(object.thing.x == 5);");
not at google - send to devlin 2012/03/25 22:42:58 If this was instead var x = object.thing.x; var a
koz (OOO until 15th September) 2012/03/26 01:36:09 Yeah, it would if you wrap it in a NativesEnabledS
+ module_system_->Require("test");
+}

Powered by Google App Engine
This is Rietveld 408576698