Bug 1345722 - Split webNavigation onCreatedNavigationTarget tests to prevent them to fail intermittently. r=mixedpuppy a=test-only
authorLuca Greco <lgreco@mozilla.com>
Mon, 20 Mar 2017 19:38:36 +0100
changeset 395416 0c7f65b96a483ce0df39782e3687108f3023045b
parent 395415 96e523b602c200de44db9ecabbec96694c67bc41
child 395417 272b6311b65e0900b23a8dab9a91f56a0cf587c9
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy, test-only
bugs1345722
milestone54.0a2
Bug 1345722 - Split webNavigation onCreatedNavigationTarget tests to prevent them to fail intermittently. r=mixedpuppy a=test-only MozReview-Commit-ID: 9s8qgBrpAfz
browser/components/extensions/test/browser/browser-common.ini
browser/components/extensions/test/browser/browser_ext_webNavigation_onCreatedNavigationTarget.js
browser/components/extensions/test/browser/browser_ext_webNavigation_onCreatedNavigationTarget_contextmenu.js
--- a/browser/components/extensions/test/browser/browser-common.ini
+++ b/browser/components/extensions/test/browser/browser-common.ini
@@ -119,16 +119,17 @@ support-files =
 [browser_ext_tabs_zoom.js]
 [browser_ext_tabs_update_url.js]
 [browser_ext_topwindowid.js]
 [browser_ext_url_overrides_newtab.js]
 [browser_ext_webRequest.js]
 [browser_ext_webNavigation_frameId0.js]
 [browser_ext_webNavigation_getFrames.js]
 [browser_ext_webNavigation_onCreatedNavigationTarget.js]
+[browser_ext_webNavigation_onCreatedNavigationTarget_contextmenu.js]
 [browser_ext_webNavigation_onCreatedNavigationTarget_window_open.js]
 [browser_ext_webNavigation_urlbar_transitions.js]
 [browser_ext_windows.js]
 [browser_ext_windows_create.js]
 tags = fullscreen
 [browser_ext_windows_create_params.js]
 [browser_ext_windows_create_tabId.js]
 [browser_ext_windows_create_url.js]
--- a/browser/components/extensions/test/browser/browser_ext_webNavigation_onCreatedNavigationTarget.js
+++ b/browser/components/extensions/test/browser/browser_ext_webNavigation_onCreatedNavigationTarget.js
@@ -47,24 +47,16 @@ async function runTestCase({extension, o
   is(webNavMsg.sourceTabId, sourceTabId, "Got the expected sourceTabId property");
   is(webNavMsg.sourceFrameId, sourceFrameId, "Got the expected sourceFrameId property");
   is(webNavMsg.url, url, "Got the expected url property");
 
   is(completedNavMsg.tabId, createdTabId, "Got the expected webNavigation.onCompleted tabId property");
   is(completedNavMsg.url, url, "Got the expected webNavigation.onCompleted url property");
 }
 
-async function clickContextMenuItem({pageElementSelector, contextMenuItemLabel}) {
-  const contentAreaContextMenu = await openContextMenu(pageElementSelector);
-  const item = contentAreaContextMenu.getElementsByAttribute("label", contextMenuItemLabel);
-  is(item.length, 1, `found contextMenu item for "${contextMenuItemLabel}"`);
-  item[0].click();
-  await closeContextMenu();
-}
-
 add_task(function* test_on_created_navigation_target_from_mouse_click() {
   const tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, SOURCE_PAGE);
 
   const extension = ExtensionTestUtils.loadExtension({
     background,
     manifest: {
       permissions: ["webNavigation"],
     },
@@ -122,69 +114,16 @@ add_task(function* test_on_created_navig
     },
   });
 
   yield BrowserTestUtils.removeTab(tab);
 
   yield extension.unload();
 });
 
-add_task(function* test_on_created_navigation_target_from_context_menu() {
-  const tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, SOURCE_PAGE);
-
-  const extension = ExtensionTestUtils.loadExtension({
-    background,
-    manifest: {
-      permissions: ["webNavigation"],
-    },
-  });
-
-  yield extension.startup();
-
-  const expectedSourceTab = yield extension.awaitMessage("expectedSourceTab");
-
-  info("Open link in a new tab from the context menu");
-
-  yield runTestCase({
-    extension,
-    async openNavTarget() {
-      await clickContextMenuItem({
-        pageElementSelector: "#test-create-new-tab-from-context-menu",
-        contextMenuItemLabel: "Open Link in New Tab",
-      });
-    },
-    expectedWebNavProps: {
-      sourceTabId: expectedSourceTab.sourceTabId,
-      sourceFrameId: 0,
-      url: `${OPENED_PAGE}#new-tab-from-context-menu`,
-    },
-  });
-
-  info("Open link in a new window from the context menu");
-
-  yield runTestCase({
-    extension,
-    async openNavTarget() {
-      await clickContextMenuItem({
-        pageElementSelector: "#test-create-new-window-from-context-menu",
-        contextMenuItemLabel: "Open Link in New Window",
-      });
-    },
-    expectedWebNavProps: {
-      sourceTabId: expectedSourceTab.sourceTabId,
-      sourceFrameId: 0,
-      url: `${OPENED_PAGE}#new-window-from-context-menu`,
-    },
-  });
-
-  yield BrowserTestUtils.removeTab(tab);
-
-  yield extension.unload();
-});
-
 add_task(function* test_on_created_navigation_target_from_mouse_click_subframe() {
   const tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, SOURCE_PAGE);
 
   const extension = ExtensionTestUtils.loadExtension({
     background,
     manifest: {
       permissions: ["webNavigation"],
     },
@@ -251,70 +190,8 @@ add_task(function* test_on_created_navig
     },
   });
 
   yield BrowserTestUtils.removeTab(tab);
 
   yield extension.unload();
 });
 
-add_task(function* test_on_created_navigation_target_from_context_menu_subframe() {
-  const tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, SOURCE_PAGE);
-
-  const extension = ExtensionTestUtils.loadExtension({
-    background,
-    manifest: {
-      permissions: ["webNavigation"],
-    },
-  });
-
-  yield extension.startup();
-
-  const expectedSourceTab = yield extension.awaitMessage("expectedSourceTab");
-
-  info("Open a subframe link in a new tab from the context menu");
-
-  yield runTestCase({
-    extension,
-    async openNavTarget() {
-      await clickContextMenuItem({
-        pageElementSelector: function() {
-          // This code runs as a framescript in the child process and it returns the
-          // target link in the subframe.
-          return this.content.frames[0] // eslint-disable-line mozilla/no-cpows-in-tests
-            .document.querySelector("#test-create-new-tab-from-context-menu-subframe");
-        },
-        contextMenuItemLabel: "Open Link in New Tab",
-      });
-    },
-    expectedWebNavProps: {
-      sourceTabId: expectedSourceTab.sourceTabId,
-      sourceFrameId: expectedSourceTab.sourceTabFrames[1].frameId,
-      url: `${OPENED_PAGE}#new-tab-from-context-menu-subframe`,
-    },
-  });
-
-  info("Open a subframe link in a new window from the context menu");
-
-  yield runTestCase({
-    extension,
-    async openNavTarget() {
-      await clickContextMenuItem({
-        pageElementSelector: function() {
-          // This code runs as a framescript in the child process and it returns the
-          // target link in the subframe.
-          return this.content.frames[0] // eslint-disable-line mozilla/no-cpows-in-tests
-            .document.querySelector("#test-create-new-window-from-context-menu-subframe");
-        },
-        contextMenuItemLabel: "Open Link in New Window",
-      });
-    },
-    expectedWebNavProps: {
-      sourceTabId: expectedSourceTab.sourceTabId,
-      sourceFrameId: expectedSourceTab.sourceTabFrames[1].frameId,
-      url: `${OPENED_PAGE}#new-window-from-context-menu-subframe`,
-    },
-  });
-
-  yield BrowserTestUtils.removeTab(tab);
-
-  yield extension.unload();
-});
copy from browser/components/extensions/test/browser/browser_ext_webNavigation_onCreatedNavigationTarget.js
copy to browser/components/extensions/test/browser/browser_ext_webNavigation_onCreatedNavigationTarget_contextmenu.js
--- a/browser/components/extensions/test/browser/browser_ext_webNavigation_onCreatedNavigationTarget.js
+++ b/browser/components/extensions/test/browser/browser_ext_webNavigation_onCreatedNavigationTarget_contextmenu.js
@@ -55,83 +55,16 @@ async function runTestCase({extension, o
 async function clickContextMenuItem({pageElementSelector, contextMenuItemLabel}) {
   const contentAreaContextMenu = await openContextMenu(pageElementSelector);
   const item = contentAreaContextMenu.getElementsByAttribute("label", contextMenuItemLabel);
   is(item.length, 1, `found contextMenu item for "${contextMenuItemLabel}"`);
   item[0].click();
   await closeContextMenu();
 }
 
-add_task(function* test_on_created_navigation_target_from_mouse_click() {
-  const tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, SOURCE_PAGE);
-
-  const extension = ExtensionTestUtils.loadExtension({
-    background,
-    manifest: {
-      permissions: ["webNavigation"],
-    },
-  });
-
-  yield extension.startup();
-
-  const expectedSourceTab = yield extension.awaitMessage("expectedSourceTab");
-
-  info("Open link in a new tab using Ctrl-click");
-
-  yield runTestCase({
-    extension,
-    openNavTarget() {
-      BrowserTestUtils.synthesizeMouseAtCenter("#test-create-new-tab-from-mouse-click",
-                                               {ctrlKey: true, metaKey: true},
-                                               tab.linkedBrowser);
-    },
-    expectedWebNavProps: {
-      sourceTabId: expectedSourceTab.sourceTabId,
-      sourceFrameId: 0,
-      url: `${OPENED_PAGE}#new-tab-from-mouse-click`,
-    },
-  });
-
-  info("Open link in a new window using Shift-click");
-
-  yield runTestCase({
-    extension,
-    openNavTarget() {
-      BrowserTestUtils.synthesizeMouseAtCenter("#test-create-new-window-from-mouse-click",
-                                               {shiftKey: true},
-                                               tab.linkedBrowser);
-    },
-    expectedWebNavProps: {
-      sourceTabId: expectedSourceTab.sourceTabId,
-      sourceFrameId: 0,
-      url: `${OPENED_PAGE}#new-window-from-mouse-click`,
-    },
-  });
-
-  info("Open link with target=\"_blank\" in a new tab using click");
-
-  yield runTestCase({
-    extension,
-    openNavTarget() {
-      BrowserTestUtils.synthesizeMouseAtCenter("#test-create-new-tab-from-targetblank-click",
-                                               {},
-                                               tab.linkedBrowser);
-    },
-    expectedWebNavProps: {
-      sourceTabId: expectedSourceTab.sourceTabId,
-      sourceFrameId: 0,
-      url: `${OPENED_PAGE}#new-tab-from-targetblank-click`,
-    },
-  });
-
-  yield BrowserTestUtils.removeTab(tab);
-
-  yield extension.unload();
-});
-
 add_task(function* test_on_created_navigation_target_from_context_menu() {
   const tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, SOURCE_PAGE);
 
   const extension = ExtensionTestUtils.loadExtension({
     background,
     manifest: {
       permissions: ["webNavigation"],
     },
@@ -175,92 +108,16 @@ add_task(function* test_on_created_navig
     },
   });
 
   yield BrowserTestUtils.removeTab(tab);
 
   yield extension.unload();
 });
 
-add_task(function* test_on_created_navigation_target_from_mouse_click_subframe() {
-  const tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, SOURCE_PAGE);
-
-  const extension = ExtensionTestUtils.loadExtension({
-    background,
-    manifest: {
-      permissions: ["webNavigation"],
-    },
-  });
-
-  yield extension.startup();
-
-  const expectedSourceTab = yield extension.awaitMessage("expectedSourceTab");
-
-  info("Open a subframe link in a new tab using Ctrl-click");
-
-  yield runTestCase({
-    extension,
-    openNavTarget() {
-      BrowserTestUtils.synthesizeMouseAtCenter(function() {
-        // This code runs as a framescript in the child process and it returns the
-        // target link in the subframe.
-        return this.content.frames[0].document // eslint-disable-line mozilla/no-cpows-in-tests
-          .querySelector("#test-create-new-tab-from-mouse-click-subframe");
-      }, {ctrlKey: true, metaKey: true}, tab.linkedBrowser);
-    },
-    expectedWebNavProps: {
-      sourceTabId: expectedSourceTab.sourceTabId,
-      sourceFrameId: expectedSourceTab.sourceTabFrames[1].frameId,
-      url: `${OPENED_PAGE}#new-tab-from-mouse-click-subframe`,
-    },
-  });
-
-  info("Open a subframe link in a new window using Shift-click");
-
-  yield runTestCase({
-    extension,
-    openNavTarget() {
-      BrowserTestUtils.synthesizeMouseAtCenter(function() {
-        // This code runs as a framescript in the child process and it returns the
-        // target link in the subframe.
-        return this.content.frames[0].document // eslint-disable-line mozilla/no-cpows-in-tests
-                      .querySelector("#test-create-new-window-from-mouse-click-subframe");
-      }, {shiftKey: true}, tab.linkedBrowser);
-    },
-    expectedWebNavProps: {
-      sourceTabId: expectedSourceTab.sourceTabId,
-      sourceFrameId: expectedSourceTab.sourceTabFrames[1].frameId,
-      url: `${OPENED_PAGE}#new-window-from-mouse-click-subframe`,
-    },
-  });
-
-  info("Open a subframe link with target=\"_blank\" in a new tab using click");
-
-  yield runTestCase({
-    extension,
-    openNavTarget() {
-      BrowserTestUtils.synthesizeMouseAtCenter(function() {
-        // This code runs as a framescript in the child process and it returns the
-        // target link in the subframe.
-        return this.content.frames[0].document // eslint-disable-line mozilla/no-cpows-in-tests
-          .querySelector("#test-create-new-tab-from-targetblank-click-subframe");
-      }, {}, tab.linkedBrowser);
-    },
-    expectedWebNavProps: {
-      sourceTabId: expectedSourceTab.sourceTabId,
-      sourceFrameId: expectedSourceTab.sourceTabFrames[1].frameId,
-      url: `${OPENED_PAGE}#new-tab-from-targetblank-click-subframe`,
-    },
-  });
-
-  yield BrowserTestUtils.removeTab(tab);
-
-  yield extension.unload();
-});
-
 add_task(function* test_on_created_navigation_target_from_context_menu_subframe() {
   const tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, SOURCE_PAGE);
 
   const extension = ExtensionTestUtils.loadExtension({
     background,
     manifest: {
       permissions: ["webNavigation"],
     },