Bug 1639716 - [devtools performance] Add a property to the root actor's traits and pass all traits to the gInit function r=jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D129418
This commit is contained in:
Julien Wajsberg 2022-01-26 17:26:21 +00:00
Родитель ff988ebecd
Коммит 58c4dd6381
6 изменённых файлов: 42 добавлений и 4 удалений

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

@ -180,7 +180,8 @@ class ClientWrapper {
*/
async loadPerformanceProfiler(win, openAboutProfiling) {
const perfFront = await this.getFront("perf");
await win.gInit(perfFront, "devtools-remote", openAboutProfiling);
const { traits } = this.client;
await win.gInit(perfFront, traits, "devtools-remote", openAboutProfiling);
}
/**

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

@ -169,6 +169,7 @@ declare namespace MockedExports {
};
wm: {
getMostRecentWindow: (name: string) => ChromeWindow;
getMostRecentNonPBWindow: (name: string) => ChromeWindow;
};
focus: {
activeWindow: ChromeWindow;

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

@ -14,7 +14,12 @@ import {
export interface PanelWindow {
gToolbox?: any;
gStore?: Store;
gInit(perfFront: PerfFront, pageContext: PageContext): Promise<void>;
gInit(
perfFront: PerfFront,
traits: RootTraits,
pageContext: PageContext,
openAboutProfiling?: () => void
): Promise<void>;
gDestroy(): void;
gIsPanelDestroyed?: boolean;
}
@ -39,6 +44,13 @@ export interface Toolbox {
*/
export interface Commands {
client: any;
targetCommand: {
targetFront: {
getTrait: (
traitName: "noDisablingOnPrivateBrowsing"
) => boolean | undefined;
};
};
}
/**
@ -74,6 +86,16 @@ export interface PreferenceFront {
setIntPref: (prefName: string, value: number) => Promise<void>;
}
export interface RootTraits {
// In Firefox >= 98, this will be true, and will be missing for older
// versions. The functionality controlled by this property can be removed once
// Firefox 98 hits release.
noDisablingOnPrivateBrowsing?: boolean;
// There are other properties too, but we don't use them here as they're not
// related to the performance panel.
}
export type RecordingState =
// The initial state before we've queried the PerfActor
| "not-yet-known"

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

@ -14,6 +14,7 @@
* @typedef {import("./@types/perf").MinimallyTypedGeckoProfile} MinimallyTypedGeckoProfile
* @typedef {import("./@types/perf").ProfileCaptureResult} ProfileCaptureResult
* @typedef {import("./@types/perf").ProfilerViewMode} ProfilerViewMode
* @typedef {import("./@types/perf").RootTraits} RootTraits
*/
"use strict";
@ -89,10 +90,13 @@ const {
* Initialize the panel by creating a redux store, and render the root component.
*
* @param {PerfFront} perfFront - The Perf actor's front. Used to start and stop recordings.
* @param {RootTraits} traits - The traits coming from the root actor. This
* makes it possible to change some code path
* depending on the server version.
* @param {PageContext} pageContext - The context that the UI is being loaded in under.
* @param {(() => void)?} openAboutProfiling - Optional call to open about:profiling
*/
async function gInit(perfFront, pageContext, openAboutProfiling) {
async function gInit(perfFront, traits, pageContext, openAboutProfiling) {
const store = createStore(reducers);
const isSupportedPlatform = await perfFront.isSupportedPlatform();
const supportedFeatures = await perfFront.getSupportedFeatures();

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

@ -62,8 +62,13 @@ class PerformancePanel {
this.panelWin.gIsPanelDestroyed = false;
const perfFront = await this.commands.client.mainRoot.getFront("perf");
const traits = {
noDisablingOnPrivateBrowsing: this.commands.targetCommand.targetFront.getTrait(
"noDisablingOnPrivateBrowsing"
),
};
await this.panelWin.gInit(perfFront, "devtools");
await this.panelWin.gInit(perfFront, traits, "devtools");
return this;
}

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

@ -130,6 +130,11 @@ exports.RootActor = protocol.ActorClassWithSpec(rootSpec, {
// @backward-compat { version 86 } ThreadActor.attach no longer pauses the thread,
// so that we no longer have to resume.
noPauseOnThreadActorAttach: true,
// @backward-compat { version 98 }
// Starting version 98, we stopped disabling the profiler if the user has
// a window with private browsing enabled. This trait helps to detect this
// so that different code paths can be called.
noDisablingOnPrivateBrowsing: true,
};
},