1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_770099_violation.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 1.4 +/* vim:set ts=2 sw=2 sts=2 et: */ 1.5 +/* ***** BEGIN LICENSE BLOCK ***** 1.6 + * Any copyright is dedicated to the Public Domain. 1.7 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.8 + * 1.9 + * ***** END LICENSE BLOCK ***** */ 1.10 + 1.11 +// Tests that the Web Console CSP messages are displayed 1.12 + 1.13 +const TEST_VIOLATION = "https://example.com/browser/browser/devtools/webconsole/test/test_bug_770099_violation.html"; 1.14 +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").' 1.15 + 1.16 +let hud = undefined; 1.17 + 1.18 +function test() { 1.19 + addTab("data:text/html;charset=utf8,Web Console CSP violation test"); 1.20 + browser.addEventListener("load", function _onLoad() { 1.21 + browser.removeEventListener("load", _onLoad, true); 1.22 + openConsole(null, loadDocument); 1.23 + }, true); 1.24 +} 1.25 + 1.26 +function loadDocument(theHud){ 1.27 + hud = theHud; 1.28 + hud.jsterm.clearOutput() 1.29 + browser.addEventListener("load", onLoad, true); 1.30 + content.location = TEST_VIOLATION; 1.31 +} 1.32 + 1.33 +function onLoad(aEvent) { 1.34 + browser.removeEventListener("load", onLoad, true); 1.35 + testViolationMessage(); 1.36 +} 1.37 + 1.38 +function testViolationMessage(){ 1.39 + let aOutputNode = hud.outputNode; 1.40 + 1.41 + waitForSuccess({ 1.42 + name: "CSP policy URI warning displayed successfully", 1.43 + validatorFn: function() { 1.44 + return hud.outputNode.textContent.indexOf(CSP_VIOLATION_MSG) > -1; 1.45 + }, 1.46 + successFn: finishTest, 1.47 + failureFn: finishTest, 1.48 + }); 1.49 +}