Using import() from a Sandbox throws with NS_ERROR_OUT_OF_MEMORY
Categories
(Core :: JavaScript Engine, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox67 | --- | fixed |
People
(Reporter: ochameau, Assigned: jonco)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
patch
|
baku
:
review+
|
Details | Diff | Splinter Review |
I was trying to see if we could start using import() in code DevTools modules,
but I'm getting exception when trying to use import() from a privileged Sandbox:
const s = Cu.Sandbox(Services.scriptSecurityManager.getSystemPrincipal());
Cu.evalInSandbox("import('https://cdn.jsdelivr.net/gh/lodash/lodash/camelCase.js')", s);
=> (NS_ERROR_OUT_OF_MEMORY) [nsIXPCComponents_Utils.evalInSandbox]" nsresult: "0x8007000e (NS_ERROR_OUT_OF_MEMORY)"
Note that the same applies to Sandbox with a content principal:
const s = Cu.Sandbox("http://jsdelivr.net")
Cu.evalInSandbox("import('https://cdn.jsdelivr.net/gh/lodash/lodash/camelCase.js')", s);
And it also fails if I'm trying to load a ES Modules from a resource URI:
const s = Cu.Sandbox(Services.scriptSecurityManager.getSystemPrincipal());
Cu.evalInSandbox("var x = import('resource://devtools/shared/event-emitter.jsm')", s)
(I added this event-emitter.jsm module, it doesn't exists in m-c)
Reporter | ||
Comment 1•6 years ago
|
||
Note that, this is not a must-have feature.
You may as well say import() is not planned to work in Sandboxes.
It's just that I was hitting this exception while looking into bug 1525652.
Assignee | ||
Comment 2•6 years ago
|
||
Modules are not implemented in the context of a Sandbox. However this should be reporting a more useful error than NS_ERROR_OUT_OF_MEMORY.
Assignee | ||
Comment 3•6 years ago
|
||
Patch to report an error if we can't find a ScriptLoader for the current context.
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Pushed by cbrindusan@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/95fd39d659bc
Report an error if there's no ScriptLoader for the current context. r=baku
Comment 5•6 years ago
|
||
bugherder |
Description
•