test for lazy getters scope, bug 508850, r=sdwilsh
authorMarco Bonardo <mbonardo@mozilla.com>
Mon, 05 Oct 2009 12:12:28 +0200
changeset 33457 1cd24ecc343d45cbe3d62d450f12f30f66ef1edb
parent 33456 1470fa9c9f0189295cba7d108ba46f9c4e36e3b1
child 33458 98a42087c07b45665e946623db59a0cd1ee493cb
push idunknown
push userunknown
push dateunknown
reviewerssdwilsh
bugs508850
milestone1.9.3a1pre
test for lazy getters scope, bug 508850, r=sdwilsh
js/src/xpconnect/tests/unit/test_xpcomutils.js
--- a/js/src/xpconnect/tests/unit/test_xpcomutils.js
+++ b/js/src/xpconnect/tests/unit/test_xpcomutils.js
@@ -73,27 +73,31 @@ function test_generateQI_string_names()
         x.QueryInterface(Components.interfaces.nsIDOMDocument);
         do_throw("QI should not have succeeded!");
     } catch(e) {}
 }
 
 function test_defineLazyGetter()
 {
     let accessCount = 0;
-    let obj = { };
+    let obj = {
+      inScope: false
+    };
     const TEST_VALUE = "test value";
     XPCOMUtils.defineLazyGetter(obj, "foo", function() {
         accessCount++;
+        this.inScope = true;
         return TEST_VALUE;
     });
     do_check_eq(accessCount, 0);
 
     // Get the property, making sure the access count has increased.
     do_check_eq(obj.foo, TEST_VALUE);
     do_check_eq(accessCount, 1);
+    do_check_true(obj.inScope);
 
     // Get the property once more, making sure the access count has not
     // increased.
     do_check_eq(obj.foo, TEST_VALUE);
     do_check_eq(accessCount, 1);
 }
 
 function test_defineLazyServiceGetter()