mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 770099 - Send CSP policy and report information to Web Console (Part 2); r=dveditz,msucan,jwalker
This commit is contained in:
parent
38b8c56de1
commit
b035e0bc43
@ -107,6 +107,8 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_webconsole_bug_658368_time_methods.js \
|
||||
browser_webconsole_bug_764572_output_open_url.js \
|
||||
browser_webconsole_bug_622303_persistent_filters.js \
|
||||
browser_webconsole_bug_770099_bad_policyuri.js \
|
||||
browser_webconsole_bug_770099_violation.js \
|
||||
browser_webconsole_window_zombie.js \
|
||||
browser_cached_messages.js \
|
||||
browser_bug664688_sandbox_update_after_navigation.js \
|
||||
@ -188,6 +190,10 @@ MOCHITEST_BROWSER_FILES += \
|
||||
test-bug-658368-time-methods.html \
|
||||
test-webconsole-error-observer.html \
|
||||
test-for-of.html \
|
||||
test_bug_770099_violation.html \
|
||||
test_bug_770099_violation.html^headers^ \
|
||||
test_bug_770099_bad_policy_uri.html \
|
||||
test_bug_770099_bad_policy_uri.html^headers^ \
|
||||
test-result-format-as-string.html \
|
||||
test-bug-737873-mixedcontent.html \
|
||||
$(NULL)
|
||||
|
@ -0,0 +1,55 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// Tests that the Web Console CSP messages are displayed
|
||||
|
||||
const TEST_BAD_POLICY_URI = "https://example.com/browser/browser/devtools/webconsole/test/test_bug_770099_bad_policy_uri.html";
|
||||
|
||||
let hud = undefined;
|
||||
|
||||
function test() {
|
||||
addTab("data:text/html;charset=utf8,Web Console CSP bad policy URI test");
|
||||
browser.addEventListener("load", function _onLoad() {
|
||||
browser.removeEventListener("load", _onLoad, true);
|
||||
openConsole(null, loadDocument);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function loadDocument(theHud) {
|
||||
hud = theHud;
|
||||
hud.jsterm.clearOutput();
|
||||
browser.addEventListener("load", onLoad, true);
|
||||
content.location = TEST_BAD_POLICY_URI;
|
||||
}
|
||||
|
||||
function onLoad(aEvent) {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
testPolicyURIMessage();
|
||||
}
|
||||
|
||||
function testPolicyURIMessage() {
|
||||
let aOutputNode = hud.outputNode;
|
||||
|
||||
waitForSuccess(
|
||||
{
|
||||
name: "CSP policy URI warning displayed successfully",
|
||||
validatorFn: function() {
|
||||
return aOutputNode.querySelector(".webconsole-msg-error");
|
||||
},
|
||||
|
||||
successFn: function() {
|
||||
//tests on the urlnode
|
||||
let node = aOutputNode.querySelector(".webconsole-msg-error");
|
||||
isnot(node.textContent.indexOf("can't fetch policy"), -1,
|
||||
"CSP Policy URI message found");
|
||||
finishTest();
|
||||
},
|
||||
|
||||
failureFn: finishTest,
|
||||
}
|
||||
);
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// Tests that the Web Console CSP messages are displayed
|
||||
|
||||
const TEST_VIOLATION = "https://example.com/browser/browser/devtools/webconsole/test/test_bug_770099_violation.html";
|
||||
|
||||
let hud = undefined;
|
||||
|
||||
function test() {
|
||||
addTab("data:text/html;charset=utf8,Web Console CSP violation test");
|
||||
browser.addEventListener("load", function _onLoad() {
|
||||
browser.removeEventListener("load", _onLoad, true);
|
||||
openConsole(null, loadDocument);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function loadDocument(theHud){
|
||||
hud = theHud;
|
||||
hud.jsterm.clearOutput()
|
||||
browser.addEventListener("load", onLoad, true);
|
||||
content.location = TEST_VIOLATION;
|
||||
}
|
||||
|
||||
function onLoad(aEvent) {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
testViolationMessage();
|
||||
}
|
||||
|
||||
function testViolationMessage(){
|
||||
let aOutputNode = hud.outputNode;
|
||||
|
||||
waitForSuccess(
|
||||
{
|
||||
name: "CSP policy URI warning displayed successfully",
|
||||
validatorFn: function() {
|
||||
return aOutputNode.querySelector(".webconsole-msg-warn");
|
||||
},
|
||||
|
||||
successFn: function() {
|
||||
//tests on the urlnode
|
||||
let node = aOutputNode.querySelector(".webconsole-msg-warn");
|
||||
isnot(node.textContent.indexOf("violated"), -1,
|
||||
"CSP violation message found");
|
||||
finishTest();
|
||||
},
|
||||
|
||||
failureFn: finishTest,
|
||||
}
|
||||
);
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Test for Bug 770099 - bad policy-uri</title>
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=770099">Mozilla Bug 770099</a>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,2 @@
|
||||
X-Content-Security-Policy: policy-uri http://example.com/some_policy
|
||||
Content-type: text/html; charset=utf-8
|
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Test for Bug 770099 - policy violation</title>
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=770099">Mozilla Bug 770099</a>
|
||||
<img src="http://some.example.com/test.png">
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1 @@
|
||||
X-Content-Security-Policy: default-src 'self'
|
Loading…
Reference in New Issue
Block a user