Bug 1404888 - Enable browser_webconsole_insecure_passwords_web_console_warning.js in new console frontend; r=jdescottes.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Tue, 23 Jan 2018 11:39:09 +0100
changeset 400734 3e4b0027e470dab9c4f64ecdbcc998d6dca03d89
parent 400683 6a8c0e1a251c50630b7e0777c6a269e05758d761
child 400735 e4675ca07f733508f0941588c3cb4b2678b5866d
push id33315
push userrgurzau@mozilla.com
push dateThu, 25 Jan 2018 17:00:51 +0000
treeherdermozilla-central@53c5a199232a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1404888
milestone60.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 1404888 - Enable browser_webconsole_insecure_passwords_web_console_warning.js in new console frontend; r=jdescottes. The test needed to be rewritten as we can't have the 3 warning messages at the same time (see https://hg.mozilla.org/mozilla-central/rev/084f217c4d49#l1.76 and https://hg.mozilla.org/mozilla-central/diff/817eb00ba702/toolkit/components/passwordmgr/InsecurePasswordUtils.jsm#l1.106). This wasn't picked up by the old frontend test because it is disabled. In order to test the different warning messages we open 3 different pages which log the appropriate warning. MozReview-Commit-ID: Gqa8GrMh8iR
devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_insecure_passwords_web_console_warning.js
devtools/client/webconsole/new-console-output/test/mochitest/test-bug-762593-insecure-passwords-web-console-warning.html
devtools/client/webconsole/new-console-output/test/mochitest/test-iframe-762593-insecure-form-action.html
devtools/client/webconsole/new-console-output/test/mochitest/test-iframe-762593-insecure-frame.html
devtools/client/webconsole/new-console-output/test/mochitest/test-iframe-insecure-form-action.html
devtools/client/webconsole/new-console-output/test/mochitest/test-insecure-frame.html
devtools/client/webconsole/new-console-output/test/mochitest/test-insecure-passwords-web-console-warning.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -29,17 +29,16 @@ support-files =
   test-bug-601177-log-levels.html
   test-bug-601177-log-levels.js
   test-bug-630733-response-redirect-headers.sjs
   test-bug-632275-getters.html
   test-bug-644419-log-limits.html
   test-bug-646025-console-file-location.html
   test-bug-658368-time-methods.html
   test-bug-737873-mixedcontent.html
-  test-bug-762593-insecure-passwords-web-console-warning.html
   test-bug-766001-console-log.js
   test-bug-766001-js-console-links.html
   test-bug-766001-js-errors.js
   test-bug-782653-css-errors-1.css
   test-bug-782653-css-errors-2.css
   test-bug-782653-css-errors.html
   test-bug-837351-security-errors.html
   test-bug-859170-longstring-hang.html
@@ -86,34 +85,35 @@ support-files =
   test-error.html
   test-eval-in-stackframe.html
   test-exception-stackframe.html
   test-external-script-errors.html
   test-external-script-errors.js
   test-file-location.js
   test-filter.html
   test-for-of.html
-  test-iframe-762593-insecure-form-action.html
-  test-iframe-762593-insecure-frame.html
+  test-iframe-insecure-form-action.html
   test-iframe1.html
   test-iframe2.html
   test-iframe3.html
   test-iframe-wrong-hud-iframe.html
   test-iframe-wrong-hud.html
   test-image.png
   test-ineffective-iframe-sandbox-warning-inner.html
   test-ineffective-iframe-sandbox-warning-nested1.html
   test-ineffective-iframe-sandbox-warning-nested2.html
   test-ineffective-iframe-sandbox-warning0.html
   test-ineffective-iframe-sandbox-warning1.html
   test-ineffective-iframe-sandbox-warning2.html
   test-ineffective-iframe-sandbox-warning3.html
   test-ineffective-iframe-sandbox-warning4.html
   test-ineffective-iframe-sandbox-warning5.html
+  test-insecure-frame.html
   test-insecure-passwords-about-blank-web-console-warning.html
+  test-insecure-passwords-web-console-warning.html
   test-inspect-cross-domain-objects-frame.html
   test-inspect-cross-domain-objects-top.html
   test-jsterm-dollar.html
   test-location-debugger-link-console-log.js
   test-location-debugger-link-errors.js
   test-location-debugger-link.html
   test-location-styleeditor-link-1.css
   test-location-styleeditor-link-2.css
@@ -285,18 +285,16 @@ skip-if = true #	Bug 1404382
 [browser_webconsole_iframe_wrong_hud.js]
 [browser_webconsole_ineffective_iframe_sandbox_warning.js]
 [browser_webconsole_init.js]
 [browser_webconsole_input_field_focus_on_panel_select.js]
 skip-if = true #	Bug 1405343
 [browser_webconsole_input_focus.js]
 [browser_webconsole_insecure_passwords_about_blank_web_console_warning.js]
 [browser_webconsole_insecure_passwords_web_console_warning.js]
-skip-if = true #	Bug 1404888
-# old console skip-if = true # Bug 1110500 - mouse event failure in test
 [browser_webconsole_inspect_cross_domain_object.js]
 [browser_webconsole_js_input_expansion.js]
 [browser_webconsole_jsterm.js]
 skip-if = true #	Bug 1405352
 # old console skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug timeout)
 [browser_webconsole_jsterm_copy.js]
 subsuite = clipboard
 skip-if = true #	Bug 1404831
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_insecure_passwords_web_console_warning.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_insecure_passwords_web_console_warning.js
@@ -3,61 +3,44 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
  // Tests that errors about insecure passwords are logged to the web console.
  // See Bug 762593.
 
 "use strict";
 
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
-                 "test/test-bug-762593-insecure-passwords-web-" +
-                 "console-warning.html";
-const INSECURE_PASSWORD_MSG = "Password fields present on an insecure " +
-                 "(http://) page. This is a security risk that allows user " +
-                 "login credentials to be stolen.";
-const INSECURE_FORM_ACTION_MSG = "Password fields present in a form with an " +
-                 "insecure (http://) form action. This is a security risk " +
-                 "that allows user login credentials to be stolen.";
-const INSECURE_IFRAME_MSG = "Password fields present on an insecure " +
-                 "(http://) iframe. This is a security risk that allows " +
-                 "user login credentials to be stolen.";
-const INSECURE_PASSWORDS_URI = "https://developer.mozilla.org/docs/Web/" +
-                               "Security/Insecure_passwords" + DOCS_GA_PARAMS;
-
-add_task(function* () {
-  yield loadTab(TEST_URI);
-
-  let hud = yield openConsole();
+const INSECURE_IFRAME_URI = "http://example.com/browser/devtools/client/webconsole/" +
+  "new-console-output/test/mochitest/test-insecure-passwords-web-console-warning.html";
+const INSECURE_PASSWORD_URI = "http://example.com/browser/devtools/client/webconsole/" +
+  "new-console-output/test/mochitest/test-iframe-insecure-form-action.html";
+const INSECURE_FORM_ACTION_URI = "https://example.com/browser/devtools/client/" +
+  "webconsole/new-console-output/test/mochitest/test-iframe-insecure-form-action.html";
 
-  let result = yield waitForMessages({
-    webconsole: hud,
-    messages: [
-      {
-        name: "Insecure password error displayed successfully",
-        text: INSECURE_PASSWORD_MSG,
-        category: CATEGORY_SECURITY,
-        severity: SEVERITY_WARNING
-      },
-      {
-        name: "Insecure iframe error displayed successfully",
-        text: INSECURE_IFRAME_MSG,
-        category: CATEGORY_SECURITY,
-        severity: SEVERITY_WARNING
-      },
-      {
-        name: "Insecure form action error displayed successfully",
-        text: INSECURE_FORM_ACTION_MSG,
-        category: CATEGORY_SECURITY,
-        severity: SEVERITY_WARNING
-      },
-    ],
-  });
+const STOLEN = "This is a security risk that allows user login credentials to be stolen.";
+const INSECURE_PASSWORD_MSG =
+  "Password fields present on an insecure (http://) page. " + STOLEN;
+const INSECURE_FORM_ACTION_MSG =
+  "Password fields present in a form with an insecure (http://) form action. " + STOLEN;
+const INSECURE_IFRAME_MSG =
+  "Password fields present on an insecure (http://) iframe. " + STOLEN;
+const INSECURE_PASSWORDS_URI =
+  "https://developer.mozilla.org/docs/Web/Security/Insecure_passwords" + DOCS_GA_PARAMS;
 
-  yield testClickOpenNewTab(hud, result);
+add_task(async function () {
+  await testUriWarningMessage(INSECURE_IFRAME_URI, INSECURE_IFRAME_MSG);
+  await testUriWarningMessage(INSECURE_PASSWORD_URI, INSECURE_PASSWORD_MSG);
+  await testUriWarningMessage(INSECURE_FORM_ACTION_URI, INSECURE_FORM_ACTION_MSG);
 });
 
-function testClickOpenNewTab(hud, [result]) {
-  let msg = [...result.matched][0];
-  let warningNode = msg.querySelector(".learn-more-link");
-  ok(warningNode, "learn more link");
-  return simulateMessageLinkClick(warningNode, INSECURE_PASSWORDS_URI);
+async function testUriWarningMessage(uri, warningMessage) {
+  let hud = await openNewTabAndConsole(uri);
+  let message = await waitFor(()=> findMessage(hud, warningMessage, ".message.warn"));
+  ok(message, "Warning message displayed successfully");
+  await testLearnMoreLinkClick(message, INSECURE_PASSWORDS_URI);
 }
+
+async function testLearnMoreLinkClick(message, expectedUri) {
+  let learnMoreLink = message.querySelector(".learn-more-link");
+  ok(learnMoreLink, "There is a [Learn More] link");
+  const {link} = await simulateLinkClick(learnMoreLink);
+  is(link, expectedUri, "Click on [Learn More] link navigates user to " + expectedUri);
+}
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-iframe-762593-insecure-form-action.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-iframe-insecure-form-action.html
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-iframe-762593-insecure-frame.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-insecure-frame.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-iframe-762593-insecure-frame.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-insecure-frame.html
@@ -4,12 +4,12 @@
     <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
     <!-- Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/ -->
   </head>
   <body>
     <h1>iframe 1</h1>
     <p>This frame is served with an insecure password field.</p>
     <iframe src=
-      "http://example.com/browser/devtools/client/webconsole/test/test-iframe-762593-insecure-form-action.html">
+      "http://example.com/browser/devtools/client/webconsole/new-console-output/test/mochitest/test-iframe-insecure-form-action.html">
     </iframe>
   </body>
 </html>
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-762593-insecure-passwords-web-console-warning.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-insecure-passwords-web-console-warning.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-bug-762593-insecure-passwords-web-console-warning.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-insecure-passwords-web-console-warning.html
@@ -5,12 +5,12 @@
     <title>Bug 762593 - Add warning/error Message to Web Console when the
       page includes Insecure Password fields</title>
     <!-- Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/ -->
   </head>
   <body>
     <p>This page is served with an iframe with insecure password field.</p>
     <iframe src
-      ="http://example.com/browser/devtools/client/webconsole/test/test-iframe-762593-insecure-frame.html">
+      ="http://example.com/browser/devtools/client/webconsole/new-console-output/test/mochitest/test-insecure-frame.html">
     </iframe>
   </body>
 </html>