Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 ***** */
8 // Tests that the Web Console CSP messages are displayed
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").'
13 let hud = undefined;
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 }
23 function loadDocument(theHud){
24 hud = theHud;
25 hud.jsterm.clearOutput()
26 browser.addEventListener("load", onLoad, true);
27 content.location = TEST_VIOLATION;
28 }
30 function onLoad(aEvent) {
31 browser.removeEventListener("load", onLoad, true);
32 testViolationMessage();
33 }
35 function testViolationMessage(){
36 let aOutputNode = hud.outputNode;
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 }