Bug 1204575 - Test case for fix WebExtension EventManager fireFunc registering. r=billm r=gabor
This commit is contained in:
@@ -12,3 +12,4 @@ support-files =
|
||||
[browser_ext_tabs_query.js]
|
||||
[browser_ext_tabs_update.js]
|
||||
[browser_ext_windows_update.js]
|
||||
[browser_ext_contentscript_connect.js]
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
add_task(function* () {
|
||||
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/");
|
||||
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"permissions": ["tabs"]
|
||||
},
|
||||
|
||||
background: function() {
|
||||
var ports_received = 0;
|
||||
var port_messages_received = 0;
|
||||
|
||||
browser.runtime.onConnect.addListener((port) => {
|
||||
browser.test.assertTrue(!!port, "port1 received");
|
||||
|
||||
ports_received++;
|
||||
browser.test.assertEq(1, ports_received, "1 port received");
|
||||
|
||||
port.onMessage.addListener((msg, sender) => {
|
||||
browser.test.assertEq("port message", msg, "listener1 port message received");
|
||||
|
||||
port_messages_received++
|
||||
browser.test.assertEq(1, port_messages_received, "1 port message received");
|
||||
})
|
||||
});
|
||||
browser.runtime.onConnect.addListener((port) => {
|
||||
browser.test.assertTrue(!!port, "port2 received");
|
||||
|
||||
ports_received++;
|
||||
browser.test.assertEq(2, ports_received, "2 ports received");
|
||||
|
||||
port.onMessage.addListener((msg, sender) => {
|
||||
browser.test.assertEq("port message", msg, "listener2 port message received");
|
||||
|
||||
port_messages_received++
|
||||
browser.test.assertEq(2, port_messages_received, "2 port messages received");
|
||||
|
||||
browser.test.notifyPass("contentscript_connect.pass");
|
||||
});
|
||||
});
|
||||
|
||||
browser.tabs.executeScript({ file: "script.js" });
|
||||
},
|
||||
|
||||
files: {
|
||||
"script.js": function() {
|
||||
var port = browser.runtime.connect();
|
||||
port.postMessage("port message");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
yield extension.startup();
|
||||
yield extension.awaitFinish("contentscript_connect.pass");
|
||||
yield extension.unload();
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
Reference in New Issue
Block a user