зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1796582 - [devtools] Use distinctSystemPrincipalLoader instead of invisibleToDebugger when possible r=ochameau
Differential Revision: https://phabricator.services.mozilla.com/D160214
This commit is contained in:
Родитель
940cf12bc4
Коммит
6583edacfb
|
@ -4,7 +4,12 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var { loader, require, DevToolsLoader } = ChromeUtils.importESModule(
|
||||
var {
|
||||
loader,
|
||||
require,
|
||||
useDistinctSystemPrincipalLoader,
|
||||
releaseDistinctSystemPrincipalLoader,
|
||||
} = ChromeUtils.importESModule(
|
||||
"resource://devtools/shared/loader/Loader.sys.mjs"
|
||||
);
|
||||
|
||||
|
@ -260,15 +265,16 @@ async function openToolbox(commands) {
|
|||
}
|
||||
}
|
||||
|
||||
let releaseTestLoader = null;
|
||||
function installTestingServer() {
|
||||
// Install a DevToolsServer in this process and inform the server of its
|
||||
// location. Tests operating on the browser toolbox run in the server
|
||||
// (the firefox parent process) and can connect to this new server using
|
||||
// initBrowserToolboxTask(), allowing them to evaluate scripts here.
|
||||
|
||||
const testLoader = new DevToolsLoader({
|
||||
invisibleToDebugger: true,
|
||||
});
|
||||
const requester = {};
|
||||
const testLoader = useDistinctSystemPrincipalLoader(requester);
|
||||
releaseTestLoader = () => releaseDistinctSystemPrincipalLoader(requester);
|
||||
const { DevToolsServer } = testLoader.require(
|
||||
"resource://devtools/server/devtools-server.js"
|
||||
);
|
||||
|
@ -319,6 +325,10 @@ function updateBadgeText(paused) {
|
|||
function onUnload() {
|
||||
window.removeEventListener("unload", onUnload);
|
||||
gToolbox.destroy();
|
||||
if (releaseTestLoader) {
|
||||
releaseTestLoader();
|
||||
releaseTestLoader = null;
|
||||
}
|
||||
}
|
||||
|
||||
function quitApp() {
|
||||
|
|
|
@ -10,14 +10,18 @@
|
|||
//
|
||||
// If we want to track DevTools module loader we should ensure loading Loader.sys.mjs within
|
||||
// the `testScript` Function. i.e. after having calling startRecordingAllocations.
|
||||
let tracker;
|
||||
let tracker, releaseTrackerLoader;
|
||||
{
|
||||
const { DevToolsLoader } = ChromeUtils.importESModule(
|
||||
const {
|
||||
useDistinctSystemPrincipalLoader,
|
||||
releaseDistinctSystemPrincipalLoader,
|
||||
} = ChromeUtils.importESModule(
|
||||
"resource://devtools/shared/loader/Loader.sys.mjs"
|
||||
);
|
||||
const loader = new DevToolsLoader({
|
||||
invisibleToDebugger: true,
|
||||
});
|
||||
|
||||
const requester = {};
|
||||
const loader = useDistinctSystemPrincipalLoader(requester);
|
||||
releaseTrackerLoader = () => releaseDistinctSystemPrincipalLoader(requester);
|
||||
const { allocationTracker } = loader.require(
|
||||
"chrome://mochitests/content/browser/devtools/shared/test-helpers/allocation-tracker.js"
|
||||
);
|
||||
|
@ -86,12 +90,16 @@ async function startRecordingAllocations({
|
|||
gBrowser.selectedBrowser,
|
||||
[DEBUG_ALLOCATIONS],
|
||||
async debug_allocations => {
|
||||
const { DevToolsLoader } = ChromeUtils.importESModule(
|
||||
const {
|
||||
DevToolsLoader,
|
||||
useDistinctSystemPrincipalLoader,
|
||||
releaseDistinctSystemPrincipalLoader,
|
||||
} = ChromeUtils.importESModule(
|
||||
"resource://devtools/shared/loader/Loader.sys.mjs"
|
||||
);
|
||||
const loader = new DevToolsLoader({
|
||||
invisibleToDebugger: true,
|
||||
});
|
||||
|
||||
const requester = {};
|
||||
const loader = useDistinctSystemPrincipalLoader(requester);
|
||||
const { allocationTracker } = loader.require(
|
||||
"chrome://mochitests/content/browser/devtools/shared/test-helpers/allocation-tracker.js"
|
||||
);
|
||||
|
@ -99,9 +107,11 @@ async function startRecordingAllocations({
|
|||
// because we may easily leak web page objects, which aren't in DevTools global.
|
||||
const tracker = allocationTracker({ watchAllGlobals: true });
|
||||
|
||||
// /!\ HACK: save tracker and doGC on DevToolsLoader in order to be able to reuse
|
||||
// them in a following call to SpecialPowers.spawn
|
||||
// /!\ HACK: store tracker and releaseTrackerLoader on DevToolsLoader in order
|
||||
// to be able to reuse them in a following call to SpecialPowers.spawn
|
||||
DevToolsLoader.tracker = tracker;
|
||||
DevToolsLoader.releaseTrackerLoader = () =>
|
||||
releaseDistinctSystemPrincipalLoader(requester);
|
||||
|
||||
await tracker.startRecordingAllocations(debug_allocations);
|
||||
}
|
||||
|
@ -232,7 +242,19 @@ async function stopRecordingAllocations(
|
|||
},
|
||||
],
|
||||
});
|
||||
|
||||
// Finally release the tracker loader in content process.
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
|
||||
const { DevToolsLoader } = ChromeUtils.importESModule(
|
||||
"resource://devtools/shared/loader/Loader.sys.mjs"
|
||||
);
|
||||
DevToolsLoader.releaseTrackerLoader();
|
||||
});
|
||||
}
|
||||
|
||||
// And release the tracker loader in the parent process
|
||||
releaseTrackerLoader();
|
||||
|
||||
// Log it to stdout so that perfherder can collect this data.
|
||||
// This only works if we called `SimpleTest.requestCompleteLog()`!
|
||||
info("PERFHERDER_DATA: " + JSON.stringify(PERFHERDER_DATA));
|
||||
|
|
|
@ -31,12 +31,17 @@ if (DEBUG_ALLOCATIONS) {
|
|||
// Use a custom loader with `invisibleToDebugger` flag for the allocation tracker
|
||||
// as it instantiates custom Debugger API instances and has to be running in a distinct
|
||||
// compartments from DevTools and system scopes (JSMs, XPCOM,...)
|
||||
const { DevToolsLoader } = ChromeUtils.importESModule(
|
||||
const {
|
||||
useDistinctSystemPrincipalLoader,
|
||||
releaseDistinctSystemPrincipalLoader,
|
||||
} = ChromeUtils.importESModule(
|
||||
"resource://devtools/shared/loader/Loader.sys.mjs"
|
||||
);
|
||||
const loader = new DevToolsLoader({
|
||||
invisibleToDebugger: true,
|
||||
});
|
||||
const requester = {};
|
||||
const loader = useDistinctSystemPrincipalLoader(requester);
|
||||
registerCleanupFunction(() =>
|
||||
releaseDistinctSystemPrincipalLoader(requester)
|
||||
);
|
||||
|
||||
const { allocationTracker } = loader.require(
|
||||
"resource://devtools/shared/test-helpers/allocation-tracker.js"
|
||||
|
|
Загрузка…
Ссылка в новой задаче