Bug 1003095 - Create a whitelist for the chrome module;r=past

This commit is contained in:
Eddy Bruel 2014-05-21 14:01:20 +02:00
Родитель 19550e9c57
Коммит 55c6905c8b
1 изменённых файлов: 30 добавлений и 0 удалений

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

@ -94,6 +94,25 @@ function createModule(id) {
});
};
// A whitelist of modules from which the built-in chrome module may be
// required. The idea is add all modules that depend on chrome to the whitelist
// initially, and then remove them one by one, fixing any errors as we go along.
// Once the whitelist is empty, we can remove the built-in chrome module from
// the loader entirely.
//
// TODO: Remove this when the whitelist becomes empty
let chromeWhitelist = [
"devtools/server/main",
"devtools/toolkit/transport/transport",
"devtools/toolkit/transport/stream-utils",
"devtools/toolkit/transport/packets",
"devtools/toolkit/DevToolsUtils",
"devtools/toolkit/event-emitter",
"devtools/server/protocol",
"devtools/server/actors/script",
"devtools/styleinspector/css-logic",
];
// Create a CommonJS loader with the following options:
// - createSandbox:
// A function that will be used to create sandboxes. It takes the name and
@ -176,6 +195,17 @@ function WorkerDebuggerLoader(options) {
throw new Error("can't require module without id!");
}
// If the module to be required is the built-in chrome module, and the
// requirer is not in the whitelist, return a vacuous object as if the
// module was unavailable.
//
// TODO: Remove this when the whitelist becomes empty
if (id === "chrome" && chromeWhitelist.indexOf(requirer.id) < 0) {
return { CC: undefined, Cc: undefined, ChromeWorker: undefined,
Cm: undefined, Ci: undefined, Cu: undefined, Cr: undefined,
components: undefined };
}
// Built-in modules are cached by id rather than URL, so try to find the
// module to be required by id first.
let module = modules[id];