Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add runtime.on performance warning #32222

Merged
merged 6 commits into from
Mar 14, 2024

Conversation

rebloor
Copy link
Contributor

@rebloor rebloor commented Feb 11, 2024

Description

Adds API documentation and release note for the runtime.on performance event introduced by Bug 1861445 Add new hang warning event API for WebExtensionswarning.

See mdn/browser-compat-data#22196 and mdn/browser-compat-data#22617 for browser compatibility data.

DO NOT MERGE until related BCD content is ready to merge.

@rebloor rebloor added the Content:WebExt WebExtensions docs label Feb 11, 2024
@rebloor rebloor requested a review from Rob--W February 11, 2024 16:08
@rebloor rebloor self-assigned this Feb 11, 2024
@rebloor rebloor requested review from a team as code owners February 11, 2024 16:08
@rebloor rebloor requested review from pepelsbey and removed request for a team February 11, 2024 16:08
@github-actions github-actions bot added Content:Firefox Content in the Mozilla/Firefox subtree size/m [PR only] 51-500 LoC changed labels Feb 11, 2024
Copy link
Contributor

github-actions bot commented Feb 11, 2024

Preview URLs

Flaws (3)

Note! 2 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/OnPerformanceWarningSeverity
Title: runtime.OnPerformanceWarningSeverity
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: webextensions.api.runtime.OnPerformanceWarningSeverity

URL: /en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onPerformanceWarning
Title: runtime.onPerformanceWarning
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: webextensions.api.runtime.onPerformanceWarning

URL: /en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/OnPerformanceWarningCategory
Title: runtime.OnPerformanceWarningCategory
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: webextensions.api.runtime.OnPerformanceWarningCategory
External URLs (1)

URL: /en-US/docs/Mozilla/Firefox/Releases/124
Title: Firefox 124 for developers

(comment last updated: 2024-03-14 03:00:47)


- : The function called when this event occurs. The function is passed these arguments:
- `category`
- : `string`. "content_script", the performance warning event category.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the OnPerformanceWarningCategory enum. It is also exposed as the runtime.OnPerformanceWarningCategory object. It currently reports content_script categories only, but the API by design is extensible to other kinds of warnings.

- : `string`. "content_script", the performance warning event category.
- `severity`
- : `string`. The performance warning event severity. One of "low", "medium", or "high".
- `tabId`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabId is optional.


- `listener`

- : The function called when this event occurs. The function is passed these arguments:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not passed these args but an object with the following properties.

See this example: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webNavigation/onBeforeNavigate


{{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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop this boiletplate. This API doesn't even exist in Chromium.

files/en-us/mozilla/firefox/releases/124/index.md Outdated Show resolved Hide resolved

- `category`
- : A {{WebExtAPIRef("runtime.OnPerformanceWarningCategory")}} object indicating the category of the warning.
- `severity`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rob--W Is this also an object?, e.g. OnPerformanceWarningSeverity

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rebloor If it helps, here are the entries from /toolkit/components/extensions/schemas/runtime.json:

{
  "id": "OnPerformanceWarningCategory",
  "type": "string",
  "enum": ["content_script"],
  "description": "The performance warning event category, e.g. 'content_script'."
},
{
  "id": "OnPerformanceWarningSeverity",
  "type": "string",
  "enum": ["low", "medium", "high"],
  "description": "The performance warning event severity. Will be 'high' for serious and user-visible issues."
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kzar exactly, hence the question.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's inline the potential values for now; I'll clarify with other engineers whether we really want to expose the supported values on an object. If so, then we can update the documentation to add extra articles with the enum values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I requested clarification at w3c/webextensions#456 (comment). Let's wait a week or so to allow for an answer before merging this PR.

I think that the most likely outcome is that we would retain these objects. Let's shape this patch towards that assumption since it is the least amount of work for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rob--W I see that @kzar responded to w3c/webextensions#456 (comment) - do I read that correctly that we are agreeing to document OnPerformanceWarningCategory and OnPerformanceWarningSeverity as types?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@rebloor rebloor requested a review from Rob--W March 5, 2024 03:11
- : `object`. An object with the following properties:

- `category`
- : A {{WebExtAPIRef("runtime.OnPerformanceWarningCategory")}} object indicating the category of the warning.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not an object, but a string that holds one of the enum values.


- `category`
- : A {{WebExtAPIRef("runtime.OnPerformanceWarningCategory")}} object indicating the category of the warning.
- `severity`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's inline the potential values for now; I'll clarify with other engineers whether we really want to expose the supported values on an object. If so, then we can update the documentation to add extra articles with the enum values.

@rebloor rebloor requested review from Rob--W and kzar March 13, 2024 10:15

Values of this type are strings. Possible values are:

- `"content_script"`: The performance warning originated from a content script.
Copy link

@kzar kzar Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `"content_script"`: The performance warning originated from a content script.
- `"content_script"`: The performance warning relates to a slow extension content script.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: avoid ambiguity: the event is for content scripts of the extension itself, not others.

Copy link
Member

@Rob--W Rob--W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with kzar's suggestion applied.

@rebloor rebloor merged commit 0bbf7b0 into mdn:main Mar 14, 2024
9 checks passed
@rebloor rebloor deleted the add-runtime.onPerformanceWarning branch March 14, 2024 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Firefox Content in the Mozilla/Firefox subtree Content:WebExt WebExtensions docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants