michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* ***** BEGIN LICENSE BLOCK ***** michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: * michael@0: * ***** END LICENSE BLOCK ***** */ michael@0: michael@0: // Tests that the Web Console CSP messages are displayed michael@0: michael@0: const TEST_VIOLATION = "https://example.com/browser/browser/devtools/webconsole/test/test_bug_770099_violation.html"; michael@0: 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: michael@0: let hud = undefined; michael@0: michael@0: function test() { michael@0: addTab("data:text/html;charset=utf8,Web Console CSP violation test"); michael@0: browser.addEventListener("load", function _onLoad() { michael@0: browser.removeEventListener("load", _onLoad, true); michael@0: openConsole(null, loadDocument); michael@0: }, true); michael@0: } michael@0: michael@0: function loadDocument(theHud){ michael@0: hud = theHud; michael@0: hud.jsterm.clearOutput() michael@0: browser.addEventListener("load", onLoad, true); michael@0: content.location = TEST_VIOLATION; michael@0: } michael@0: michael@0: function onLoad(aEvent) { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: testViolationMessage(); michael@0: } michael@0: michael@0: function testViolationMessage(){ michael@0: let aOutputNode = hud.outputNode; michael@0: michael@0: waitForSuccess({ michael@0: name: "CSP policy URI warning displayed successfully", michael@0: validatorFn: function() { michael@0: return hud.outputNode.textContent.indexOf(CSP_VIOLATION_MSG) > -1; michael@0: }, michael@0: successFn: finishTest, michael@0: failureFn: finishTest, michael@0: }); michael@0: }