Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /*
2 * The policy for this test is:
3 * Content-Security-Policy: default-src 'self'
4 */
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");
13 src_event.onmessage = function(e) {
14 src_event.close();
15 parent.dispatchEvent(new Event('allowedEventSrcCallbackOK'));
16 }
18 src_event.onerror = function(e) {
19 src_event.close();
20 parent.dispatchEvent(new Event('allowedEventSrcCallbackFailed'));
21 }
22 }
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");
31 src_event.onmessage = function(e) {
32 src_event.close();
33 parent.dispatchEvent(new Event('blockedEventSrcCallbackOK'));
34 }
36 src_event.onerror = function(e) {
37 src_event.close();
38 parent.dispatchEvent(new Event('blockedEventSrcCallbackFailed'));
39 }
40 }
42 addLoadEvent(createAllowedEvent);
43 addLoadEvent(createBlockedEvent);