tor-browser

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

opaque-response-preloaded-xhr.html (1081B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <body></body>
      4 <script>
      5 const URL = 'opaque-response?from=opaque-response-preloaded-xhr.html';
      6 function runTest() {
      7  var l = document.createElement('link');
      8  // Use link rel=preload to try to get the browser to cache the opaque
      9  // response.
     10  l.setAttribute('rel', 'preload');
     11  l.setAttribute('href', URL);
     12  l.setAttribute('as', 'fetch');
     13  l.onload = function() {
     14    xhr = new XMLHttpRequest;
     15    xhr.withCredentials = true;
     16    xhr.open('GET', URL);
     17    // opaque-response returns an opaque response from serviceworker and thus
     18    // the XHR must fail because it is not no-cors request.
     19    // Particularly, the XHR must not reuse the opaque response from the
     20    // preload request.
     21    xhr.onerror = function() {
     22      parent.done('PASS');
     23    };
     24    xhr.onload = function() {
     25      parent.done('FAIL: ' + xhr.responseText);
     26    };
     27    xhr.send();
     28  };
     29  l.onerror = function() {
     30    parent.done('FAIL: preload failed unexpectedly');
     31  };
     32  document.body.appendChild(l);
     33 }
     34 </script>
     35 <body onload="setTimeout(runTest, 100)"></body>