content/base/test/csp/file_CSP_bug802872.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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);

mercurial