Bug 1220748 - Enable browser_permissionsPromptDeny.js in e10s, r=felipe.
authorFlorian Quèze <florian@queze.net>
Mon, 29 Feb 2016 11:44:49 +0100
changeset 322337 008d7f4d10bf9694b2dc3bdd3568575e22cdbf6a
parent 322335 9da51cb4974e03cdd8fa45a34086fe1033abfeaf
child 322338 67ab004a728d94fc173a4a451c8c4e419555c2e9
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe
bugs1220748
milestone47.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 1220748 - Enable browser_permissionsPromptDeny.js in e10s, r=felipe.
dom/indexedDB/test/browser.ini
dom/indexedDB/test/browserHelpers.js
dom/indexedDB/test/browser_permissionsPromptDeny.js
--- a/dom/indexedDB/test/browser.ini
+++ b/dom/indexedDB/test/browser.ini
@@ -11,12 +11,11 @@ support-files =
   browser_permissionsWorker.html
   browser_permissionsWorker.js
   bug839193.js
   bug839193.xul
 
 [browser_forgetThisSite.js]
 [browser_permissionsPromptAllow.js]
 [browser_permissionsPromptDeny.js]
-skip-if = e10s # bug 1220748 - Attempts to touch content docshell to set usePrivateBrowsing.
 [browser_permissionsPromptWorker.js]
 [browser_perwindow_privateBrowsing.js]
 [browser_bug839193.js]
--- a/dom/indexedDB/test/browserHelpers.js
+++ b/dom/indexedDB/test/browserHelpers.js
@@ -3,38 +3,44 @@
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 var testGenerator = testSteps();
 
 var testResult;
 var testException;
 
-function testFinishedCallback(result, exception)
-{
-  throw new Error("Bad testFinishedCallback!");
-}
-
 function runTest()
 {
   testGenerator.next();
 }
 
 function finishTestNow()
 {
   if (testGenerator) {
     testGenerator.close();
     testGenerator = undefined;
   }
 }
 
 function finishTest()
 {
   setTimeout(finishTestNow, 0);
-  setTimeout(testFinishedCallback, 0, testResult, testException);
+  setTimeout(() => {
+    if (window.testFinishedCallback)
+      window.testFinishedCallback(testResult, testException);
+    else {
+      let message;
+      if (testResult)
+        message = "ok";
+      else
+        message = testException;
+      window.parent.postMessage(message, "*");
+    }
+  }, 0);
 }
 
 function grabEventAndContinueHandler(event)
 {
   testGenerator.send(event);
 }
 
 function errorHandler(event)
--- a/dom/indexedDB/test/browser_permissionsPromptDeny.js
+++ b/dom/indexedDB/test/browser_permissionsPromptDeny.js
@@ -2,123 +2,118 @@
  * 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 test()
-{
-  waitForExplicitFinish();
-  // We want the prompt.
-  removePermission(testPageURL, "indexedDB");
-  executeSoon(test1);
+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 new Promise(function(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();
+    });
+  });
 }
 
-function test1()
-{
+add_task(function test1() {
+  removePermission(testPageURL, "indexedDB");
+
   info("creating tab");
   gBrowser.selectedTab = gBrowser.addTab();
 
-  gBrowser.selectedBrowser.addEventListener("load", function () {
-    gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
-
-    setFinishedCallback(function(result, exception) {
-      ok(!result, "No database created");
-      is(exception, "InvalidStateError", "Correct exception");
-      is(getPermission(testPageURL, "indexedDB"),
-         Components.interfaces.nsIPermissionManager.DENY_ACTION,
-         "Correct permission set");
-      gBrowser.removeCurrentTab();
-      executeSoon(test2);
-    });
+  info("loading test page: " + testPageURL);
+  gBrowser.selectedBrowser.loadURI(testPageURL);
+  yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
 
-    registerPopupEventHandler("popupshowing", function () {
-      ok(true, "prompt showing");
-    });
-    registerPopupEventHandler("popupshown", function () {
-      ok(true, "prompt shown");
-      triggerSecondaryCommand(this, 0);
-    });
-    registerPopupEventHandler("popuphidden", function () {
-      ok(true, "prompt hidden");
-    });
+  registerPopupEventHandler("popupshowing", function () {
+    ok(true, "prompt showing");
+  });
+  registerPopupEventHandler("popupshown", function () {
+    ok(true, "prompt shown");
+    triggerSecondaryCommand(this, 0);
+  });
+  registerPopupEventHandler("popuphidden", function () {
+    ok(true, "prompt hidden");
+  });
 
-  }, true);
+  yield promiseMessage("InvalidStateError");
+
+  is(getPermission(testPageURL, "indexedDB"),
+     Components.interfaces.nsIPermissionManager.DENY_ACTION,
+     "Correct permission set");
+  gBrowser.removeCurrentTab();
+});
+
+add_task(function test2() {
+  info("creating private tab");
+  gBrowser.selectedTab = gBrowser.addTab();
+  yield setUsePrivateBrowsing(gBrowser.selectedBrowser, true);
 
   info("loading test page: " + testPageURL);
-  content.location = testPageURL;
-}
-
-function test2()
-{
-  info("creating tab");
-  gBrowser.selectedTab = gBrowser.addTab();
-  gBrowser.selectedBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true;
-
-  gBrowser.selectedBrowser.addEventListener("load", function () {
-    gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
+  gBrowser.selectedBrowser.loadURI(testPageURL);
+  yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
 
-    setFinishedCallback(function(result, exception) {
-      ok(!result, "No database created");
-      is(exception, "InvalidStateError", "Correct exception");
-      is(getPermission(testPageURL, "indexedDB"),
-         Components.interfaces.nsIPermissionManager.DENY_ACTION,
-         "Correct permission set");
-      gBrowser.selectedBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = false;
-      unregisterAllPopupEventHandlers();
-      gBrowser.removeCurrentTab();
-      executeSoon(test3);
-    });
+  registerPopupEventHandler("popupshowing", function () {
+    ok(false, "prompt showing");
+  });
+  registerPopupEventHandler("popupshown", function () {
+    ok(false, "prompt shown");
+  });
+  registerPopupEventHandler("popuphidden", function () {
+    ok(false, "prompt hidden");
+  });
 
-    registerPopupEventHandler("popupshowing", function () {
-      ok(false, "prompt showing");
-    });
-    registerPopupEventHandler("popupshown", function () {
-      ok(false, "prompt shown");
-    });
-    registerPopupEventHandler("popuphidden", function () {
-      ok(false, "prompt hidden");
-    });
+  yield promiseMessage("InvalidStateError");
 
-  }, true);
+  is(getPermission(testPageURL, "indexedDB"),
+     Components.interfaces.nsIPermissionManager.DENY_ACTION,
+     "Correct permission set");
+  unregisterAllPopupEventHandlers();
+  yield setUsePrivateBrowsing(gBrowser.selectedBrowser, false);
+  gBrowser.removeCurrentTab();
+});
 
-  info("loading test page: " + testPageURL);
-  content.location = testPageURL;
-}
-
-function test3()
-{
+add_task(function test3() {
   info("creating tab");
   gBrowser.selectedTab = gBrowser.addTab();
 
-  gBrowser.selectedBrowser.addEventListener("load", function () {
-    gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
-
-    setFinishedCallback(function(result, exception) {
-      ok(!result, "No database created");
-      is(exception, "InvalidStateError", "Correct exception");
-      is(getPermission(testPageURL, "indexedDB"),
-         Components.interfaces.nsIPermissionManager.DENY_ACTION,
-         "Correct permission set");
-      gBrowser.removeCurrentTab();
-      unregisterAllPopupEventHandlers();
-      removePermission(testPageURL, "indexedDB");
-      executeSoon(finish);
-    });
+  info("loading test page: " + testPageURL);
+  gBrowser.selectedBrowser.loadURI(testPageURL);
+  yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
 
-    registerPopupEventHandler("popupshowing", function () {
-      ok(false, "Shouldn't show a popup this time");
-    });
-    registerPopupEventHandler("popupshown", function () {
-      ok(false, "Shouldn't show a popup this time");
-    });
-    registerPopupEventHandler("popuphidden", function () {
-      ok(false, "Shouldn't show a popup this time");
-    });
+  registerPopupEventHandler("popupshowing", function () {
+    ok(false, "Shouldn't show a popup this time");
+  });
+  registerPopupEventHandler("popupshown", function () {
+    ok(false, "Shouldn't show a popup this time");
+  });
+  registerPopupEventHandler("popuphidden", function () {
+    ok(false, "Shouldn't show a popup this time");
+  });
 
-  }, true);
+  yield promiseMessage("InvalidStateError");
 
-  info("loading test page: " + testPageURL);
-  content.location = testPageURL;
-}
+  is(getPermission(testPageURL, "indexedDB"),
+     Components.interfaces.nsIPermissionManager.DENY_ACTION,
+     "Correct permission set");
+  gBrowser.removeCurrentTab();
+  unregisterAllPopupEventHandlers();
+  removePermission(testPageURL, "indexedDB");
+});