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