summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_webconsole_csp_ignore_reflected_xss_message.js
blob: 03da6d5d4f22a194c6bd23720e4227a791635408 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Tests that a file with an unsupported CSP directive ('reflected-xss filter')
// displays the appropriate message to the console. See Bug 1045902.

"use strict";

const EXPECTED_RESULT =
  "Not supporting directive \u2018reflected-xss\u2019. " +
  "Directive and values will be ignored.";
const TEST_FILE =
  "http://example.com/browser/devtools/client/webconsole/" +
  "test/browser/test_console_csp_ignore_reflected_xss_message.html";

const TEST_URI =
  "data:text/html;charset=utf8,<!DOCTYPE html>Web Console CSP ignoring reflected XSS (bug 1045902)";

add_task(async function () {
  const hud = await openNewTabAndConsole(TEST_URI);
  await navigateTo(TEST_FILE);

  await checkUniqueMessageExists(hud, EXPECTED_RESULT, ".warn");
  ok(
    true,
    `CSP logs displayed in console when using "reflected-xss" directive`
  );

  info("Reload page and check that the CSP warning is not duplicated");
  await reloadBrowser();
  await checkUniqueMessageExists(hud, EXPECTED_RESULT, ".warn");

  Services.cache2.clear();
});