tor-browser

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

script.html (1490B)


      1 <script src=/resources/testharness.js></script>
      2 <script src=/resources/testharnessreport.js></script>
      3 <div id=log></div>
      4 <script>
      5  var log = function() {}, // see comment below
      6      p = function() {}, // see comment below
      7      fails = [null, "", "x", "x/x", "text/html", "text/json"],
      8      passes = ["text/javascript", "text/ecmascript", "text/ecmascript;blah", "text/javascript1.0"]
      9 
     10  // Ideally we'd also check whether the scripts in fact execute, but that would involve
     11  // timers and might get a bit racy without cross-browser support for the execute events.
     12 
     13  const get_url = (mime, outcome) => {
     14    let url = "resources/js.py"
     15    if (mime != null) {
     16        url += "?type=" + encodeURIComponent(mime)
     17    }
     18    if (outcome) {
     19      url += "&outcome=p"
     20    }
     21    return url
     22  }
     23 
     24  fails.forEach(function(mime) {
     25    async_test(function(t) {
     26      var script = document.createElement("script")
     27      script.onerror = t.step_func_done(function(){})
     28      script.onload = t.unreached_func("Unexpected load event")
     29      script.src = get_url(mime)
     30      document.body.appendChild(script)
     31    }, "URL query: " + mime)
     32  })
     33 
     34  passes.forEach(function(mime) {
     35    async_test(function(t) {
     36      var script = document.createElement("script")
     37      script.onerror = t.unreached_func("Unexpected error event")
     38      script.onload = t.step_func_done(function(){})
     39      script.src = get_url(mime, true)
     40      document.body.appendChild(script)
     41    }, "URL query: " + mime)
     42  })
     43 </script>