|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <title>Bug 802872</title> |
|
5 <!-- Including SimpleTest.js so we can use waitForExplicitFinish !--> |
|
6 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
8 </head> |
|
9 <body> |
|
10 <p id="display"></p> |
|
11 <div id="content" style="display: none"></div> |
|
12 <iframe style="width:100%;" id='eventframe'></iframe> |
|
13 |
|
14 <script class="testbody" type="text/javascript"> |
|
15 |
|
16 SimpleTest.waitForExplicitFinish(); |
|
17 |
|
18 var finishedTests = 0; |
|
19 var numberOfTests = 2; |
|
20 |
|
21 var checkExplicitFinish = function () { |
|
22 finishedTests++; |
|
23 if (finishedTests == numberOfTests) { |
|
24 SimpleTest.finish(); |
|
25 } |
|
26 } |
|
27 |
|
28 SpecialPowers.pushPrefEnv( |
|
29 {'set':[["security.csp.speccompliant", true]]}, |
|
30 function () { |
|
31 // add event listeners for CSP-permitted EventSrc callbacks |
|
32 addEventListener('allowedEventSrcCallbackOK', function (e) { |
|
33 ok(true, "OK: CSP allows EventSource for whitelisted domain!"); |
|
34 checkExplicitFinish(); |
|
35 }, false); |
|
36 addEventListener('allowedEventSrcCallbackFailed', function (e) { |
|
37 ok(false, "Error: CSP blocks EventSource for whitelisted domain!"); |
|
38 checkExplicitFinish(); |
|
39 }, false); |
|
40 |
|
41 // add event listeners for CSP-blocked EventSrc callbacks |
|
42 addEventListener('blockedEventSrcCallbackOK', function (e) { |
|
43 ok(false, "Error: CSP allows EventSource to not whitelisted domain!"); |
|
44 checkExplicitFinish(); |
|
45 }, false); |
|
46 addEventListener('blockedEventSrcCallbackFailed', function (e) { |
|
47 ok(true, "OK: CSP blocks EventSource for not whitelisted domain!"); |
|
48 checkExplicitFinish(); |
|
49 }, false); |
|
50 |
|
51 // load it |
|
52 document.getElementById('eventframe').src = 'file_CSP_bug802872.html'; |
|
53 } |
|
54 ); |
|
55 |
|
56 </script> |
|
57 </body> |
|
58 </html> |