tor-browser

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

eventsource-constructor-non-same-origin.htm (1235B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>shared worker - EventSource: constructor (act as if there is a network error)</title>
      5    <meta name=timeout content=long>
      6    <script src="/resources/testharness.js"></script>
      7    <script src="/resources/testharnessreport.js"></script>
      8  </head>
      9  <body>
     10    <div id="log"></div>
     11    <script>
     12      function fetchFail(url) {
     13        var test = async_test(document.title + " (" + url + ")")
     14        test.step(function() {
     15          var worker = new SharedWorker('eventsource-constructor-non-same-origin.js#'+encodeURIComponent(url))
     16          worker.port.onmessage = function(e) {
     17            test.step(function() {
     18              assert_true(e.data[0], e.data[1])
     19              assert_equals(e.data[1], EventSource.CLOSED, 'source.readyState')
     20              assert_false(e.data[2], "'data' in e");
     21            })
     22            test.done()
     23          }
     24        })
     25      }
     26      fetchFail("ftp://example.not")
     27      fetchFail("about:blank")
     28      fetchFail("mailto:whatwg@awesome.example")
     29      fetchFail("javascript:alert('FAIL')")
     30    </script>
     31    <!-- This tests "fails the connection" as well as making sure a simple
     32         event is dispatched and not a MessageEvent -->
     33  </body>
     34 </html>