Bug 1408932 - Rename and enable browser_webconsole_cspro.js in new frontend; r=Honza.
MozReview-Commit-ID: 2qSue0CIO1c
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -6,18 +6,16 @@ support-files =
code_bundle_invalidmap.js.map
code_bundle_nosource.js
code_bundle_nosource.js.map
head.js
sjs_slow-response-test-server.sjs
source-mapped.css
source-mapped.css.map
source-mapped.scss
- test_bug_1010953_cspro.html
- test_bug_1010953_cspro.html^headers^
test_bug_1247459_violation.html
test_bug_770099_violation.html
test_bug_770099_violation.html^headers^
test_console_csp_ignore_reflected_xss_message.html
test_console_csp_ignore_reflected_xss_message.html^headers^
test_hpkp-invalid-headers.sjs
test_hsts-invalid-headers.sjs
test-autocomplete-in-stackframe.html
@@ -50,19 +48,16 @@ support-files =
test-bug-595934-svg.xhtml
test-bug-595934-workers.html
test-bug-595934-workers.js
test-bug-599725-response-headers.sjs
test-bug-601177-log-levels.html
test-bug-601177-log-levels.js
test-bug-603750-websocket.html
test-bug-603750-websocket.js
- test-cd-iframe-child.html
- test-cd-iframe-parent.html
- test-console-api-iframe.html
test-bug-630733-response-redirect-headers.sjs
test-bug-632275-getters.html
test-bug-632347-iterators-generators.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-752559-ineffective-iframe-sandbox-warning-inner.html
@@ -80,16 +75,21 @@ support-files =
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
test-bug-952277-highlight-nodes-in-vview.html
+ test-cd-iframe-child.html
+ test-cd-iframe-parent.html
+ test-console-api-iframe.html
+ test-cspro.html
+ test-cspro.html^headers^
test-iframe-child.html
test-iframe-parent.html
test-certificate-messages.html
test-closure-optimized-out.html
test-closures.html
test-console-api-stackframe.html
test-console-clear.html
test-console-column.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_cspro.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_cspro.js
@@ -1,10 +1,8 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/ */
/* We are loading:
a script that is allowed by the CSP header but not by the CSPRO header
an image which is allowed by the CSPRO header but not by the CSP header.
So we expect a warning (image has been blocked) and a report
@@ -13,45 +11,34 @@ So we expect a warning (image has been b
The expected console messages in the constants CSP_VIOLATION_MSG and
CSP_REPORT_MSG are confirmed to be found in the console messages.
See Bug 1010953.
*/
"use strict";
-const TEST_URI = "data:text/html;charset=utf8,Web Console CSP report only " +
- "test (bug 1010953)";
-const TEST_VIOLATION = "http://example.com/browser/devtools/client/" +
- "webconsole/test/test_bug_1010953_cspro.html";
-const CSP_VIOLATION_MSG = "Content Security Policy: The page\u2019s settings " +
- "blocked the loading of a resource at " +
- "http://some.example.com/test.png " +
- "(\u201cimg-src http://example.com\u201d).";
-const CSP_REPORT_MSG = "Content Security Policy: The page\u2019s settings " +
- "observed the loading of a resource at " +
- "http://some.example.com/test_bug_1010953_cspro.js " +
- "(\u201cscript-src http://example.com\u201d). A CSP report is " +
- "being sent.";
-
-add_task(function* () {
- let { browser } = yield loadTab(TEST_URI);
-
- let hud = yield openConsole();
+const TEST_URI = "data:text/html;charset=utf8,Web Console CSP report only test";
+const TEST_VIOLATION = "http://example.com/browser/devtools/client/webconsole/" +
+ "new-console-output/test/mochitest/test-cspro.html";
+const CSP_VIOLATION_MSG =
+ "Content Security Policy: The page\u2019s settings blocked the loading of a resource " +
+ "at http://some.example.com/cspro.png (\u201cimg-src http://example.com\u201d).";
+const CSP_REPORT_MSG =
+ "Content Security Policy: The page\u2019s settings observed the loading of a " +
+ "resource at http://some.example.com/cspro.js " +
+ "(\u201cscript-src http://example.com\u201d). A CSP report is being sent.";
- hud.jsterm.clearOutput();
+add_task(async function () {
+ let hud = await openNewTabAndConsole(TEST_URI);
- let loaded = loadBrowser(browser);
- BrowserTestUtils.loadURI(browser, TEST_VIOLATION);
- yield loaded;
+ let onCspViolationMessage = waitForMessage(hud, CSP_VIOLATION_MSG, ".message.error");
+ let onCspReportMessage = waitForMessage(hud, CSP_REPORT_MSG, ".message.error");
- yield waitForSuccess({
- name: "Confirmed that CSP and CSP-Report-Only log different messages to " +
- "the console.",
- validator: function () {
- console.log(hud.outputNode.textContent);
- let success = false;
- success = hud.outputNode.textContent.indexOf(CSP_VIOLATION_MSG) > -1 &&
- hud.outputNode.textContent.indexOf(CSP_REPORT_MSG) > -1;
- return success;
- }
- });
+ info("Load a page with CSP warnings.");
+ loadDocument(TEST_VIOLATION);
+
+ await onCspViolationMessage;
+ await onCspReportMessage;
+ ok(true, "Confirmed that CSP and CSP-Report-Only log different messages to console");
+
+ hud.jsterm.clearOutput(true);
});
rename from devtools/client/webconsole/new-console-output/test/mochitest/test_bug_1010953_cspro.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-cspro.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test_bug_1010953_cspro.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-cspro.html
@@ -7,14 +7,14 @@ messages.</title>
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1010953">Mozilla Bug 1010953</a>
<!-- this script file allowed by the CSP header (but not by the report-only header) -->
-<script src="http://some.example.com/test_bug_1010953_cspro.js"></script>
+<script src="http://some.example.com/cspro.js"></script>
<!-- this image allowed only be the CSP report-only header. -->
-<img src="http://some.example.com/test.png">
+<img src="http://some.example.com/cspro.png">
</body>
</html>
\ No newline at end of file
rename from devtools/client/webconsole/new-console-output/test/mochitest/test_bug_1010953_cspro.html^headers^
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-cspro.html^headers^