Bug 1523605 fix intermittent failure in browser_ext_sidebarAction_incognito.js r=rpl
authorShane Caraveo <scaraveo@mozilla.com>
Thu, 28 Feb 2019 13:40:58 +0000
changeset 519600 9d1e9834a326d6b9ebdef03cf4622d0482aa17a9
parent 519599 756272e36e32264332e6b95aa804b69581295c7e
child 519601 c89f5d4d2e86a66411ad91a5e7241e3242ac3d7a
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrpl
bugs1523605
milestone67.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 1523605 fix intermittent failure in browser_ext_sidebarAction_incognito.js r=rpl Sometimes about:blank would match a non-private window, ensure we're looking for a url specific to the private window. Differential Revision: https://phabricator.services.mozilla.com/D21454
browser/components/extensions/test/browser/browser_ext_sidebarAction_incognito.js
browser/components/extensions/test/browser/head.js
--- a/browser/components/extensions/test/browser/browser_ext_sidebarAction_incognito.js
+++ b/browser/components/extensions/test/browser/browser_ext_sidebarAction_incognito.js
@@ -1,62 +1,61 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
-async function testIncognito(incognitoOverride) {
+add_task(async function test_sidebarAction_not_allowed() {
   SpecialPowers.pushPrefEnv({set: [
     ["extensions.allowPrivateBrowsingByDefault", false],
   ]});
 
   let extension = ExtensionTestUtils.loadExtension({
-    incognitoOverride,
     manifest: {
       sidebar_action: {
         default_panel: "sidebar.html",
       },
     },
     background() {
       browser.test.onMessage.addListener(async pbw => {
         await browser.test.assertRejects(browser.sidebarAction.setTitle({
           windowId: pbw.windowId, title: "test",
-        }), /Invalid window ID/, "should not be able to set title");
+        }), /Invalid window ID/, "should not be able to set title with windowId");
         await browser.test.assertRejects(browser.sidebarAction.setTitle({
           tabId: pbw.tabId, title: "test",
         }), /Invalid tab ID/, "should not be able to set title");
         await browser.test.assertRejects(browser.sidebarAction.getTitle({
           windowId: pbw.windowId,
-        }), /Invalid window ID/, "should not be able to get title");
+        }), /Invalid window ID/, "should not be able to get title with windowId");
         await browser.test.assertRejects(browser.sidebarAction.getTitle({
           tabId: pbw.tabId,
-        }), /Invalid tab ID/, "should not be able to get title");
+        }), /Invalid tab ID/, "should not be able to get title with tabId");
 
         await browser.test.assertRejects(browser.sidebarAction.setIcon({
           windowId: pbw.windowId, path: "test",
-        }), /Invalid window ID/, "should not be able to set icon");
+        }), /Invalid window ID/, "should not be able to set icon with windowId");
         await browser.test.assertRejects(browser.sidebarAction.setIcon({
           tabId: pbw.tabId, path: "test",
-        }), /Invalid tab ID/, "should not be able to set icon");
+        }), /Invalid tab ID/, "should not be able to set icon with tabId");
 
         await browser.test.assertRejects(browser.sidebarAction.setPanel({
           windowId: pbw.windowId, panel: "test",
-        }), /Invalid window ID/, "should not be able to set panel");
+        }), /Invalid window ID/, "should not be able to set panel with windowId");
         await browser.test.assertRejects(browser.sidebarAction.setPanel({
           tabId: pbw.tabId, panel: "test",
-        }), /Invalid tab ID/, "should not be able to set panel");
+        }), /Invalid tab ID/, "should not be able to set panel with tabId");
         await browser.test.assertRejects(browser.sidebarAction.getPanel({
           windowId: pbw.windowId,
-        }), /Invalid window ID/, "should not be able to get panel");
+        }), /Invalid window ID/, "should not be able to get panel with windowId");
         await browser.test.assertRejects(browser.sidebarAction.getPanel({
           tabId: pbw.tabId,
-        }), /Invalid tab ID/, "should not be able to get panel");
+        }), /Invalid tab ID/, "should not be able to get panel with tabId");
 
         await browser.test.assertRejects(browser.sidebarAction.isOpen({
           windowId: pbw.windowId,
-        }), /Invalid window ID/, "should not be able to determine openness");
+        }), /Invalid window ID/, "should not be able to determine openness with windowId");
 
         browser.test.notifyPass("pass");
       });
     },
     files: {
       "sidebar.html": `
         <!DOCTYPE html>
         <html>
@@ -76,31 +75,19 @@ async function testIncognito(incognitoOv
       },
     },
   });
 
   await extension.startup();
   let sidebarID = `${makeWidgetId(extension.id)}-sidebar-action`;
   ok(SidebarUI.sidebars.has(sidebarID), "sidebar exists in non-private window");
 
-  let winData = await getIncognitoWindow("about:blank");
+  let winData = await getIncognitoWindow();
 
   let hasSidebar = winData.win.SidebarUI.sidebars.has(sidebarID);
-  if (incognitoOverride == "spanning") {
-    ok(hasSidebar, "sidebar exists in private window");
-  } else {
-    ok(!hasSidebar, "sidebar does not exist in private window");
-    // Test API access to private window data.
-    extension.sendMessage(winData.details);
-    await extension.awaitFinish("pass");
-  }
+  ok(!hasSidebar, "sidebar does not exist in private window");
+  // Test API access to private window data.
+  extension.sendMessage(winData.details);
+  await extension.awaitFinish("pass");
 
   await BrowserTestUtils.closeWindow(winData.win);
   await extension.unload();
-}
-
-add_task(async function test_sidebarAction_not_allowed() {
-  await testIncognito();
 });
-
-add_task(async function test_sidebarAction_allowed() {
-  await testIncognito("spanning");
-});
--- a/browser/components/extensions/test/browser/head.js
+++ b/browser/components/extensions/test/browser/head.js
@@ -667,17 +667,17 @@ async function startIncognitoMonitorExte
     },
     incognitoOverride: "not_allowed",
     background,
   });
   await extension.startup();
   return extension;
 }
 
-async function getIncognitoWindow(url) {
+async function getIncognitoWindow(url = "about:privatebrowsing") {
   // Since events will be limited based on incognito, we need a
   // spanning extension to get the tab id so we can test access failure.
 
   // avoid linting issue with background
   /* eslint-disable no-use-before-define */
   function background(expectUrl) {
     browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
       if (changeInfo.status === "complete" && tab.url === expectUrl) {