mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 788405 - variables created via importScripts should be globals. r=gavin
This commit is contained in:
parent
cdd4ae9faf
commit
88360f0511
@ -130,6 +130,13 @@ FrameWorker.prototype = {
|
||||
};
|
||||
sandbox.navigator = navigator;
|
||||
|
||||
// Our importScripts function needs to 'eval' the script code from inside
|
||||
// a function, but using eval() directly means functions in the script
|
||||
// don't end up in the global scope.
|
||||
sandbox._evalInSandbox = function(s) {
|
||||
Cu.evalInSandbox(s, sandbox);
|
||||
};
|
||||
|
||||
// and we delegate ononline and onoffline events to the worker.
|
||||
// See http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#workerglobalscope
|
||||
this.frame.addEventListener('offline', function fw_onoffline(event) {
|
||||
|
@ -32,7 +32,7 @@ function importScripts() {
|
||||
xhr.onreadystatechange = function(aEvt) {
|
||||
if (xhr.readyState == 4) {
|
||||
if (xhr.status == 200 || xhr.status == 0) {
|
||||
eval(xhr.responseText);
|
||||
_evalInSandbox(xhr.responseText);
|
||||
}
|
||||
else {
|
||||
throw new Error("Unable to importScripts ["+scriptURL+"], status " + xhr.status)
|
||||
|
@ -1 +1,6 @@
|
||||
dump("relative_import file\n");
|
||||
|
||||
testVar = "oh hai";
|
||||
function testFunc() {
|
||||
return "oh hai";
|
||||
}
|
||||
|
@ -4,7 +4,12 @@ onconnect = function(e) {
|
||||
let req;
|
||||
try {
|
||||
importScripts("relative_import.js");
|
||||
port.postMessage({topic: "done", result: "ok"});
|
||||
// the import should have exposed "testVar" and "testFunc" from the module.
|
||||
if (testVar == "oh hai" && testFunc() == "oh hai") {
|
||||
port.postMessage({topic: "done", result: "ok"});
|
||||
} else {
|
||||
port.postMessage({topic: "done", result: "import worked but global is not available"});
|
||||
}
|
||||
} catch(e) {
|
||||
port.postMessage({topic: "done", result: "FAILED to importScripts, " + e.toString() });
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user