Bug 1453260 - run test script in specific page only r=aswan
authorRob Wu <rob@robwu.nl>
Wed, 11 Apr 2018 14:25:03 +0200
changeset 412908 22ebb890e8ede5d3b87c2e600bbd01c2fa9281b0
parent 412907 67c06be1e14731b5f9983fa264cb68141f8a60df
child 412909 141144c1794db439f6fb39dfaaeab08d23855e63
push id62526
push userrob@robwu.nl
push dateThu, 12 Apr 2018 02:24:21 +0000
treeherderautoland@22ebb890e8ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1453260
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1453260 - run test script in specific page only r=aswan Use a more specific entry point for the test than "http://mochitest.test:8888" to make sure that the test is only started once, when the test opens a tab with the entry point. MozReview-Commit-ID: 7iAFREDuACu
browser/components/extensions/test/browser/browser_ext_connect_and_move_tabs.js
--- a/browser/components/extensions/test/browser/browser_ext_connect_and_move_tabs.js
+++ b/browser/components/extensions/test/browser/browser_ext_connect_and_move_tabs.js
@@ -6,27 +6,27 @@
 // prematurely disconnected as the underlying message managers change when a
 // tab is moved between windows.
 
 function loadExtension() {
   return ExtensionTestUtils.loadExtension({
     manifest: {
       "content_scripts": [{
         "js": ["script.js"],
-        "matches": ["http://mochi.test/"],
+        "matches": ["http://mochi.test/?discoTest"],
       }],
     },
     background() {
       browser.runtime.onConnect.addListener((port) => {
         port.onDisconnect.addListener(() => {
           browser.test.fail("onDisconnect should not fire because the port is to be closed from this side");
           browser.test.sendMessage("port_disconnected");
         });
         port.onMessage.addListener(async msg => {
-          browser.test.assertEq("connect_from_contentscript", msg, "expected message");
+          browser.test.assertEq("connect_from_script", msg, "expected message");
           // Move a tab to a new window and back. Regression test for bugzil.la/1448674
           let {windowId, id: tabId, index} = port.sender.tab;
           await browser.windows.create({tabId});
           await browser.tabs.move(tabId, {index, windowId});
           await browser.windows.create({tabId});
           await browser.tabs.move(tabId, {index, windowId});
           try {
             // When the port is unexpectedly disconnected, postMessage will throw an error.
@@ -60,26 +60,26 @@ function loadExtension() {
         port.onMessage.addListener(msg => {
           browser.test.assertEq("ping", msg, "expected message");
           browser.test.sendMessage("port_ping_ponged_before_disconnect");
           port.onDisconnect.addListener(() => {
             browser.test.sendMessage("port_disconnected");
           });
           browser.runtime.sendMessage("disconnect-me");
         });
-        port.postMessage("connect_from_contentscript");
+        port.postMessage("connect_from_script");
       },
     },
   });
 }
 
 add_task(async function contentscript_connect_and_move_tabs() {
   let extension = loadExtension();
   await extension.startup();
-  await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/");
+  await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/?discoTest");
   await extension.awaitMessage("port_ping_ponged_before_disconnect");
   await extension.awaitMessage("port_disconnected");
   // Must use gBrowser.selectedTab instead of the return value of
   // BrowserTestUtils.openNewForegroundTab because the latter does not refer to
   // the tab because the tab is moved between windows during the test.
   await BrowserTestUtils.removeTab(gBrowser.selectedTab);
   await extension.unload();
 });