зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1398601 - Add testcase for loading subscripts within a JSM r=kmag
MozReview-Commit-ID: I09eoUnQYCG --HG-- extra : rebase_source : b0950f8b5e98ee3bc52fa03067d904687feefcf5
This commit is contained in:
Родитель
ff55566d27
Коммит
d09e551152
|
@ -0,0 +1,18 @@
|
|||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var EXPORTED_SYMBOLS = ["target", "bound"];
|
||||
|
||||
var bound = "";
|
||||
var target = {};
|
||||
Services.scriptloader.loadSubScript("resource://test/environment_script.js", target);
|
||||
|
||||
// Check global bindings
|
||||
try { void vu; bound += "vu,"; } catch (e) {}
|
||||
try { void vq; bound += "vq,"; } catch (e) {}
|
||||
try { void vl; bound += "vl,"; } catch (e) {}
|
||||
try { void gt; bound += "gt,"; } catch (e) {}
|
||||
try { void ed; bound += "ed,"; } catch (e) {}
|
||||
try { void ei; bound += "ei,"; } catch (e) {}
|
||||
try { void fo; bound += "fo,"; } catch (e) {}
|
||||
try { void fi; bound += "fi,"; } catch (e) {}
|
||||
try { void fd; bound += "fd,"; } catch (e) {}
|
|
@ -0,0 +1,23 @@
|
|||
let tgt_load = {};
|
||||
let tgt_check = {};
|
||||
Components.utils.import("resource://test/environment_loadscript.jsm", tgt_load);
|
||||
Components.utils.import("resource://test/environment_checkscript.jsm", tgt_check);
|
||||
|
||||
// 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
|
||||
if (tgt_load.bound != "vu,ei,fo,fi,")
|
||||
throw new Error("Unexpected global binding set - " + tgt_load.bound);
|
||||
if (tgt_subscript_bound != "vq,gt,ed,fd,")
|
||||
throw new Error("Unexpected target binding set - " + tgt_subscript_bound);
|
||||
|
||||
// Components should not share namespace
|
||||
if (tgt_check.bound != "")
|
||||
throw new Error("Unexpected shared binding set - " + tgt_check.bound);
|
|
@ -12,6 +12,7 @@ support-files =
|
|||
component_import.js
|
||||
component_import.manifest
|
||||
environment_script.js
|
||||
environment_loadscript.jsm
|
||||
environment_checkscript.jsm
|
||||
file_simple_script.js
|
||||
importer.jsm
|
||||
|
@ -142,4 +143,5 @@ head = head_watchdog.js
|
|||
[test_FrameScriptEnvironment.js]
|
||||
[test_SubscriptLoaderEnvironment.js]
|
||||
[test_SubscriptLoaderSandboxEnvironment.js]
|
||||
[test_SubscriptLoaderJSMEnvironment.js]
|
||||
[test_ComponentEnvironment.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче