-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1f442bc
Add runtime.onPerformanceWarning
rebloor b1832c7
Release note
rebloor 49d3f48
Apply suggestions from review
rebloor 670f349
Update from feedback
rebloor 31fc90e
add runtime.OnPerformanceWarningSeverity
rebloor b8bb8f2
Apply suggestions from review
rebloor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...s/en-us/mozilla/add-ons/webextensions/api/runtime/onperformancewarning/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
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 this argument: | ||
|
||
- `details` | ||
|
||
- : `object`. An object with the following properties: | ||
|
||
- `category` | ||
- : {{WebExtAPIRef("runtime.OnPerformanceWarningCategory")}}. The category of the warning. | ||
- `severity` | ||
- : {{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` | ||
- : `string`. An explanation of what the warning means, possibly with information on how to address it. | ||
|
||
## Examples | ||
|
||
```js | ||
function handlePerformanceWarning(details) { | ||
console.log(`Performance warning: ${details.description}`); | ||
} | ||
|
||
browser.runtime.onPerformanceWarning.addListener(handlePerformanceWarning); | ||
``` | ||
|
||
{{WebExtExamples}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
22 changes: 22 additions & 0 deletions
22
...mozilla/add-ons/webextensions/api/runtime/onperformancewarningcategory/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 is for a slow content script in the listening extension. | ||
|
||
{{WebExtExamples("h2")}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
24 changes: 24 additions & 0 deletions
24
...mozilla/add-ons/webextensions/api/runtime/onperformancewarningseverity/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
andOnPerformanceWarningSeverity
as types?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.