tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

file_bug802872.js (1340B)


      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(
     12    "http://mochi.test:8888/tests/dom/security/test/csp/file_bug802872.sjs"
     13  );
     14 
     15  src_event.onmessage = function (e) {
     16    src_event.close();
     17    parent.dispatchEvent(new Event("allowedEventSrcCallbackOK"));
     18  };
     19 
     20  src_event.onerror = function (e) {
     21    src_event.close();
     22    parent.dispatchEvent(new Event("allowedEventSrcCallbackFailed"));
     23  };
     24 }
     25 
     26 function createBlockedEvent() {
     27  /*
     28   * creates a new EventSource using 'http://example.com'. This domain is not allowlisted by the
     29   * CSP of this page, therefore the CSP blocks this request.
     30   */
     31  var src_event = new EventSource(
     32    "http://example.com/tests/dom/security/test/csp/file_bug802872.sjs"
     33  );
     34 
     35  src_event.onmessage = function (e) {
     36    src_event.close();
     37    parent.dispatchEvent(new Event("blockedEventSrcCallbackOK"));
     38  };
     39 
     40  src_event.onerror = function (e) {
     41    src_event.close();
     42    parent.dispatchEvent(new Event("blockedEventSrcCallbackFailed"));
     43  };
     44 }
     45 
     46 addLoadEvent(createAllowedEvent);
     47 addLoadEvent(createBlockedEvent);