зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1317154: Correctly support multiple concurrent listeners for the same event. r=aswan
MozReview-Commit-ID: 4OgukI6Sc6v --HG-- extra : rebase_source : 5e6935b90198ec50221f75fa1649598220dc3917
This commit is contained in:
Родитель
0e8a09df8f
Коммит
c70bd10f2d
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
[DEFAULT]
|
||||
tags = webextensions in-process-webextensions
|
||||
|
||||
|
||||
[include:mochitest-common.ini]
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for content script</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<script type="text/javascript" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
"use strict";
|
||||
|
||||
add_task(function* test_listener_proxies() {
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
useAddonManager: "temporary",
|
||||
|
||||
manifest: {
|
||||
"permissions": ["storage"],
|
||||
},
|
||||
|
||||
async background() {
|
||||
// Test that adding multiple listeners for the same event works as
|
||||
// expected.
|
||||
|
||||
let awaitChanged = () => new Promise(resolve => {
|
||||
browser.storage.onChanged.addListener(function listener() {
|
||||
browser.storage.onChanged.removeListener(listener);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
let promises = [
|
||||
awaitChanged(),
|
||||
awaitChanged(),
|
||||
];
|
||||
|
||||
function removedListener() {}
|
||||
browser.storage.onChanged.addListener(removedListener);
|
||||
browser.storage.onChanged.removeListener(removedListener);
|
||||
|
||||
promises.push(awaitChanged(), awaitChanged());
|
||||
|
||||
browser.storage.local.set({foo: "bar"});
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
browser.test.notifyPass("onchanged-listeners");
|
||||
},
|
||||
});
|
||||
|
||||
yield extension.startup();
|
||||
|
||||
yield extension.awaitFinish("onchanged-listeners");
|
||||
|
||||
yield extension.unload();
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче