|
1 /* vim:set ts=2 sw=2 sts=2 et: */ |
|
2 /* ***** BEGIN LICENSE BLOCK ***** |
|
3 * Any copyright is dedicated to the Public Domain. |
|
4 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
5 * |
|
6 * ***** END LICENSE BLOCK ***** */ |
|
7 |
|
8 // Tests that the Web Console CSP messages are displayed |
|
9 |
|
10 const TEST_VIOLATION = "https://example.com/browser/browser/devtools/webconsole/test/test_bug_770099_violation.html"; |
|
11 const CSP_VIOLATION_MSG = 'Content Security Policy: The page\'s settings blocked the loading of a resource at http://some.example.com/test.png ("default-src https://example.com:443").' |
|
12 |
|
13 let hud = undefined; |
|
14 |
|
15 function test() { |
|
16 addTab("data:text/html;charset=utf8,Web Console CSP violation test"); |
|
17 browser.addEventListener("load", function _onLoad() { |
|
18 browser.removeEventListener("load", _onLoad, true); |
|
19 openConsole(null, loadDocument); |
|
20 }, true); |
|
21 } |
|
22 |
|
23 function loadDocument(theHud){ |
|
24 hud = theHud; |
|
25 hud.jsterm.clearOutput() |
|
26 browser.addEventListener("load", onLoad, true); |
|
27 content.location = TEST_VIOLATION; |
|
28 } |
|
29 |
|
30 function onLoad(aEvent) { |
|
31 browser.removeEventListener("load", onLoad, true); |
|
32 testViolationMessage(); |
|
33 } |
|
34 |
|
35 function testViolationMessage(){ |
|
36 let aOutputNode = hud.outputNode; |
|
37 |
|
38 waitForSuccess({ |
|
39 name: "CSP policy URI warning displayed successfully", |
|
40 validatorFn: function() { |
|
41 return hud.outputNode.textContent.indexOf(CSP_VIOLATION_MSG) > -1; |
|
42 }, |
|
43 successFn: finishTest, |
|
44 failureFn: finishTest, |
|
45 }); |
|
46 } |