runtime.sendMessage WebExtension page incorrectly describes return value and arguments

RESOLVED INVALID

Status

Developer Documentation
Add-ons
RESOLVED INVALID
a year ago
a year ago

People

(Reporter: William Budington, Unassigned)

Tracking

Details

(Reporter)

Description

a year ago
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36

Steps to reproduce:

Tested on Firefox 53.0.2 (64-bit), Linux.

On https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/sendMessage, MDN describes a Promise being returned from the call to `runtime.sendMessage`, and three arguments to the method.  This differs from the Chrome documentation (https://developer.chrome.com/extensions/runtime#method-sendMessage) which does not specify a return value and provides a fourth argument as a `responseCallback`.

In my testing, I found that the Chrome documentation was accurate, and that `sendMessage` (at least on stable) returns `undefined`.  The fourth argument was available via the API in both `stable` and `54.0b5 (64-bit)` Linux.

Proposed solution:

If this is an error, please correct.  If this reflects a planned change in the API, please make note of this.
WebExtensions implement asynchronous functions with promises, not with callbacks. This is a system-wide incompatibility with Chrome extensions:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities#Callbacks_and_the_chrome.*_namespace

Firefox implements a shim which makes the "chrome" namespace available as well as the "browser" namespace. If you use the "chrome" namespace, you get the callback style for asynch functions.

I hope that helps!
Status: UNCONFIRMED → RESOLVED
Last Resolved: a year ago
Resolution: --- → INVALID
(Reporter)

Comment 2

a year ago
This makes sense.  Thanks for the clarification.
You need to log in before you can comment on or make changes to this bug.