test for lazy getters scope,
bug 508850, r=sdwilsh
--- 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()