mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 15:28:39 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
76
dom/security/test/csp/test_allow_https_schemes.html
Normal file
76
dom/security/test/csp/test_allow_https_schemes.html
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 826805 - Allow http and https for scheme-less sources</title>
|
||||
<!-- Including SimpleTest.js so we can use waitForExplicitFinish !-->
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="visibility: hidden">
|
||||
<iframe style="width:100%;" id="testframe"></iframe>
|
||||
</div>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
/* Description of the test:
|
||||
* We are loading the following url (including a fragment portion):
|
||||
* https://example.com/tests/dom/security/test/csp/file_path_matching.js#foo
|
||||
* using different policies that lack specification of a scheme.
|
||||
*
|
||||
* Since the file is served over http:, the upgrade to https should be
|
||||
* permitted by CSP in case no port is specified.
|
||||
*/
|
||||
|
||||
var policies = [
|
||||
["allowed", "example.com"],
|
||||
["allowed", "example.com:443"],
|
||||
["allowed", "example.com:80"],
|
||||
["allowed", "http://*:80"],
|
||||
["allowed", "https://*:443"],
|
||||
// our testing framework only supports :80 and :443, but
|
||||
// using :8000 in a policy does the trick for the test.
|
||||
["blocked", "example.com:8000"],
|
||||
]
|
||||
|
||||
var counter = 0;
|
||||
var policy;
|
||||
|
||||
function loadNextTest() {
|
||||
if (counter == policies.length) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
else {
|
||||
policy = policies[counter++];
|
||||
var src = "file_testserver.sjs";
|
||||
// append the file that should be served
|
||||
src += "?file=" + escape("tests/dom/security/test/csp/file_allow_https_schemes.html");
|
||||
// append the CSP that should be used to serve the file
|
||||
src += "&csp=" + escape("default-src 'none'; script-src " + policy[1]);
|
||||
|
||||
document.getElementById("testframe").addEventListener("load", test, false);
|
||||
document.getElementById("testframe").src = src;
|
||||
}
|
||||
}
|
||||
|
||||
function test() {
|
||||
try {
|
||||
document.getElementById("testframe").removeEventListener('load', test, false);
|
||||
var testframe = document.getElementById("testframe");
|
||||
var divcontent = testframe.contentWindow.document.getElementById('testdiv').innerHTML;
|
||||
is(divcontent, policy[0], "should be " + policy[0] + " in test " + (counter - 1) + "!");
|
||||
}
|
||||
catch (e) {
|
||||
ok(false, "ERROR: could not access content in test " + (counter - 1) + "!");
|
||||
}
|
||||
loadNextTest();
|
||||
}
|
||||
|
||||
loadNextTest();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue