addListener methods should return a promise

NEW
Unassigned

Status

WebExtensions
General
P3
normal
2 years ago
a day ago

People

(Reporter: robwu, Unassigned)

Tracking

51 Branch

Firefox Tracking Flags

(firefox51 affected)

Details

(Whiteboard: triaged)

(Reporter)

Description

2 years ago
Event registration with proxied APIs is asynchronous. This leads to missing events when a WebExtension API is used with other APIs that would trigger the event.

In the next example, I expect an onRemoved event, but I did not receive any, probably because window.close() uses higher-priority IPC than the WebExtensions event implementation.

var win = window.open("http://example.com");
// Wait until the window opens and then run the following:
browser.tabs.onRemoved(tabId => console.log("Removed tab" + tabId));
win.close();
(Reporter)

Comment 1

2 years ago
This test: http://searchfox.org/mozilla-central/rev/950e13cca1fda6507dc53c243295044e8eda4493/toolkit/components/extensions/test/mochitest/test_ext_tab_teardown.html#119
fails because the (extension) tab is hosted in the main process, and calling window.close()
synchronously triggers http://searchfox.org/mozilla-central/rev/950e13cca1fda6507dc53c243295044e8eda4493/browser/base/content/tabbrowser.xml#4694

... so the tab is closed before the asynchronous tabs.onRemoved.addListener event has had a chance to run.

Updated

2 years ago
Priority: -- → P3
Whiteboard: triaged
(Reporter)

Comment 2

a year ago
Bug 1343940 is another instance of this bug.
See Also: → bug 1343940
Component: WebExtensions: Untriaged → WebExtensions: General
Summary: Events in ChildAPIManager + ParentAPIManager are out of sync with non-WebExtension APIs → addListener methods should return a promise
Duplicate of this bug: 1343940

Updated

a day ago
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.