tor-browser

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

test_bug802872.html (1576B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Bug 802872</title>
      5  <!-- Including SimpleTest.js so we can use waitForExplicitFinish !-->
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      8 </head>
      9 <body>
     10  <p id="display"></p>
     11  <div id="content" style="display: none"></div>
     12  <iframe style="width:100%;" id='eventframe'></iframe>
     13 
     14 <script class="testbody" type="text/javascript">
     15 
     16 SimpleTest.waitForExplicitFinish();
     17 
     18 var finishedTests = 0;
     19 var numberOfTests = 2;
     20 
     21 var checkExplicitFinish = function () {
     22  finishedTests++;
     23  if (finishedTests == numberOfTests) {
     24     SimpleTest.finish();
     25  }
     26 }
     27 
     28 // add event listeners for CSP-permitted EventSrc callbacks
     29 addEventListener('allowedEventSrcCallbackOK', function (e) {
     30  ok(true, "OK: CSP allows EventSource for allowlisted domain!");
     31  checkExplicitFinish();
     32 }, false);
     33 addEventListener('allowedEventSrcCallbackFailed', function (e) {
     34  ok(false, "Error: CSP blocks EventSource for allowlisted domain!");
     35  checkExplicitFinish();
     36 }, false);
     37 
     38 // add event listeners for CSP-blocked EventSrc callbacks
     39 addEventListener('blockedEventSrcCallbackOK', function (e) {
     40  ok(false, "Error: CSP allows EventSource to not allowlisted domain!");
     41  checkExplicitFinish();
     42 }, false);
     43 addEventListener('blockedEventSrcCallbackFailed', function (e) {
     44  ok(true, "OK: CSP blocks EventSource for not allowlisted domain!");
     45  checkExplicitFinish();
     46 }, false);
     47 
     48 // load it
     49 document.getElementById('eventframe').src = 'file_bug802872.html';
     50 
     51 </script>
     52 </body>
     53 </html>