Bug 1345722 - Split webNavigation onCreatedNavigationTarget tests to prevent them to fail intermittently. draft
authorLuca Greco <lgreco@mozilla.com>
Mon, 20 Mar 2017 19:38:36 +0100
changeset 501636 99d8c322ecd40587a6f425a25475eacdf5fd8587
parent 501569 05bfa2831c0ba4a26fa72328ffe6a99aba9c356a
child 549951 6e5e1df51995e7d72946eb992a2f2635748f3a5f
push id50062
push userluca.greco@alcacoop.it
push dateMon, 20 Mar 2017 18:41:25 +0000
bugs1345722
milestone55.0a1
Bug 1345722 - Split webNavigation onCreatedNavigationTarget tests to prevent them to fail intermittently. 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
@@ -124,16 +124,17 @@ support-files =
 [browser_ext_themes_validation.js]
 [browser_ext_topwindowid.js]
 [browser_ext_url_overrides_newtab.js]
 [browser_ext_url_overrides_home.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"],
     },