зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 0ca665e88ae5 (bug 1164564) for Linux debug test_promises_actor_onpromisesettled.js failures.
This commit is contained in:
Родитель
512484cf45
Коммит
480baa5452
|
@ -30,6 +30,7 @@ this.EXPORTED_SYMBOLS = ["DevToolsLoader", "devtools", "BuiltinProvider",
|
|||
let loaderModules = {
|
||||
"Services": Object.create(Services),
|
||||
"toolkit/loader": loader,
|
||||
"promise": promise,
|
||||
"PromiseDebugging": PromiseDebugging
|
||||
};
|
||||
XPCOMUtils.defineLazyGetter(loaderModules, "Debugger", () => {
|
||||
|
@ -95,7 +96,6 @@ BuiltinProvider.prototype = {
|
|||
"devtools/content-observer": "resource://gre/modules/devtools/content-observer",
|
||||
"gcli": "resource://gre/modules/devtools/gcli",
|
||||
"projecteditor": "resource:///modules/devtools/projecteditor",
|
||||
"promise": "resource://gre/modules/Promise-backend.js",
|
||||
"acorn": "resource://gre/modules/devtools/acorn",
|
||||
"acorn/util/walk": "resource://gre/modules/devtools/acorn/walk.js",
|
||||
"tern": "resource://gre/modules/devtools/tern",
|
||||
|
@ -135,7 +135,6 @@ SrcdirProvider.prototype = {
|
|||
srcdir = OS.Path.normalize(srcdir.data.trim());
|
||||
let devtoolsDir = OS.Path.join(srcdir, "browser", "devtools");
|
||||
let toolkitDir = OS.Path.join(srcdir, "toolkit", "devtools");
|
||||
let modulesDir = OS.Path.join(srcdir, "toolkit", "modules");
|
||||
let mainURI = this.fileURI(OS.Path.join(devtoolsDir, "main.js"));
|
||||
let definitionsURI = this.fileURI(OS.Path.join(devtoolsDir, "definitions.js"));
|
||||
let devtoolsURI = this.fileURI(devtoolsDir);
|
||||
|
@ -154,7 +153,6 @@ SrcdirProvider.prototype = {
|
|||
let contentObserverURI = this.fileURI(OS.Path.join(toolkitDir), "content-observer.js");
|
||||
let gcliURI = this.fileURI(OS.Path.join(toolkitDir, "gcli", "source", "lib", "gcli"));
|
||||
let projecteditorURI = this.fileURI(OS.Path.join(devtoolsDir, "projecteditor"));
|
||||
let promiseURI = this.fileURI(OS.Path.join(modulesDir, "promise-backend.js"));
|
||||
let acornURI = this.fileURI(OS.Path.join(toolkitDir, "acorn"));
|
||||
let acornWalkURI = OS.Path.join(acornURI, "walk.js");
|
||||
let ternURI = OS.Path.join(toolkitDir, "tern");
|
||||
|
@ -182,7 +180,6 @@ SrcdirProvider.prototype = {
|
|||
"devtools/content-observer": contentObserverURI,
|
||||
"gcli": gcliURI,
|
||||
"projecteditor": projecteditorURI,
|
||||
"promise": promiseURI,
|
||||
"acorn": acornURI,
|
||||
"acorn/util/walk": acornWalkURI,
|
||||
"tern": ternURI,
|
||||
|
|
|
@ -22,28 +22,9 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// Globals
|
||||
|
||||
// Obtain an instance of Cu. How this instance is obtained depends on how this
|
||||
// file is loaded.
|
||||
//
|
||||
// This file can be loaded in three different ways:
|
||||
// 1. As a CommonJS module, by Loader.jsm, on the main thread.
|
||||
// 2. As a CommonJS module, by worker-loader.js, on a worker thread.
|
||||
// 3. As a subscript, by Promise.jsm, on the main thread.
|
||||
//
|
||||
// If require is defined, the file is loaded as a CommonJS module. Components
|
||||
// will not be defined in that case, but we can obtain an instance of Cu from
|
||||
// the chrome module. Otherwise, this file is loaded as a subscript, and we can
|
||||
// obtain an instance of Cu from Components directly.
|
||||
//
|
||||
// If the file is loaded as a CommonJS module on a worker thread, the instance
|
||||
// of Cu obtained from the chrome module will be null. The reason for this is
|
||||
// that Components is not defined in worker threads, so no instance of Cu can
|
||||
// be obtained.
|
||||
|
||||
let Cu = this.require ? require("chrome").Cu : Components.utils;
|
||||
|
||||
// If Cu is defined, use it to lazily define the FinalizationWitnessService.
|
||||
if (Cu) {
|
||||
// Do not load the FinalizationWitnessService is we are being required as a
|
||||
// CommonJS module, because the Components object is not available in workers.
|
||||
if (!isWorker) {
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
|
@ -65,7 +46,7 @@ const salt = Math.floor(Math.random() * 100);
|
|||
const N_INTERNALS = "{private:internals:" + salt + "}";
|
||||
|
||||
// We use DOM Promise for scheduling the walker loop.
|
||||
const DOMPromise = Cu ? Promise : null;
|
||||
const DOMPromise = isWorker ? null : Promise;
|
||||
|
||||
/////// Warn-upon-finalization mechanism
|
||||
//
|
||||
|
@ -271,9 +252,10 @@ let PendingErrors = {
|
|||
}
|
||||
};
|
||||
|
||||
// Initialize the warn-upon-finalization mechanism if and only if Cu is defined.
|
||||
// Otherwise, FinalizationWitnessService won't be defined (see above).
|
||||
if (Cu) {
|
||||
// Do not initialize the warn-on-finalization mechanism if we are being required
|
||||
// as a CommonJS module by the worker loader, because the Components object (and
|
||||
// therefore the FinalizationWitnessService) is not available.
|
||||
if (!isWorker) {
|
||||
PendingErrors.init();
|
||||
}
|
||||
|
||||
|
@ -646,9 +628,9 @@ Object.freeze(Promise.Debugging);
|
|||
|
||||
Object.freeze(Promise);
|
||||
|
||||
// If module is defined, this file is loaded as a CommonJS module. Make sure
|
||||
// Promise is exported in that case.
|
||||
if (this.module) {
|
||||
// Make sure to export the Promise object if we are being required as a CommonJS
|
||||
// module by the worker loader.
|
||||
if (isWorker) {
|
||||
module.exports = Promise;
|
||||
}
|
||||
|
||||
|
@ -703,7 +685,7 @@ this.PromiseWalker = {
|
|||
aPromise[N_INTERNALS].value = aValue;
|
||||
if (aPromise[N_INTERNALS].handlers.length > 0) {
|
||||
this.schedulePromise(aPromise);
|
||||
} else if (Cu && aStatus == STATUS_REJECTED) {
|
||||
} else if (!isWorker && aStatus == STATUS_REJECTED) {
|
||||
// This is a rejection and the promise is the last in the chain.
|
||||
// For the time being we therefore have an uncaught error.
|
||||
let id = PendingErrors.register(aValue);
|
||||
|
@ -719,25 +701,10 @@ this.PromiseWalker = {
|
|||
scheduleWalkerLoop: function()
|
||||
{
|
||||
this.walkerLoopScheduled = true;
|
||||
|
||||
// If this file is loaded on a worker thread, DOMPromise will not behave as
|
||||
// expected: because native promises are not aware of nested event loops
|
||||
// created by the debugger, their respective handlers will not be called
|
||||
// until after leaving the nested event loop. The debugger server relies
|
||||
// heavily on the use promises, so this could cause the debugger to hang.
|
||||
//
|
||||
// To work around this problem, any use of native promises in the debugger
|
||||
// server should be avoided when it is running on a worker thread. Because
|
||||
// it is still necessary to be able to schedule runnables on the event
|
||||
// queue, the worker loader defines the function setImmediate as a
|
||||
// per-module global for this purpose.
|
||||
//
|
||||
// If Cu is defined, this file is loaded on the main thread. Otherwise, it
|
||||
// is loaded on the worker thread.
|
||||
if (Cu) {
|
||||
DOMPromise.resolve().then(() => this.walkerLoop());
|
||||
} else {
|
||||
if (isWorker) {
|
||||
setImmediate(this.walkerLoop);
|
||||
} else {
|
||||
DOMPromise.resolve().then(() => this.walkerLoop());
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -96,6 +96,17 @@ this.Ci = Components.interfaces;
|
|||
this.Cu = Components.utils;
|
||||
this.Cr = Components.results;
|
||||
|
||||
// Promise-backend.js can either be loaded as a subscript by this file, or
|
||||
// required as a CommonJS module by the worker loader. Because certain APIS (in
|
||||
// particular, Components) are not available in workers, Promise-backend.js
|
||||
// behaves slightly different in the latter case.
|
||||
//
|
||||
// To distinguish between these two cases, the worker loader defines a global
|
||||
// variable isWorker, and sets it to true. When loading Promise-backend.js as
|
||||
// a subscript, we need to make sure this variable is defined as well, and set
|
||||
// it to false.
|
||||
this.isWorker = false;
|
||||
|
||||
this.Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(this.Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("resource://gre/modules/Promise-backend.js", this);
|
||||
|
|
Загрузка…
Ссылка в новой задаче