blob: 76ab1b22e6f44db84c7cb884b08d50d2d9a23432 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/*
* This tests loads a page that triggers so many CSP reports that they throttled
* and a console error is logged.
*/
"use strict";
const TEST_URI =
"data:text/html;charset=utf8,<!DOCTYPE html>Web Console CSP too many reports test";
const TEST_VIOLATIONS =
"https://example.com/browser/devtools/client/webconsole/" +
"test/browser/test-csp-many-errors.html";
const bundle = Services.strings.createBundle(
"chrome://global/locale/security/csp.properties"
);
const CSP_VIOLATION_MSG = bundle.formatStringFromName(
"CSPInlineStyleViolation",
["style-src 'none'", "style-src-attr"]
);
const CSP_TOO_MANY_REPORTS_MSG = bundle.formatStringFromName(
"tooManyReports",
[]
);
add_task(async function () {
// Reduce the limit to reduce the log spam.
await SpecialPowers.pushPrefEnv({
set: [["security.csp.reporting.limit.count", 10]],
});
const hud = await openNewTabAndConsole(TEST_URI);
const onCspViolationMessage = waitForMessageByType(
hud,
CSP_VIOLATION_MSG,
".error"
).then(() => info("Got violation message."));
const onCspTooManyReportsMessage = waitForMessageByType(
hud,
CSP_TOO_MANY_REPORTS_MSG,
".error"
).then(() => info("Got too many reports message."));
info("Load a page with CSP warnings.");
await navigateTo(TEST_VIOLATIONS);
info("Waiting for console messages.");
await Promise.all([onCspViolationMessage, onCspTooManyReportsMessage]);
ok(true, "Got error about too many reports");
await clearOutput(hud);
});
|