From c70bd10f2dd18bc51f7578b17084f24e4b3736e0 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 18 Nov 2016 12:20:22 -0800 Subject: [PATCH] Bug 1317154: Correctly support multiple concurrent listeners for the same event. r=aswan MozReview-Commit-ID: 4OgukI6Sc6v --HG-- extra : rebase_source : 5e6935b90198ec50221f75fa1649598220dc3917 --- .../browser_ext_windows_create_tabId.js | 2 - .../components/extensions/ExtensionParent.jsm | 4 +- .../test/mochitest/mochitest-common.ini | 1 + .../extensions/test/mochitest/mochitest.ini | 1 - .../mochitest/test_ext_listener_proxies.html | 63 +++++++++++++++++++ 5 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 toolkit/components/extensions/test/mochitest/test_ext_listener_proxies.html diff --git a/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js b/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js index 6d033cd1ac48..52ffaea8b724 100644 --- a/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js +++ b/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js @@ -104,8 +104,6 @@ add_task(function* testWindowCreate() { promiseTabUpdated("http://example.org/"), ]); - await new Promise(resolve => setTimeout(resolve, 0)); - window = await browser.windows.create({url: ["http://example.com/", "http://example.org/"]}); await readyPromise; diff --git a/toolkit/components/extensions/ExtensionParent.jsm b/toolkit/components/extensions/ExtensionParent.jsm index 3df7316b7f57..37950d49ea3d 100644 --- a/toolkit/components/extensions/ExtensionParent.jsm +++ b/toolkit/components/extensions/ExtensionParent.jsm @@ -525,7 +525,7 @@ ParentAPIManager = { }); } - context.listenerProxies.set(data.path, listener); + context.listenerProxies.set(data.listenerId, listener); let args = Cu.cloneInto(data.args, context.sandbox); findPathInObject(context.apiObj, data.path).addListener(listener, ...args); @@ -533,7 +533,7 @@ ParentAPIManager = { removeListener(data) { let context = this.getContextById(data.childId); - let listener = context.listenerProxies.get(data.path); + let listener = context.listenerProxies.get(data.listenerId); findPathInObject(context.apiObj, data.path).removeListener(listener); }, diff --git a/toolkit/components/extensions/test/mochitest/mochitest-common.ini b/toolkit/components/extensions/test/mochitest/mochitest-common.ini index 523eb99b2b4e..d4cd76dd7338 100644 --- a/toolkit/components/extensions/test/mochitest/mochitest-common.ini +++ b/toolkit/components/extensions/test/mochitest/mochitest-common.ini @@ -89,6 +89,7 @@ skip-if = (os == 'android') # Android does not support tabs API. Bug 1260250 [test_ext_unload_frame.html] [test_ext_i18n.html] skip-if = (os == 'android') # Bug 1258975 on android. +[test_ext_listener_proxies.html] [test_ext_web_accessible_resources.html] skip-if = (os == 'android') # Bug 1258975 on android. [test_ext_webrequest_background_events.html] diff --git a/toolkit/components/extensions/test/mochitest/mochitest.ini b/toolkit/components/extensions/test/mochitest/mochitest.ini index d4b4073ee7ca..29a79a151ec2 100644 --- a/toolkit/components/extensions/test/mochitest/mochitest.ini +++ b/toolkit/components/extensions/test/mochitest/mochitest.ini @@ -1,5 +1,4 @@ [DEFAULT] tags = webextensions in-process-webextensions - [include:mochitest-common.ini] diff --git a/toolkit/components/extensions/test/mochitest/test_ext_listener_proxies.html b/toolkit/components/extensions/test/mochitest/test_ext_listener_proxies.html new file mode 100644 index 000000000000..ca8db873e42a --- /dev/null +++ b/toolkit/components/extensions/test/mochitest/test_ext_listener_proxies.html @@ -0,0 +1,63 @@ + + + + Test for content script + + + + + + + + + + + +