Closed Bug 1311128 Opened 8 years ago Closed 8 years ago

WebExtensions API: Port.onMessage listeners are not passed the port as the second argument

Categories

(WebExtensions :: Untriaged, defect)

52 Branch
x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1299411

People

(Reporter: u287251, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Build ID: 20161017030209

Steps to reproduce:

In trying to port uBlock Origin ("uBO") extension to WebExtensions, I hit this bug: the `port` argument is not being passed to listeners registered through Port.onMessage.addListener. This breaks uBO's message passing between main process and content process(es), auxiliary pages, and popup panel.

As per Chromium API regarding Port.onMessage.addListener:

> This event is fired when postMessage is called by the other end of the port.
> The first parameter is the message, the second parameter is the port that
> received the message.

Source:
https://developer.chrome.com/extensions/runtime#type-Port

Digging into WebExtensions source code, I believe this is the line where the `port` argument should be passed as the second parameter:
https://dxr.mozilla.org/mozilla-central/source/toolkit/components/extensions/ExtensionUtils.jsm#1225

Corresponding uBO's issue at GitHub:
https://github.com/gorhill/uBlock/issues/622


Actual results:

The second argument, the port, is not passed along when uBO's Port.onMessage listener is called.


Expected results:

The second argument, the port, is passed along when uBO's Port.onMessage listener is called.
OS: Unspecified → Linux
Hardware: Unspecified → x86_64
Component: Untriaged → WebExtensions: General
Product: Firefox → Toolkit
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Component: WebExtensions: General → WebExtensions: Untriaged
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.