browser/devtools/webconsole/test/browser_webconsole_bug_770099_violation.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial