diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /devtools/client/performance-new | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/performance-new')
10 files changed, 90 insertions, 46 deletions
diff --git a/devtools/client/performance-new/@types/gecko.d.ts b/devtools/client/performance-new/@types/gecko.d.ts index e03844cb34..f5da78697e 100644 --- a/devtools/client/performance-new/@types/gecko.d.ts +++ b/devtools/client/performance-new/@types/gecko.d.ts @@ -59,6 +59,8 @@ declare namespace MockedExports { addMessageListener: (event: string, listener: (event: any) => void) => void; } + // This is the thing in window.gBrowser, defined in + // https://searchfox.org/mozilla-central/source/browser/base/content/tabbrowser.js interface Browser { addWebTab: (url: string, options: any) => BrowserTab; contentPrincipal: any; @@ -68,28 +70,19 @@ declare namespace MockedExports { ownerDocument?: ChromeDocument; } + // This is a tab in a browser, defined in + // https://searchfox.org/mozilla-central/rev/6b8a3f804789fb865f42af54e9d2fef9dd3ec74d/browser/base/content/tabbrowser.js#2580 interface BrowserTab { - linkedBrowser: Browser; + linkedBrowser: ChromeBrowser; } - interface ChromeWindow { + interface BrowserWindow extends Window { gBrowser: Browser; focus(): void; - openWebLinkIn( - url: string, - where: "current" | "tab" | "window", - options: Partial<{ - // Not all possible options are present, please add more if/when needed. - userContextId: number; - forceNonPrivate: boolean; - relatedToCurrent: boolean; - resolveOnContentBrowserCreated: ( - contentBrowser: ChromeBrowser - ) => unknown; - }> - ): void; } + // The thing created in https://searchfox.org/mozilla-central/rev/6b8a3f804789fb865f42af54e9d2fef9dd3ec74d/browser/base/content/tabbrowser.js#2088 + // This is linked to BrowserTab. interface ChromeBrowser { browsingContext?: BrowsingContext; } @@ -196,11 +189,11 @@ declare namespace MockedExports { removeObserver: (observer: object, type: string) => void; }; wm: { - getMostRecentWindow: (name: string) => ChromeWindow; - getMostRecentNonPBWindow: (name: string) => ChromeWindow; + getMostRecentWindow: (name: string) => BrowserWindow; + getMostRecentNonPBWindow: (name: string) => BrowserWindow; }; focus: { - activeWindow: ChromeWindow; + activeWindow: BrowserWindow; }; io: { newURI(url: string): nsIURI; @@ -249,7 +242,7 @@ declare namespace MockedExports { class nsIFilePicker {} interface FilePicker { - init: (window: Window, title: string, mode: number) => void; + init: (browsingContext: BrowsingContext, title: string, mode: number) => void; open: (callback: (rv: number) => unknown) => void; // The following are enum values. modeGetFolder: number; @@ -404,22 +397,48 @@ declare interface XULElement extends HTMLElement { } declare interface XULIframeElement extends XULElement { - contentWindow: ChromeWindow; + contentWindow: Window; src: string; } -declare interface ChromeWindow extends Window { +// `declare interface Window` is TypeScript way to let us implicitely extend and +// augment the already existing Window interface defined in the TypeScript library. +// This makes it possible to define properties that exist in the window object +// while in a privileged context. We assume that all of the environments we run +// in this project will be pribileged, that's why we take this shortcut of +// globally extending the Window type. +// See the ChromeOnly attributes in https://searchfox.org/mozilla-central/rev/896042a1a71066254ceb5291f016ca3dbca21cb7/dom/webidl/Window.webidl#391 +// +// openWebLinkIn and openTrustedLinkIn aren't in all privileged windows, but +// they're also defined in the privileged environments we're dealing with in +// this project, so they're defined here for convenience. +declare interface Window { + browsingContext: MockedExports.BrowsingContext; openWebLinkIn: ( url: string, where: "current" | "tab" | "tabshifted" | "window" | "save", - // TS-TODO - params?: unknown + options?: Partial<{ + // Not all possible options are present, please add more if/when needed. + userContextId: number; + forceNonPrivate: boolean; + relatedToCurrent: boolean; + resolveOnContentBrowserCreated: ( + contentBrowser: MockedExports.ChromeBrowser + ) => unknown; + }> ) => void; openTrustedLinkIn: ( url: string, where: "current" | "tab" | "tabshifted" | "window" | "save", - // TS-TODO - params?: unknown + options?: Partial<{ + // Not all possible options are present, please add more if/when needed. + userContextId: number; + forceNonPrivate: boolean; + relatedToCurrent: boolean; + resolveOnContentBrowserCreated: ( + contentBrowser: MockedExports.ChromeBrowser + ) => unknown; + }> ) => void; } diff --git a/devtools/client/performance-new/@types/perf.d.ts b/devtools/client/performance-new/@types/perf.d.ts index 2c7ec7f0b4..fb8790bbc1 100644 --- a/devtools/client/performance-new/@types/perf.d.ts +++ b/devtools/client/performance-new/@types/perf.d.ts @@ -474,6 +474,7 @@ export type RequestFromFrontend = | StatusQueryRequest | EnableMenuButtonRequest | GetProfileRequest + | GetExternalMarkersRequest | GetExternalPowerTracksRequest | GetSymbolTableRequest | QuerySymbolicationApiRequest; @@ -481,6 +482,11 @@ export type RequestFromFrontend = type StatusQueryRequest = { type: "STATUS_QUERY" }; type EnableMenuButtonRequest = { type: "ENABLE_MENU_BUTTON" }; type GetProfileRequest = { type: "GET_PROFILE" }; +type GetExternalMarkersRequest = { + type: "GET_EXTERNAL_MARKERS", + startTime: number, + endTime: number, +}; type GetExternalPowerTracksRequest = { type: "GET_EXTERNAL_POWER_TRACKS", startTime: number, @@ -523,6 +529,7 @@ export type ResponseToFrontend = | StatusQueryResponse | EnableMenuButtonResponse | GetProfileResponse + | GetExternalMarkersResponse | GetExternalPowerTracksResponse | GetSymbolTableResponse | QuerySymbolicationApiResponse; @@ -549,6 +556,7 @@ type StatusQueryResponse = { }; type EnableMenuButtonResponse = void; type GetProfileResponse = ArrayBuffer | MinimallyTypedGeckoProfile; +type GetExternalMarkersResponse = Array<object>; type GetExternalPowerTracksResponse = Array<object>; type GetSymbolTableResponse = SymbolTableAsTuple; type QuerySymbolicationApiResponse = string; diff --git a/devtools/client/performance-new/panel/panel.js b/devtools/client/performance-new/panel/panel.js index d099f3c296..2377855d31 100644 --- a/devtools/client/performance-new/panel/panel.js +++ b/devtools/client/performance-new/panel/panel.js @@ -37,9 +37,9 @@ class PerformancePanel { * This is implemented (and overwritten) by the EventEmitter. Is there a way * to use mixins with JSDoc? * - * @param {string} eventName + * @param {string} _eventName */ - emit(eventName) {} + emit(_eventName) {} /** * Open is effectively an asynchronous constructor. diff --git a/devtools/client/performance-new/popup/logic.sys.mjs b/devtools/client/performance-new/popup/logic.sys.mjs index 174163d54b..9c10987ec1 100644 --- a/devtools/client/performance-new/popup/logic.sys.mjs +++ b/devtools/client/performance-new/popup/logic.sys.mjs @@ -36,6 +36,13 @@ const lazy = createLazyLoaders({ */ function selectElementsInPanelview(panelview) { const document = panelview.ownerDocument; + + // Forcefully cast the window to the type Window + /** @type {any} */ + const windowAny = document.defaultView; + /** @type {Window} */ + const window = windowAny; + /** * Get an element or throw an error if it's not found. This is more friendly * for TypeScript. @@ -54,16 +61,10 @@ function selectElementsInPanelview(panelview) { return element; } - // Forcefully cast the window to the type ChromeWindow. - /** @type {any} */ - const chromeWindowAny = document.defaultView; - /** @type {ChromeWindow} */ - const chromeWindow = chromeWindowAny; - return { document, panelview, - window: chromeWindow, + window, inactive: getElementById("PanelUI-profiler-inactive"), active: getElementById("PanelUI-profiler-active"), presetDescription: getElementById("PanelUI-profiler-content-description"), diff --git a/devtools/client/performance-new/popup/menu-button.sys.mjs b/devtools/client/performance-new/popup/menu-button.sys.mjs index f1aee09af4..3dfffb4098 100644 --- a/devtools/client/performance-new/popup/menu-button.sys.mjs +++ b/devtools/client/performance-new/popup/menu-button.sys.mjs @@ -32,10 +32,9 @@ const WIDGET_ID = "profiler-button"; /** * Add the profiler button to the navbar. * - * @param {ChromeDocument} document The browser's document. * @return {void} */ -function addToNavbar(document) { +function addToNavbar() { const { CustomizableUI } = lazy.CustomizableUI(); CustomizableUI.addWidgetToArea(WIDGET_ID, CustomizableUI.AREA_NAVBAR); @@ -173,7 +172,7 @@ function initialize(toggleProfilerKeyShortcuts) { /** * @type {(event: { target: ChromeHTMLElement | XULElement }) => void} */ - onViewHiding(event) { + onViewHiding() { // Clean-up the view. This removes all of the event listeners. for (const fn of panelState.cleanup) { fn(); @@ -292,8 +291,7 @@ function initialize(toggleProfilerKeyShortcuts) { }); }, - // @ts-ignore - Bug 1674368 - onCommand: event => { + onCommand: () => { if (Services.profiler.IsPaused()) { // A profile is already being captured, ignore this event. return; diff --git a/devtools/client/performance-new/shared/background.sys.mjs b/devtools/client/performance-new/shared/background.sys.mjs index f538500a42..4b19f68b71 100644 --- a/devtools/client/performance-new/shared/background.sys.mjs +++ b/devtools/client/performance-new/shared/background.sys.mjs @@ -63,7 +63,7 @@ const PREF_PREFIX = "devtools.performance.recording."; // capabilities of the WebChannel. The front-end can handle old WebChannel // versions and has a full list of versions and capabilities here: // https://github.com/firefox-devtools/profiler/blob/main/src/app-logic/web-channel.js -const CURRENT_WEBCHANNEL_VERSION = 2; +const CURRENT_WEBCHANNEL_VERSION = 3; const lazyRequire = {}; // eslint-disable-next-line mozilla/lazy-getter-object-name @@ -761,7 +761,7 @@ async function getResponseForMessage(request, browser) { // Enable the profiler menu button. const { ProfilerMenuButton } = lazy.ProfilerMenuButton(); - ProfilerMenuButton.addToNavbar(ownerDocument); + ProfilerMenuButton.addToNavbar(); // Dispatch the change event manually, so that the shortcuts will also be // added. @@ -817,6 +817,20 @@ async function getResponseForMessage(request, browser) { } return []; } + case "GET_EXTERNAL_MARKERS": { + const { startTime, endTime } = request; + const externalMarkersUrl = Services.prefs.getCharPref( + "devtools.performance.recording.markers.external-url", + "" + ); + if (externalMarkersUrl) { + const response = await fetch( + `${externalMarkersUrl}?start=${startTime}&end=${endTime}` + ); + return response.json(); + } + return []; + } default: console.error( "An unknown message type was received by the profiler's WebChannel handler.", diff --git a/devtools/client/performance-new/shared/browser.js b/devtools/client/performance-new/shared/browser.js index c97bb0a0ab..34f641cc1b 100644 --- a/devtools/client/performance-new/shared/browser.js +++ b/devtools/client/performance-new/shared/browser.js @@ -153,7 +153,11 @@ function openFilePickerForObjdir(window, objdirs, changeObjdirs) { const FilePicker = Cc["@mozilla.org/filepicker;1"].createInstance( Ci.nsIFilePicker ); - FilePicker.init(window, "Pick build directory", FilePicker.modeGetFolder); + FilePicker.init( + window.browsingContext, + "Pick build directory", + FilePicker.modeGetFolder + ); FilePicker.open(rv => { if (rv == FilePicker.returnOK) { const path = FilePicker.file.path; diff --git a/devtools/client/performance-new/store/actions.js b/devtools/client/performance-new/store/actions.js index 2bb7ce126c..970ce4e644 100644 --- a/devtools/client/performance-new/store/actions.js +++ b/devtools/client/performance-new/store/actions.js @@ -181,7 +181,7 @@ exports.startRecording = perfFront => { * @return {ThunkAction<Promise<MinimallyTypedGeckoProfile>>} */ exports.getProfileAndStopProfiler = perfFront => { - return async ({ dispatch, getState }) => { + return async ({ dispatch }) => { dispatch({ type: "REQUESTING_PROFILE" }); const profile = await perfFront.getProfileAndStopProfiler(); dispatch({ type: "OBTAINED_PROFILE" }); @@ -195,7 +195,7 @@ exports.getProfileAndStopProfiler = perfFront => { * @return {ThunkAction<void>} */ exports.stopProfilerAndDiscardProfile = perfFront => { - return async ({ dispatch, getState }) => { + return async ({ dispatch }) => { dispatch({ type: "REQUESTING_TO_STOP_RECORDING" }); try { diff --git a/devtools/client/performance-new/test/browser/browser_webchannel-enable-menu-button-preset.js b/devtools/client/performance-new/test/browser/browser_webchannel-enable-menu-button-preset.js index 4732f8f037..aefcd175c9 100644 --- a/devtools/client/performance-new/test/browser/browser_webchannel-enable-menu-button-preset.js +++ b/devtools/client/performance-new/test/browser/browser_webchannel-enable-menu-button-preset.js @@ -33,7 +33,7 @@ add_task(async function test() { ); // Enable the profiler menu button with web channel. - await withWebChannelTestDocument(async browser => { + await withWebChannelTestDocument(async _browser => { await waitForTabTitle("WebChannel Page Ready"); await waitForProfilerMenuButton(); ok(true, "The profiler menu button was enabled by the WebChannel."); diff --git a/devtools/client/performance-new/test/browser/browser_webchannel-enable-menu-button.js b/devtools/client/performance-new/test/browser/browser_webchannel-enable-menu-button.js index a1864c475d..23d72225e5 100644 --- a/devtools/client/performance-new/test/browser/browser_webchannel-enable-menu-button.js +++ b/devtools/client/performance-new/test/browser/browser_webchannel-enable-menu-button.js @@ -8,7 +8,7 @@ add_task(async function test() { info("Test the WebChannel mechanism works for turning on the menu button."); await makeSureProfilerPopupIsDisabled(); - await withWebChannelTestDocument(async browser => { + await withWebChannelTestDocument(async () => { await waitForTabTitle("WebChannel Page Ready"); await waitForProfilerMenuButton(); ok(true, "The profiler menu button was enabled by the WebChannel."); |