Bug 1493426 - Respect tab privateness when opening browserAction popup. r=rpl
authorOriol Brufau <oriol-bugzilla@hotmail.com>
Tue, 16 Oct 2018 14:04:43 +0000
changeset 499990 973fdd5f75cd556436d7fa5b0ebc8a0629c78cff
parent 499989 96a0fd705c2abbdd5e7905362bf7bac74f0db8ee
child 500028 12a1714386d4428690a48ac0d0856fee1aa9f31e
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrpl
bugs1493426
milestone64.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 1493426 - Respect tab privateness when opening browserAction popup. r=rpl Differential Revision: https://phabricator.services.mozilla.com/D8628
mobile/android/components/extensions/ext-utils.js
mobile/android/components/extensions/test/mochitest/test_ext_popup_behavior.html
--- a/mobile/android/components/extensions/ext-utils.js
+++ b/mobile/android/components/extensions/ext-utils.js
@@ -294,19 +294,22 @@ class TabTracker extends TabTrackerBase 
     }
 
     if (this.extensionPopupTab) {
       win.BrowserApp.closeTab(this.extensionPopupTab);
     }
 
     this.init();
 
+    let {browser, id} = win.BrowserApp.selectedTab;
+    let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(browser);
     this._extensionPopupTabWeak = Cu.getWeakReference(win.BrowserApp.addTab(popup, {
       selected: true,
-      parentId: win.BrowserApp.selectedTab.id,
+      parentId: id,
+      isPrivate,
     }));
   }
 
   getId(nativeTab) {
     return nativeTab.id;
   }
 
   getTab(id, default_ = undefined) {
--- a/mobile/android/components/extensions/test/mochitest/test_ext_popup_behavior.html
+++ b/mobile/android/components/extensions/test/mochitest/test_ext_popup_behavior.html
@@ -169,12 +169,57 @@ add_task(async function test_popup_behav
     closeTabAndWaitTabClosed({BrowserApp, tab: tab1}),
     closeTabAndWaitTabClosed({BrowserApp, tab: tab2}),
     closeTabAndWaitTabClosed({BrowserApp, tab: tab3}),
   ]);
 
   await extension.unload();
 });
 
+add_task(async function test_popup_incognito() {
+  const chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
+  const BrowserApp = chromeWin.BrowserApp;
+  const extension = ExtensionTestUtils.loadExtension({
+    background() {
+      browser.tabs.onCreated.addListener(async (tab) => {
+        browser.test.sendMessage("page-loaded", tab);
+      });
+    },
+    manifest: {
+      "name": "BrowserAction Extension",
+      "browser_action": {
+        "default_popup": "popup.html",
+      },
+    },
+    files: {
+      "popup.html": "<h1>Extension Popup</h1>",
+    },
+  });
+
+  await extension.startup();
+  const uuid = `{${extension.uuid}}`;
+  ok(BrowserActions.isShown(uuid), "Browser action should be shown");
+
+  for (let isPrivate of [false, true]) {
+    // Open tab with provided privateness
+    let nativeTab = BrowserApp.addTab("http://example.com/#normal", {
+      isPrivate,
+      selected: true,
+    });
+    let tab = await extension.awaitMessage("page-loaded");
+    is(tab.incognito, isPrivate, "Tab should have expected privateness");
+
+    // Open browserAction popup in that tab
+    BrowserActions.synthesizeClick(uuid);
+    let popup = await extension.awaitMessage("page-loaded");
+    is(popup.incognito, isPrivate, "Popup should have same privateness as tab");
+
+    // Close popup and tab
+    await closeTabAndWaitTabClosed({BrowserApp, tab: BrowserApp.selectedTab});
+    await closeTabAndWaitTabClosed({BrowserApp, tab: nativeTab});
+  }
+
+  await extension.unload();
+});
 </script>
 
 </body>
 </html>