Bug 1263629 - Use promise module invisible to the debugger for the browser toolbox server. r=jryans

This commit is contained in:
Alexandre Poirot 2016-04-14 14:32:21 -07:00
Родитель fba2aa9c7b
Коммит c0d0fa5173
2 изменённых файлов: 53 добавлений и 20 удалений

Просмотреть файл

@ -26,7 +26,6 @@ this.EXPORTED_SYMBOLS = ["DevToolsLoader", "devtools", "BuiltinProvider",
var loaderModules = {
"Services": Object.create(Services),
"toolkit/loader": Loader,
promise,
PromiseDebugging,
ChromeUtils,
ThreadSafeChromeUtils,
@ -82,19 +81,7 @@ XPCOMUtils.defineLazyGetter(loaderModules, "URL", () => {
return sandbox.URL;
});
var sharedGlobalBlocklist = ["sdk/indexed-db"];
/**
* Used when the tools should be loaded from the Firefox package itself.
* This is the default case.
*/
function BuiltinProvider() {}
BuiltinProvider.prototype = {
load: function() {
this.loader = new Loader.Loader({
id: "fx-devtools",
modules: loaderModules,
paths: {
const loaderPaths = {
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
"": "resource://gre/modules/commonjs/",
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
@ -109,9 +96,43 @@ BuiltinProvider.prototype = {
"source-map": "resource://devtools/shared/sourcemap/source-map.js",
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
// Allow access to xpcshell test items from the loader.
"xpcshell-test": "resource://test"
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
},
"xpcshell-test": "resource://test",
};
var sharedGlobalBlocklist = ["sdk/indexed-db"];
/**
* Used when the tools should be loaded from the Firefox package itself.
* This is the default case.
*/
function BuiltinProvider() {}
BuiltinProvider.prototype = {
load: function() {
// Copy generic paths and modules for this loader instance
let paths = {};
for (let path in loaderPaths) {
paths[path] = loaderPaths[path];
}
let modules = {};
for (let name in loaderModules) {
XPCOMUtils.defineLazyGetter(modules, name, (function (name) {
return loaderModules[name];
}).bind(null, name));
}
// When creating a Loader invisible to the Debugger, we have to ensure
// using only modules and not depend on any JSM. As everything that is
// not loaded with Loader isn't going to respect `invisibleToDebugger`.
// But we have to keep using Promise.jsm for other loader to prevent
// breaking unhandled promise rejection in tests.
if (this.invisibleToDebugger) {
paths["promise"] = "resource://gre/modules/Promise-backend.js";
} else {
modules["promise"] = promise;
}
this.loader = new Loader.Loader({
id: "fx-devtools",
modules,
paths,
globals: this.globals,
invisibleToDebugger: this.invisibleToDebugger,
sharedGlobal: true,

Просмотреть файл

@ -27,6 +27,11 @@ function visible_loader() {
} catch(e) {
do_throw("debugger could not add visible value");
}
// Check that for common loader used for tabs, promise modules is Promise.jsm
// Which is required to support unhandled promises rejection in mochitests
const promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
do_check_eq(loader.require("promise"), promise);
}
function invisible_loader() {
@ -43,4 +48,11 @@ function invisible_loader() {
} catch(e) {
do_check_true(true);
}
// But for browser toolbox loader, promise is loaded as a regular modules out
// of Promise-backend.js, that to be invisible to the debugger and not step
// into it.
const promise = loader.require("promise");
const promiseModule = loader._provider.loader.modules["resource://gre/modules/Promise-backend.js"];
do_check_eq(promise, promiseModule.exports);
}