2019-01-17 21:18:31 +03:00
|
|
|
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
2018-11-05 17:41:45 +03:00
|
|
|
|
2017-09-10 21:57:04 +03:00
|
|
|
let tgt_load = {};
|
|
|
|
let tgt_check = {};
|
2018-11-05 17:41:45 +03:00
|
|
|
|
|
|
|
Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
|
|
|
|
registerCleanupFunction(() => {
|
|
|
|
Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
|
|
|
|
});
|
2018-01-30 02:20:18 +03:00
|
|
|
const a = ChromeUtils.import("resource://test/environment_loadscript.jsm", tgt_load);
|
|
|
|
const b = ChromeUtils.import("resource://test/environment_checkscript.jsm", tgt_check);
|
2017-09-14 23:08:17 +03:00
|
|
|
|
|
|
|
const isShared = Cu.getGlobalForObject(a) === Cu.getGlobalForObject(b);
|
2017-09-10 21:57:04 +03:00
|
|
|
|
|
|
|
// Check target bindings
|
|
|
|
var tgt_subscript_bound = "";
|
|
|
|
for (var name of ["vu", "vq", "vl", "gt", "ed", "ei", "fo", "fi", "fd"])
|
|
|
|
if (tgt_load.target.hasOwnProperty(name))
|
|
|
|
tgt_subscript_bound += name + ",";
|
|
|
|
|
|
|
|
// Expected subscript loader behavior is as follows:
|
|
|
|
// - Qualified vars and |this| access occur on target object
|
|
|
|
// - Lexical vars occur on ExtensibleLexicalEnvironment of target object
|
|
|
|
// - Bareword assignments and global |this| access occur on caller's global
|
2017-09-14 23:08:17 +03:00
|
|
|
Assert.equal(tgt_load.bound, "vu,ei,fo,fi,", "Should have expected module binding set");
|
|
|
|
Assert.equal(tgt_subscript_bound, "vq,gt,ed,fd,", "Should have expected subscript binding set");
|
2017-09-10 21:57:04 +03:00
|
|
|
|
|
|
|
// Components should not share namespace
|
2017-09-14 23:08:17 +03:00
|
|
|
if (isShared) {
|
|
|
|
todo_check_eq(tgt_check.bound, "");
|
|
|
|
Assert.equal(tgt_check.bound, "ei,fo,", "Modules should have no shared non-eval bindings");
|
|
|
|
} else {
|
|
|
|
Assert.equal(tgt_check.bound, "", "Modules should have no shared bindings");
|
|
|
|
}
|