Bug 1252110 - Fix and enable browser_bug400731.js for e10s. r=jaws
authorDão Gottwald <dao@mozilla.com>
Mon, 29 Feb 2016 22:24:55 +0100
changeset 322362 317bf83620561efe9ef92b321ac3fc2498321f3b
parent 322361 2dc35ef10107dba0e719c458cbc6bf4a6de70835
child 322363 e3f38a0b663f2c0aeb5bef33cf7e79868d7d4853
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)
reviewersjaws
bugs1252110, 400731
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 1252110 - Fix and enable browser_bug400731.js for e10s. r=jaws
browser/components/safebrowsing/content/test/browser.ini
browser/components/safebrowsing/content/test/browser_bug400731.js
--- a/browser/components/safebrowsing/content/test/browser.ini
+++ b/browser/components/safebrowsing/content/test/browser.ini
@@ -1,10 +1,9 @@
 [DEFAULT]
 support-files = head.js
 
 [browser_forbidden.js]
 [browser_bug400731.js]
-skip-if = e10s
 [browser_bug415846.js]
 skip-if = os == "mac" || e10s
 # Disabled on Mac because of its bizarre special-and-unique
 # snowflake of a help menu.
--- a/browser/components/safebrowsing/content/test/browser_bug400731.js
+++ b/browser/components/safebrowsing/content/test/browser_bug400731.js
@@ -1,77 +1,58 @@
-/* Check for the intended visibility of the "Ignore this warning" text*/
+/* Check presence of the "Ignore this warning" button */
+
+function onDOMContentLoaded(callback) {
+  function complete({ data }) {
+    mm.removeMessageListener("Test:DOMContentLoaded", complete);
+    callback(data);
+  }
+
+  let mm = gBrowser.selectedBrowser.messageManager;
+  mm.addMessageListener("Test:DOMContentLoaded", complete);
+
+  function contentScript() {
+    let listener = function () {
+      removeEventListener("DOMContentLoaded", listener);
+
+      let button = content.document.getElementById("ignoreWarningButton");
+
+      sendAsyncMessage("Test:DOMContentLoaded", { buttonPresent: !!button });
+    };
+    addEventListener("DOMContentLoaded", listener);
+  }
+  mm.loadFrameScript("data:,(" + contentScript.toString() + ")();", true);
+}
 
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
-
-  // Navigate to malware site.  Can't use an onload listener here since
-  // error pages don't fire onload.  Also can't register the DOMContentLoaded
-  // handler here because registering it too soon would mean that we might
-  // get it for about:blank, and not about:blocked.
-  gBrowser.addTabsProgressListener({
-    onLocationChange: function(aTab, aWebProgress, aRequest, aLocation, aFlags) {
-      if (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) {
-        gBrowser.removeTabsProgressListener(this);
-        window.addEventListener("DOMContentLoaded", testMalware, true);
-      }
-    }
-  });
-  content.location = "http://www.itisatrap.org/firefox/its-an-attack.html";
+  gBrowser.selectedTab = gBrowser.addTab("http://www.itisatrap.org/firefox/its-an-attack.html");
+  onDOMContentLoaded(testMalware);
 }
 
-function testMalware(event) {
-  if (event.target != gBrowser.selectedBrowser.contentDocument) {
-    return;
-  }
-
-  window.removeEventListener("DOMContentLoaded", testMalware, true);
-
-  // Confirm that "Ignore this warning" is visible - bug 422410
-  var el = content.document.getElementById("ignoreWarningButton");
-  ok(el, "Ignore warning button should be present for malware");
-
-  var style = content.getComputedStyle(el, null);
-  is(style.display, "inline-block", "Ignore Warning button should be display:inline-block for malware");
+function testMalware(data) {
+  ok(data.buttonPresent, "Ignore warning button should be present for malware");
 
   Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", false);
 
   // Now launch the unwanted software test
-  window.addEventListener("DOMContentLoaded", testUnwanted, true);
-  content.location = "http://www.itisatrap.org/firefox/unwanted.html";
+  onDOMContentLoaded(testUnwanted);
+  gBrowser.loadURI("http://www.itisatrap.org/firefox/unwanted.html");
 }
 
-function testUnwanted(event) {
-  if (event.target != gBrowser.selectedBrowser.contentDocument) {
-    return;
-  }
-
-  window.removeEventListener("DOMContentLoaded", testUnwanted, true);
-
+function testUnwanted(data) {
   // Confirm that "Ignore this warning" is visible - bug 422410
-  var el = content.document.getElementById("ignoreWarningButton");
-  ok(!el, "Ignore warning button should be missing for unwanted software");
+  ok(!data.buttonPresent, "Ignore warning button should be missing for unwanted software");
 
   Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", true);
 
   // Now launch the phishing test
-  window.addEventListener("DOMContentLoaded", testPhishing, true);
-  content.location = "http://www.itisatrap.org/firefox/its-a-trap.html";
+  onDOMContentLoaded(testPhishing);
+  gBrowser.loadURI("http://www.itisatrap.org/firefox/its-a-trap.html");
 }
 
-function testPhishing(event) {
-  if (event.target != gBrowser.selectedBrowser.contentDocument) {
-    return;
-  }
-
-  window.removeEventListener("DOMContentLoaded", testPhishing, true);
-
-  var el = content.document.getElementById("ignoreWarningButton");
-  ok(el, "Ignore warning button should be present for phishing");
-
-  var style = content.getComputedStyle(el, null);
-  is(style.display, "inline-block", "Ignore Warning button should be display:inline-block for phishing");
+function testPhishing(data) {
+  ok(data.buttonPresent, "Ignore warning button should be present for phishing");
 
   gBrowser.removeCurrentTab();
   finish();
 }