зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1727571 - [devtools] Prevent the allocation tracker to record its own modules. r=jdescottes
It was tracking the special sandbox we spawn for builtin-modules.js as well as its internal sandbox used to fetch platform globals. Differential Revision: https://phabricator.services.mozilla.com/D124174
This commit is contained in:
Родитель
8127145d8f
Коммит
c644e2c255
|
@ -38,7 +38,7 @@ const {
|
|||
|
||||
// Create a single Sandbox to access global properties needed in this module.
|
||||
// Sandbox are memory expensive, so we should create as little as possible.
|
||||
const debuggerSandbox = Cu.Sandbox(systemPrincipal, {
|
||||
const debuggerSandbox = (exports.internalSandbox = Cu.Sandbox(systemPrincipal, {
|
||||
// This sandbox is also reused for ChromeDebugger implementation.
|
||||
// As we want to load the `Debugger` API for debugging chrome contexts,
|
||||
// we have to ensure loading it in a distinct compartment from its debuggee.
|
||||
|
@ -66,7 +66,7 @@ const debuggerSandbox = Cu.Sandbox(systemPrincipal, {
|
|||
"URL",
|
||||
"XMLHttpRequest",
|
||||
],
|
||||
});
|
||||
}));
|
||||
|
||||
const {
|
||||
AbortController,
|
||||
|
|
|
@ -82,14 +82,28 @@ exports.allocationTracker = function({
|
|||
acceptGlobal = () => true;
|
||||
} else if (watchDevToolsGlobals) {
|
||||
// Only accept globals related to DevTools
|
||||
const builtinGlobal = require("devtools/shared/builtin-modules");
|
||||
acceptGlobal = g => {
|
||||
// self-hosting-global crashes when trying to call unsafeDereference
|
||||
if (g.class == "self-hosting-global") {
|
||||
dump("TRACKER NEW GLOBAL: - : " + g.class + "\n");
|
||||
return false;
|
||||
}
|
||||
const ref = g.unsafeDereference();
|
||||
const location = Cu.getRealmLocation(ref);
|
||||
const accept = !!location.match(/devtools/i);
|
||||
let accept = !!location.match(/devtools/i);
|
||||
|
||||
// Also ignore the dedicated Sandbox used to spawn builtin-modules,
|
||||
// as well as its internal Sandbox used to fetch various platform globals.
|
||||
// We ignore the global used by the dedicated loader used to load
|
||||
// the allocation-tracker module.
|
||||
if (
|
||||
ref == Cu.getGlobalForObject(builtinGlobal) ||
|
||||
ref == builtinGlobal.internalSandbox
|
||||
) {
|
||||
accept = false;
|
||||
}
|
||||
|
||||
dump(
|
||||
"TRACKER NEW GLOBAL: " + (accept ? "+" : "-") + " : " + location + "\n"
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче