Bug 1407178 - Enable browser_webconsole_certificate_messages.js in the new console; r=Honza.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Wed, 08 Nov 2017 13:45:37 +0100
changeset 391505 4619d49c91f51f1d1297332991f2bfe0c51d3518
parent 391504 136ee1bdf20dc915330d37bb1511e714e9d71f20
child 391506 3dac33fd437c414381b27dcda649613e27f9a949
push id32892
push userncsoregi@mozilla.com
push dateMon, 13 Nov 2017 22:56:04 +0000
treeherdermozilla-central@3dddb19f2a07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1407178
milestone59.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 1407178 - Enable browser_webconsole_certificate_messages.js in the new console; r=Honza. MozReview-Commit-ID: HbspABuW7e4
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
@@ -229,18 +229,16 @@ skip-if = true #	Bug 1403452
 [browser_webconsole_block_mixedcontent_securityerrors.js]
 tags = mcb
 skip-if = true #	Bug 1403899
 # old console skip-if = (os == 'win' && bits == 64) # Bug 1390001
 [browser_webconsole_cached_messages.js]
 [browser_webconsole_cd_iframe.js]
 skip-if = true #	Bug 1406030
 [browser_webconsole_certificate_messages.js]
-skip-if = true # Bug 1408925
-# 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 1408926
 [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,44 @@
 /* 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"]},
-];
+const SHA1_URL = "https://sha1ee.example.com" + TEST_URI_PATH;
+const SHA256_URL = "https://sha256ee.example.com" + TEST_URI_PATH;
 const TRIGGER_MSG = "If you haven't seen ssl warnings yet, you won't";
 
-var gHud = undefined, gContentBrowser;
-var gCurrentTest;
+const cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
+  .getService(Ci.nsICacheStorageService);
+
+add_task(async function () {
+  const hud = await openNewTabAndConsole(TEST_URI);
 
-function test() {
-  registerCleanupFunction(function () {
-    gHud = gContentBrowser = null;
-  });
-
-  loadTab(TEST_URI).then(({browser}) => {
-    gContentBrowser = browser;
-    openConsole().then(runTestLoop);
-  });
-}
+  info("Test SHA1 warnings");
+  let onContentLog = waitForMessage(hud, TRIGGER_MSG);
+  let onSha1Warning = waitForMessage(hud, "SHA-1");
+  await loadDocument(SHA1_URL);
+  await Promise.all([onContentLog, onSha1Warning]);
 
-function runTestLoop(theHud) {
-  gCurrentTest = gWebconsoleTests.shift();
-  if (!gCurrentTest) {
-    finishTest();
-    return;
-  }
-  if (!gHud) {
-    gHud = theHud;
-  }
-  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);
-  }
-}
+  let {textContent} = hud.outputNode;
+  ok(!textContent.includes("SSL 3.0"), "There is no warning message for SSL 3.0");
+  ok(!textContent.includes("RC4"), "There is no warning message for RC4");
 
-function onLoad() {
-  gContentBrowser.removeEventListener("load", onLoad, true);
+  info("Test SSL warnings appropriately not present");
+  onContentLog = waitForMessage(hud, TRIGGER_MSG);
+  await loadDocument(SHA256_URL);
+  await onContentLog;
 
-  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);
-}
+  textContent = hud.outputNode.textContent;
+  ok(!textContent.includes("SHA-1"), "There is no warning message for SHA-1");
+  ok(!textContent.includes("SSL 3.0"), "There is no warning message for SSL 3.0");
+  ok(!textContent.includes("RC4"), "There is no warning message for RC4");
+
+  cache.clear();
+});
--- a/devtools/client/webconsole/new-console-output/test/mochitest/head.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/head.js
@@ -204,17 +204,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.