From 1f442bc5297b698ed95154d4a0878dddbfbf6786 Mon Sep 17 00:00:00 2001 From: Richard Bloor Date: Mon, 12 Feb 2024 04:47:09 +1300 Subject: [PATCH 1/6] Add runtime.onPerformanceWarning --- .../webextensions/api/runtime/index.md | 2 + .../api/runtime/onperformancewarning/index.md | 91 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md diff --git a/files/en-us/mozilla/add-ons/webextensions/api/runtime/index.md b/files/en-us/mozilla/add-ons/webextensions/api/runtime/index.md index c1193e53e3aa231..09a14ffc05ad332 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/runtime/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/runtime/index.md @@ -96,6 +96,8 @@ It also provides messaging APIs enabling you to: - : Fired when a message is sent from either an extension process or a content script. - {{WebExtAPIRef("runtime.onMessageExternal")}} - : Fired when a message is sent from another extension. Cannot be used in a content script. +- {{WebExtAPIRef("runtime.onPerformanceWarning")}} + - : Fired when a runtime performance issue is detected for the extension. - {{WebExtAPIRef("runtime.onRestartRequired")}} - : Fired when the device needs to be restarted. diff --git a/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md new file mode 100644 index 000000000000000..0911b9b1395e14c --- /dev/null +++ b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md @@ -0,0 +1,91 @@ +--- +title: runtime.onPerformanceWarning +slug: Mozilla/Add-ons/WebExtensions/API/runtime/onPerformanceWarning +page-type: webextension-api-event +browser-compat: webextensions.api.runtime.onPerformanceWarning +--- + +{{AddonSidebar}} + +This event fires when a runtime performance issue is detected for the extension. Observe this event to be notified of runtime performance problems with your extension. + +## Syntax + +```js-nolint +browser.runtime.onPerformanceWarning.addListener(listener) +browser.runtime.onPerformanceWarning.removeListener(listener) +browser.runtime.onPerformanceWarning.hasListener(listener) +``` + +Events have three functions: + +- `addListener(listener)` + - : Adds a listener to this event. +- `removeListener(listener)` + - : Stop listening to this event. The `listener` argument is the listener to remove. +- `hasListener(listener)` + - : Checks whether at least one listener is registered for this event. Returns `true` if it is listening, `false` otherwise. + +## addListener syntax + +### Parameters + +- `listener` + + - : The function called when this event occurs. The function is passed these arguments: + - `category` + - : `string`. "content_script", the performance warning event category. + - `severity` + - : `string`. The performance warning event severity. One of "low", "medium", or "high". + - `tabId` + - : `integer`. The ID of the tab that the performance warning relates to, if any. + - `description` + - : `string`. An explanation of what the warning means, possibly with information on how to address it. + +## Examples + +```js +function handlePerformanceWarning(performanceWarningInfo) { + console.log(`Performance warning: ${performanceWarningInfo.description}`); +} + +browser.runtime.onPerformanceWarning.addListener(handlePerformanceWarning); +``` + +{{WebExtExamples}} + +## Browser compatibility + +{{Compat}} + +> **Note:** This API is based on Chromium's [`chrome.runtime`](https://developer.chrome.com/docs/extensions/reference/runtime/#event-onPerformanceWarning) API. This documentation is derived from [`runtime.json`](https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json) in the Chromium code. + + From b1832c799c97d6d3fa2a17e0162d15c391daa8dd Mon Sep 17 00:00:00 2001 From: Richard Bloor Date: Mon, 12 Feb 2024 05:01:59 +1300 Subject: [PATCH 2/6] Release note --- files/en-us/mozilla/firefox/releases/124/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/files/en-us/mozilla/firefox/releases/124/index.md b/files/en-us/mozilla/firefox/releases/124/index.md index b6afbbe48f70336..649b3baf77b085a 100644 --- a/files/en-us/mozilla/firefox/releases/124/index.md +++ b/files/en-us/mozilla/firefox/releases/124/index.md @@ -58,6 +58,8 @@ This article provides information about the changes in Firefox 124 that affect d ## Changes for add-on developers +- Adds the {{WebExtAPIRef("runtime.onPerformanceWarning")}} event that enables extensions to obtain information when the browser detects that the extension has a runtime performance issue ([Firefox bug 1861445](https://bugzil.la/1861445)). + ### Removals ### Other From 49d3f4818b17a8fdec0defefa7748db22233cdae Mon Sep 17 00:00:00 2001 From: rebloor Date: Tue, 5 Mar 2024 15:10:34 +1300 Subject: [PATCH 3/6] Apply suggestions from review Co-authored-by: Rob Wu --- .../webextensions/api/runtime/onperformancewarning/index.md | 4 ++-- files/en-us/mozilla/firefox/releases/124/index.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md index 0911b9b1395e14c..346e0f4ebd4a77f 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md @@ -45,8 +45,8 @@ Events have three functions: ## Examples ```js -function handlePerformanceWarning(performanceWarningInfo) { - console.log(`Performance warning: ${performanceWarningInfo.description}`); +function handlePerformanceWarning(details) { + console.log(`Performance warning: ${details.description}`); } browser.runtime.onPerformanceWarning.addListener(handlePerformanceWarning); diff --git a/files/en-us/mozilla/firefox/releases/124/index.md b/files/en-us/mozilla/firefox/releases/124/index.md index 649b3baf77b085a..c26e0b096753b0d 100644 --- a/files/en-us/mozilla/firefox/releases/124/index.md +++ b/files/en-us/mozilla/firefox/releases/124/index.md @@ -58,7 +58,7 @@ This article provides information about the changes in Firefox 124 that affect d ## Changes for add-on developers -- Adds the {{WebExtAPIRef("runtime.onPerformanceWarning")}} event that enables extensions to obtain information when the browser detects that the extension has a runtime performance issue ([Firefox bug 1861445](https://bugzil.la/1861445)). +- Adds the {{WebExtAPIRef("runtime.onPerformanceWarning")}} event that enables extensions to obtain information when the browser detects that the extension has a runtime performance issue such as a slow-running content script ([Firefox bug 1861445](https://bugzil.la/1861445)). ### Removals From 670f34952b6069704e7d3bbbc74298a24d0f0f4b Mon Sep 17 00:00:00 2001 From: Richard Bloor Date: Tue, 5 Mar 2024 16:09:23 +1300 Subject: [PATCH 4/6] Update from feedback --- .../webextensions/api/runtime/index.md | 2 + .../api/runtime/onperformancewarning/index.md | 55 +++++-------------- .../onperformancewarningcategory/index.md | 22 ++++++++ 3 files changed, 38 insertions(+), 41 deletions(-) create mode 100644 files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarningcategory/index.md diff --git a/files/en-us/mozilla/add-ons/webextensions/api/runtime/index.md b/files/en-us/mozilla/add-ons/webextensions/api/runtime/index.md index 09a14ffc05ad332..0d02b937e88c121 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/runtime/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/runtime/index.md @@ -31,6 +31,8 @@ It also provides messaging APIs enabling you to: - : Result of a call to {{WebExtAPIRef("runtime.requestUpdateCheck()")}}. - {{WebExtAPIRef("runtime.OnInstalledReason")}} - : The reason that the {{WebExtAPIRef("runtime.onInstalled")}} event is being dispatched. +- {{WebExtAPIRef("runtime.OnPerformanceWarningCategory")}} + - : The category of warning that dispatched the {{WebExtAPIRef("runtime.onPerformanceWarning")}} event. - {{WebExtAPIRef("runtime.OnRestartRequiredReason")}} - : The reason that the {{WebExtAPIRef("runtime.onRestartRequired")}} event is being dispatched. diff --git a/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md index 346e0f4ebd4a77f..f1ba3a032870364 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md @@ -32,15 +32,20 @@ Events have three functions: - `listener` - - : The function called when this event occurs. The function is passed these arguments: - - `category` - - : `string`. "content_script", the performance warning event category. - - `severity` - - : `string`. The performance warning event severity. One of "low", "medium", or "high". - - `tabId` - - : `integer`. The ID of the tab that the performance warning relates to, if any. - - `description` - - : `string`. An explanation of what the warning means, possibly with information on how to address it. + - : The function called when this event occurs. The function is passed this argument: + + - `details` + + - : `object`. An object with the following properties: + + - `category` + - : A {{WebExtAPIRef("runtime.OnPerformanceWarningCategory")}} object indicating the category of the warning. + - `severity` + - : `string`. The performance warning event severity. One of "low", "medium", or "high". + - `tabId` {{optional_inline}} + - : `integer`. The ID of the tab that the performance warning relates to, if any. + - `description` + - : `string`. An explanation of what the warning means, possibly with information on how to address it. ## Examples @@ -57,35 +62,3 @@ browser.runtime.onPerformanceWarning.addListener(handlePerformanceWarning); ## Browser compatibility {{Compat}} - -> **Note:** This API is based on Chromium's [`chrome.runtime`](https://developer.chrome.com/docs/extensions/reference/runtime/#event-onPerformanceWarning) API. This documentation is derived from [`runtime.json`](https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json) in the Chromium code. - - diff --git a/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarningcategory/index.md b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarningcategory/index.md new file mode 100644 index 000000000000000..54706b0ef13ac31 --- /dev/null +++ b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarningcategory/index.md @@ -0,0 +1,22 @@ +--- +title: runtime.OnPerformanceWarningCategory +slug: Mozilla/Add-ons/WebExtensions/API/runtime/OnPerformanceWarningCategory +page-type: webextension-api-type +browser-compat: webextensions.api.runtime.OnPerformanceWarningCategory +--- + +{{AddonSidebar}} + +The category of warning that dispatched the {{WebExtAPIRef("runtime.onPerformanceWarning")}} event. + +## Type + +Values of this type are strings. Possible values are: + +- `"content_script"`: The performance warning originated from a content script. + +{{WebExtExamples("h2")}} + +## Browser compatibility + +{{Compat}} From 31fc90ea55a9cc07c3237c805bf260335aae831d Mon Sep 17 00:00:00 2001 From: Richard Bloor Date: Wed, 13 Mar 2024 23:14:18 +1300 Subject: [PATCH 5/6] add runtime.OnPerformanceWarningSeverity --- .../webextensions/api/runtime/index.md | 2 ++ .../api/runtime/onperformancewarning/index.md | 4 ++-- .../onperformancewarningseverity/index.md | 24 +++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarningseverity/index.md diff --git a/files/en-us/mozilla/add-ons/webextensions/api/runtime/index.md b/files/en-us/mozilla/add-ons/webextensions/api/runtime/index.md index 0d02b937e88c121..0dea473d18b807b 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/runtime/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/runtime/index.md @@ -33,6 +33,8 @@ It also provides messaging APIs enabling you to: - : The reason that the {{WebExtAPIRef("runtime.onInstalled")}} event is being dispatched. - {{WebExtAPIRef("runtime.OnPerformanceWarningCategory")}} - : The category of warning that dispatched the {{WebExtAPIRef("runtime.onPerformanceWarning")}} event. +- {{WebExtAPIRef("runtime.OnPerformanceWarningSeverity")}} + - : The severity of warning that dispatched the {{WebExtAPIRef("runtime.onPerformanceWarning")}} event. - {{WebExtAPIRef("runtime.OnRestartRequiredReason")}} - : The reason that the {{WebExtAPIRef("runtime.onRestartRequired")}} event is being dispatched. diff --git a/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md index f1ba3a032870364..3a57739329f6b35 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md @@ -39,9 +39,9 @@ Events have three functions: - : `object`. An object with the following properties: - `category` - - : A {{WebExtAPIRef("runtime.OnPerformanceWarningCategory")}} object indicating the category of the warning. + - : {{WebExtAPIRef("runtime.OnPerformanceWarningCategory")}}. The category of the warning. - `severity` - - : `string`. The performance warning event severity. One of "low", "medium", or "high". + - : {{WebExtAPIRef("runtime.OnPerformanceWarningSeverity")}}. The severity of the warning. - `tabId` {{optional_inline}} - : `integer`. The ID of the tab that the performance warning relates to, if any. - `description` diff --git a/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarningseverity/index.md b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarningseverity/index.md new file mode 100644 index 000000000000000..caf9f8afb7a5418 --- /dev/null +++ b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarningseverity/index.md @@ -0,0 +1,24 @@ +--- +title: runtime.OnPerformanceWarningSeverity +slug: Mozilla/Add-ons/WebExtensions/API/runtime/OnPerformanceWarningSeverity +page-type: webextension-api-type +browser-compat: webextensions.api.runtime.OnPerformanceWarningSeverity +--- + +{{AddonSidebar}} + +The severity of warning that dispatched the {{WebExtAPIRef("runtime.onPerformanceWarning")}} event. + +## Type + +Values of this type are strings. Possible values are: + +- `"low"` +- `"medium"` +- `"high"` + +{{WebExtExamples("h2")}} + +## Browser compatibility + +{{Compat}} From b8bb8f2fe9f9937f008377733b403389145ed6bf Mon Sep 17 00:00:00 2001 From: rebloor Date: Thu, 14 Mar 2024 15:59:21 +1300 Subject: [PATCH 6/6] Apply suggestions from review --- .../api/runtime/onperformancewarningcategory/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarningcategory/index.md b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarningcategory/index.md index 54706b0ef13ac31..b74c01acdfbd761 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarningcategory/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarningcategory/index.md @@ -13,7 +13,7 @@ The category of warning that dispatched the {{WebExtAPIRef("runtime.onPerformanc Values of this type are strings. Possible values are: -- `"content_script"`: The performance warning originated from a content script. +- `"content_script"`: The performance warning is for a slow content script in the listening extension. {{WebExtExamples("h2")}}