Bug 1277589 - Replaced setting dochsell to private with opening a new pb window. r=ehsan
authorJames Andreou <jandreou@mozilla.com>
Tue, 07 Jun 2016 18:56:31 -0700
changeset 301004 b92ba4dc0af5dcaa1732aa036e1ea75d8ec19717
parent 301003 d617b44be9a9b7adf4f3621f1168a52312db7e62
child 301005 79fba69d9631c22223ed9bdf3ba3eb4dc56a357b
push id19599
push usercbook@mozilla.com
push dateWed, 08 Jun 2016 10:16:21 +0000
treeherderfx-team@81f4cc3f6f4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1277589
milestone50.0a1
Bug 1277589 - Replaced setting dochsell to private with opening a new pb window. r=ehsan MozReview-Commit-ID: 16y65vfxigM
dom/indexedDB/test/browser_permissionsPromptDeny.js
--- a/dom/indexedDB/test/browser_permissionsPromptDeny.js
+++ b/dom/indexedDB/test/browser_permissionsPromptDeny.js
@@ -2,30 +2,18 @@
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 const testPageURL = "http://mochi.test:8888/browser/" +
   "dom/indexedDB/test/browser_permissionsPrompt.html";
 const notificationID = "indexedDB-permissions-prompt";
 
-function setUsePrivateBrowsing(browser, val) {
-  if (!browser.isRemoteBrowser) {
-    browser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = val;
-    return;
-  }
-
-  return ContentTask.spawn(browser, val, function* (val) {
-    docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = val;
-  });
-};
-
-
-function promiseMessage(aMessage) {
-  return ContentTask.spawn(gBrowser.selectedBrowser, aMessage, function* (aMessage) {
+function promiseMessage(aMessage, browser) {
+  return ContentTask.spawn(browser.selectedBrowser, aMessage, function* (aMessage) {
     yield new Promise((resolve, reject) => {
       content.addEventListener("message", function messageListener(event) {
         content.removeEventListener("message", messageListener);
         is(event.data, aMessage, "received " + aMessage);
         if (event.data == aMessage)
           resolve();
         else
           reject();
@@ -50,51 +38,52 @@ add_task(function test1() {
   registerPopupEventHandler("popupshown", function () {
     ok(true, "prompt shown");
     triggerSecondaryCommand(this, 0);
   });
   registerPopupEventHandler("popuphidden", function () {
     ok(true, "prompt hidden");
   });
 
-  yield promiseMessage("InvalidStateError");
+  yield promiseMessage("InvalidStateError", gBrowser);
 
   is(getPermission(testPageURL, "indexedDB"),
      Components.interfaces.nsIPermissionManager.DENY_ACTION,
      "Correct permission set");
   gBrowser.removeCurrentTab();
 });
 
 add_task(function test2() {
+  info("creating private window");
+  let win = yield BrowserTestUtils.openNewBrowserWindow({ private : true });
+  
   info("creating private tab");
-  gBrowser.selectedTab = gBrowser.addTab();
-  yield setUsePrivateBrowsing(gBrowser.selectedBrowser, true);
+  win.gBrowser.selectedTab = win.gBrowser.addTab();
 
   info("loading test page: " + testPageURL);
-  gBrowser.selectedBrowser.loadURI(testPageURL);
-  yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
-
+  win.gBrowser.selectedBrowser.loadURI(testPageURL);
+  yield BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
+  
   registerPopupEventHandler("popupshowing", function () {
     ok(false, "prompt showing");
   });
   registerPopupEventHandler("popupshown", function () {
     ok(false, "prompt shown");
   });
   registerPopupEventHandler("popuphidden", function () {
     ok(false, "prompt hidden");
   });
-
-  yield promiseMessage("InvalidStateError");
+  yield promiseMessage("InvalidStateError", win.gBrowser);
 
   is(getPermission(testPageURL, "indexedDB"),
      Components.interfaces.nsIPermissionManager.DENY_ACTION,
      "Correct permission set");
   unregisterAllPopupEventHandlers();
-  yield setUsePrivateBrowsing(gBrowser.selectedBrowser, false);
-  gBrowser.removeCurrentTab();
+  win.gBrowser.removeCurrentTab();
+  win.close();
 });
 
 add_task(function test3() {
   info("creating tab");
   gBrowser.selectedTab = gBrowser.addTab();
 
   info("loading test page: " + testPageURL);
   gBrowser.selectedBrowser.loadURI(testPageURL);
@@ -105,17 +94,17 @@ add_task(function test3() {
   });
   registerPopupEventHandler("popupshown", function () {
     ok(false, "Shouldn't show a popup this time");
   });
   registerPopupEventHandler("popuphidden", function () {
     ok(false, "Shouldn't show a popup this time");
   });
 
-  yield promiseMessage("InvalidStateError");
+  yield promiseMessage("InvalidStateError", gBrowser);
 
   is(getPermission(testPageURL, "indexedDB"),
      Components.interfaces.nsIPermissionManager.DENY_ACTION,
      "Correct permission set");
   gBrowser.removeCurrentTab();
   unregisterAllPopupEventHandlers();
   removePermission(testPageURL, "indexedDB");
 });