Bug 1016301 - Convert testactors.js to use native promises;r=past
This commit is contained in:
@@ -44,7 +44,7 @@ function TestTabList(aConnection) {
|
|||||||
TestTabList.prototype = {
|
TestTabList.prototype = {
|
||||||
constructor: TestTabList,
|
constructor: TestTabList,
|
||||||
getList: function () {
|
getList: function () {
|
||||||
return promise.resolve([tabActor for (tabActor of this._tabActors)]);
|
return Promise.resolve([tabActor for (tabActor of this._tabActors)]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -269,75 +269,68 @@ const chrome = { CC: undefined, Cc: undefined, ChromeWorker: undefined,
|
|||||||
// The default instance of the worker debugger loader is defined differently
|
// The default instance of the worker debugger loader is defined differently
|
||||||
// depending on whether it is loaded from the main thread or a worker thread.
|
// depending on whether it is loaded from the main thread or a worker thread.
|
||||||
if (typeof Components === "object") {
|
if (typeof Components === "object") {
|
||||||
(function () {
|
const { Constructor: CC, classes: Cc, manager: Cm, interfaces: Ci,
|
||||||
const { Constructor: CC, classes: Cc, manager: Cm, interfaces: Ci,
|
results: Cr, utils: Cu } = Components;
|
||||||
results: Cr, utils: Cu } = Components;
|
|
||||||
|
|
||||||
const principal = CC('@mozilla.org/systemprincipal;1', 'nsIPrincipal')();
|
const principal = CC('@mozilla.org/systemprincipal;1', 'nsIPrincipal')();
|
||||||
|
|
||||||
// Create a sandbox with the given name and prototype.
|
// Create a sandbox with the given name and prototype.
|
||||||
const createSandbox = function (name, prototype) {
|
const createSandbox = function (name, prototype) {
|
||||||
return Cu.Sandbox(principal, {
|
return Cu.Sandbox(principal, {
|
||||||
invisibleToDebugger: true,
|
invisibleToDebugger: true,
|
||||||
sandboxName: name,
|
sandboxName: name,
|
||||||
sandboxPrototype: prototype,
|
sandboxPrototype: prototype,
|
||||||
wantComponents: false,
|
wantComponents: false,
|
||||||
wantXrays: false
|
wantXrays: false
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const loadSubScript = Cc['@mozilla.org/moz/jssubscript-loader;1'].
|
|
||||||
getService(Ci.mozIJSSubScriptLoader).loadSubScript;
|
|
||||||
|
|
||||||
// Load a script from the given URL in the given sandbox.
|
|
||||||
const loadInSandbox = function (url, sandbox) {
|
|
||||||
loadSubScript(url, sandbox, "UTF-8");
|
|
||||||
};
|
|
||||||
|
|
||||||
// Define the Debugger object in a sandbox to ensure that the this passed to
|
|
||||||
// addDebuggerToGlobal is a global.
|
|
||||||
const Debugger = (function () {
|
|
||||||
let sandbox = Cu.Sandbox(principal, {});
|
|
||||||
Cu.evalInSandbox(
|
|
||||||
"Components.utils.import('resource://gre/modules/jsdebugger.jsm');" +
|
|
||||||
"addDebuggerToGlobal(this);",
|
|
||||||
sandbox
|
|
||||||
);
|
|
||||||
return sandbox.Debugger;
|
|
||||||
})();
|
|
||||||
|
|
||||||
// TODO: Replace this with native promises: bug 1016301
|
|
||||||
const { Promise } = Cu.import("resource://gre/modules/Promise.jsm", {});;
|
|
||||||
const Timer = Cu.import("resource://gre/modules/Timer.jsm", {});
|
|
||||||
const xpcInspector = Cc["@mozilla.org/jsinspector;1"].
|
|
||||||
getService(Ci.nsIJSInspector);
|
|
||||||
|
|
||||||
this.worker = new WorkerDebuggerLoader({
|
|
||||||
createSandbox: createSandbox,
|
|
||||||
globals: {
|
|
||||||
"isWorker": true,
|
|
||||||
"Debugger": Debugger,
|
|
||||||
"promise": Promise,
|
|
||||||
"reportError": Cu.reportError,
|
|
||||||
"setInterval": Timer.setInterval,
|
|
||||||
"setTimeout": Timer.setTimeout,
|
|
||||||
"clearInterval": Timer.clearInterval,
|
|
||||||
"clearTimeout": Timer.clearTimeout,
|
|
||||||
"xpcInspector": xpcInspector,
|
|
||||||
},
|
|
||||||
loadInSandbox: loadInSandbox,
|
|
||||||
modules: {
|
|
||||||
"Services": {},
|
|
||||||
"chrome": chrome,
|
|
||||||
},
|
|
||||||
paths: {
|
|
||||||
"": "resource://gre/modules/commonjs/",
|
|
||||||
"devtools": "resource:///modules/devtools",
|
|
||||||
"devtools/server": "resource://gre/modules/devtools/server",
|
|
||||||
"devtools/toolkit": "resource://gre/modules/devtools",
|
|
||||||
"source-map": "resource://gre/modules/devtools/source-map",
|
|
||||||
"xpcshell-test": "resource://test",
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}).call(this);
|
};
|
||||||
|
|
||||||
|
const loadSubScript = Cc['@mozilla.org/moz/jssubscript-loader;1'].
|
||||||
|
getService(Ci.mozIJSSubScriptLoader).loadSubScript;
|
||||||
|
|
||||||
|
// Load a script from the given URL in the given sandbox.
|
||||||
|
const loadInSandbox = function (url, sandbox) {
|
||||||
|
loadSubScript(url, sandbox, "UTF-8");
|
||||||
|
};
|
||||||
|
|
||||||
|
// Define the Debugger object in a sandbox to ensure that the this passed to
|
||||||
|
// addDebuggerToGlobal is a global.
|
||||||
|
let sandbox = Cu.Sandbox(principal, {});
|
||||||
|
Cu.evalInSandbox(
|
||||||
|
"Components.utils.import('resource://gre/modules/jsdebugger.jsm');" +
|
||||||
|
"addDebuggerToGlobal(this);",
|
||||||
|
sandbox
|
||||||
|
);
|
||||||
|
const Debugger = sandbox.Debugger;
|
||||||
|
|
||||||
|
const Timer = Cu.import("resource://gre/modules/Timer.jsm", {});
|
||||||
|
const xpcInspector = Cc["@mozilla.org/jsinspector;1"].
|
||||||
|
getService(Ci.nsIJSInspector);
|
||||||
|
|
||||||
|
this.worker = new WorkerDebuggerLoader({
|
||||||
|
createSandbox: createSandbox,
|
||||||
|
globals: {
|
||||||
|
"isWorker": true,
|
||||||
|
"Debugger": Debugger,
|
||||||
|
"setInterval": Timer.setInterval,
|
||||||
|
"setTimeout": Timer.setTimeout,
|
||||||
|
"clearInterval": Timer.clearInterval,
|
||||||
|
"clearTimeout": Timer.clearTimeout,
|
||||||
|
"xpcInspector": xpcInspector,
|
||||||
|
"reportError": Cu.reportError,
|
||||||
|
},
|
||||||
|
loadInSandbox: loadInSandbox,
|
||||||
|
modules: {
|
||||||
|
"Services": {},
|
||||||
|
"chrome": chrome,
|
||||||
|
},
|
||||||
|
paths: {
|
||||||
|
"": "resource://gre/modules/commonjs/",
|
||||||
|
"devtools": "resource:///modules/devtools",
|
||||||
|
"devtools/server": "resource://gre/modules/devtools/server",
|
||||||
|
"devtools/toolkit": "resource://gre/modules/devtools",
|
||||||
|
"source-map": "resource://gre/modules/devtools/source-map",
|
||||||
|
"xpcshell-test": "resource://test",
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user