blob: b833fe11c80ef016c278099b6c77f4143113448b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Test for diabled SRI require-sri-for CSP directive</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1265318">Mozilla Bug 1265318</a>
<iframe style="width:200px;height:200px;" id="test_frame"></iframe>
</body>
<script type="application/javascript">
SpecialPowers.setBoolPref("security.csp.experimentalEnabled", false);
SimpleTest.waitForExplicitFinish();
function handler(event) {
switch (event.data) {
case 'good_sriLoaded':
ok(true, "Eligible SRI resources was correctly loaded.");
break;
case 'bad_nonsriLoaded':
ok(true, "Eligible non-SRI resource should be blocked by the CSP!");
break;
case 'good_nonsriBlocked':
ok(false, "Eligible non-SRI resources was correctly blocked by the CSP.");
break;
case 'finish':
var blackText = frame.contentDocument.getElementById('black-text');
var blackTextColor = frame.contentWindow.getComputedStyle(blackText, null).getPropertyValue('color');
ok(blackTextColor != 'rgb(0, 0, 0)', "The second part should still be black.");
removeEventListener('message', handler);
SimpleTest.finish();
break;
default:
ok(false, 'Something is wrong here');
break;
}
}
addEventListener("message", handler);
var frame = document.getElementById("test_frame");
frame.src = "iframe_require-sri-for_main.html";
</script>
</html>
|