|
1 /* |
|
2 * The policy for this test is: |
|
3 * Content-Security-Policy: default-src 'self' |
|
4 */ |
|
5 |
|
6 function createAllowedEvent() { |
|
7 /* |
|
8 * Creates a new EventSource using 'http://mochi.test:8888'. Since all mochitests run on |
|
9 * 'http://mochi.test', a default-src of 'self' allows this request. |
|
10 */ |
|
11 var src_event = new EventSource("http://mochi.test:8888/tests/content/base/test/csp/file_CSP_bug802872.sjs"); |
|
12 |
|
13 src_event.onmessage = function(e) { |
|
14 src_event.close(); |
|
15 parent.dispatchEvent(new Event('allowedEventSrcCallbackOK')); |
|
16 } |
|
17 |
|
18 src_event.onerror = function(e) { |
|
19 src_event.close(); |
|
20 parent.dispatchEvent(new Event('allowedEventSrcCallbackFailed')); |
|
21 } |
|
22 } |
|
23 |
|
24 function createBlockedEvent() { |
|
25 /* |
|
26 * creates a new EventSource using 'http://example.com'. This domain is not whitelisted by the |
|
27 * CSP of this page, therefore the CSP blocks this request. |
|
28 */ |
|
29 var src_event = new EventSource("http://example.com/tests/content/base/test/csp/file_CSP_bug802872.sjs"); |
|
30 |
|
31 src_event.onmessage = function(e) { |
|
32 src_event.close(); |
|
33 parent.dispatchEvent(new Event('blockedEventSrcCallbackOK')); |
|
34 } |
|
35 |
|
36 src_event.onerror = function(e) { |
|
37 src_event.close(); |
|
38 parent.dispatchEvent(new Event('blockedEventSrcCallbackFailed')); |
|
39 } |
|
40 } |
|
41 |
|
42 addLoadEvent(createAllowedEvent); |
|
43 addLoadEvent(createBlockedEvent); |