Bug 1407178 - Enable browser_webconsole_certificate_messages.js in the new console; r=Honza.
☠☠ backed out by a97a53dfbaeb ☠ ☠
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Tue, 10 Oct 2017 11:04:57 +0200
changeset 679098 2f3dd84d4d228a6a52f47164eabd1298ed26ebe9
parent 679097 8b3c3e27958867ff0135adf75be4e8daf4a7d745
child 679099 44335b8d480b841dd85b54ac22fd9de835f3c0be
push id84141
push userbmo:schien@mozilla.com
push dateThu, 12 Oct 2017 11:13:04 +0000
reviewersHonza
bugs1407178
milestone58.0a1
Bug 1407178 - Enable browser_webconsole_certificate_messages.js in the new console; r=Honza. MozReview-Commit-ID: GHSJAnkj6Pv
devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_certificate_messages.js
devtools/client/webconsole/new-console-output/test/mochitest/head.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -247,18 +247,16 @@ skip-if = true #	Bug 1403899
 # old console skip-if = (os == 'win' && bits == 64) # Bug 1390001
 [browser_webconsole_cached_autocomplete.js]
 skip-if = true # Bug 1401881
 [browser_webconsole_cached_messages.js]
 skip-if = true #	Bug 1406069
 [browser_webconsole_cd_iframe.js]
 skip-if = true #	Bug 1406030
 [browser_webconsole_certificate_messages.js]
-skip-if = true # Bug 1401881
-# old console skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
 [browser_webconsole_charset.js]
 skip-if = true #	Bug 1404400
 [browser_webconsole_chrome.js]
 skip-if = true # Bug 1401881
 [browser_webconsole_click_function_to_source.js]
 skip-if = true #	Bug 1406038
 [browser_webconsole_clickable_urls.js]
 [browser_webconsole_closing_after_completion.js]
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_certificate_messages.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_certificate_messages.js
@@ -2,80 +2,47 @@
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests that the Web Console shows weak crypto warnings (SHA-1 Certificate)
 
 "use strict";
 
-const TEST_URI = "data:text/html;charset=utf8,Web Console weak crypto " +
-                 "warnings test";
-const TEST_URI_PATH = "/browser/devtools/client/webconsole/test/" +
-                      "test-certificate-messages.html";
+const TEST_URI = "data:text/html;charset=utf8,Web Console weak crypto warnings test";
+const TEST_URI_PATH = "/browser/devtools/client/webconsole/new-console-output/test/" +
+                      "mochitest/test-certificate-messages.html";
 
-var gWebconsoleTests = [
-  {url: "https://sha1ee.example.com" + TEST_URI_PATH,
-   name: "SHA1 warning displayed successfully",
-   warning: ["SHA-1"], nowarning: ["SSL 3.0", "RC4"]},
-  {url: "https://sha256ee.example.com" + TEST_URI_PATH,
-   name: "SSL warnings appropriately not present",
-   warning: [], nowarning: ["SHA-1", "SSL 3.0", "RC4"]},
-];
+var tests = [{
+  url: "https://sha1ee.example.com" + TEST_URI_PATH,
+  name: "SHA1 warning displayed successfully",
+  warning: ["SHA-1"],
+  nowarning: ["SSL 3.0", "RC4"]
+}, {
+  url: "https://sha256ee.example.com" + TEST_URI_PATH,
+  name: "SSL warnings appropriately not present",
+  warning: [],
+  nowarning: ["SHA-1", "SSL 3.0", "RC4"]
+}];
 const TRIGGER_MSG = "If you haven't seen ssl warnings yet, you won't";
 
-var gHud = undefined, gContentBrowser;
-var gCurrentTest;
-
-function test() {
-  registerCleanupFunction(function () {
-    gHud = gContentBrowser = null;
-  });
-
-  loadTab(TEST_URI).then(({browser}) => {
-    gContentBrowser = browser;
-    openConsole().then(runTestLoop);
-  });
-}
+add_task(async function () {
+  const hud = await openNewTabAndConsole(TEST_URI);
+  for (let test of tests) {
+    await runTest(test, hud);
+  }
+});
 
-function runTestLoop(theHud) {
-  gCurrentTest = gWebconsoleTests.shift();
-  if (!gCurrentTest) {
-    finishTest();
-    return;
-  }
-  if (!gHud) {
-    gHud = theHud;
+async function runTest(test, hud) {
+  info(`Testing ${test.name}`);
+  await loadDocument(test.url);
+  await waitFor(() => findMessage(hud, TRIGGER_MSG));
+
+  for (let warning of test.warning) {
+    ok(hud.outputNode.textContent.indexOf(warning) >= 0,
+      `There is a warning message for ${warning}`);
   }
-  gHud.jsterm.clearOutput();
-  gContentBrowser.addEventListener("load", onLoad, true);
-  if (gCurrentTest.pref) {
-    SpecialPowers.pushPrefEnv({"set": gCurrentTest.pref},
-      function () {
-        BrowserTestUtils.loadURI(gBrowser.selectedBrowser, gCurrentTest.url);
-      });
-  } else {
-    BrowserTestUtils.loadURI(gBrowser.selectedBrowser, gCurrentTest.url);
+
+  for (let nowarning of test.nowarning) {
+    ok(hud.outputNode.textContent.indexOf(nowarning) < 0,
+      `There is no warning message for ${nowarning}`);
   }
 }
-
-function onLoad() {
-  gContentBrowser.removeEventListener("load", onLoad, true);
-
-  waitForSuccess({
-    name: gCurrentTest.name,
-    validator: function () {
-      if (gHud.outputNode.textContent.indexOf(TRIGGER_MSG) >= 0) {
-        for (let warning of gCurrentTest.warning) {
-          if (gHud.outputNode.textContent.indexOf(warning) < 0) {
-            return false;
-          }
-        }
-        for (let nowarning of gCurrentTest.nowarning) {
-          if (gHud.outputNode.textContent.indexOf(nowarning) >= 0) {
-            return false;
-          }
-        }
-        return true;
-      }
-    }
-  }).then(runTestLoop);
-}
--- a/devtools/client/webconsole/new-console-output/test/mochitest/head.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/head.js
@@ -180,17 +180,17 @@ function hideContextMenu(hud) {
   let onPopupHidden = once(popup, "popuphidden");
   popup.hidePopup();
   return onPopupHidden;
 }
 
 function loadDocument(url, browser = gBrowser.selectedBrowser) {
   return new Promise(resolve => {
     browser.addEventListener("load", resolve, {capture: true, once: true});
-    BrowserTestUtils.loadURI(gBrowser.selectedBrowser, url);
+    BrowserTestUtils.loadURI(browser, url);
   });
 }
 
 /**
 * Returns a promise that resolves when the node passed as an argument mutate
 * according to the passed configuration.
 *
 * @param {Node} node - The node to observe mutations on.