Skip to content

Commit

Permalink
InjectionResult.error is not supported by Chrome (mdn#25624)
Browse files Browse the repository at this point in the history
* InjectionResult.error is not supported by Chrome

Clarify `scripting.executeScript()` (WebExtensions) error handling in Chrome that differs from Firefox.

* Reference a Chromium issue for scripting.InjectionResult.error

Co-authored-by: Rob Wu <[email protected]>

---------

Co-authored-by: Rob Wu <[email protected]>
  • Loading branch information
maxnikulin and Rob--W authored Mar 29, 2023
1 parent 5be5b68 commit 33a8d9c
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Each `InjectionResult` object has these properties:
- `error` {{optional_inline}}
- : `any`. If an error occurs, contains the value the script threw or rejected with. Typically this is an error object with a message property but it could be any value (including primitives and undefined).

Chrome does not support the `error` property yet (see [Issue 1271527: Propagate errors from scripting.executeScript to InjectionResult](https://crbug.com/1271527)). As an alternative, runtime errors can be caught by wrapping the code to execute in a try-catch statement. Uncaught errors are also reported to the console of the target tab.

The result of the script is the last evaluated statement, which is similar to the results seen if you executed the script in the [Web Console](https://firefox-source-docs.mozilla.org/devtools-user/web_console/index.html) (not any `console.log()` output). For example, consider a script like this:

```js
Expand Down

0 comments on commit 33a8d9c

Please sign in to comment.