tor-browser

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

opaque-response-being-preloaded-xhr.html (1028B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <body></body>
      4 <script>
      5 const URL = 'opaque-response?from=opaque-response-being-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.onerror = function() {
     14    parent.done('FAIL: preload failed unexpectedly');
     15  };
     16  document.body.appendChild(l);
     17  xhr = new XMLHttpRequest;
     18  xhr.withCredentials = true;
     19  xhr.open('GET', URL);
     20  // opaque-response returns an opaque response from serviceworker and thus
     21  // the XHR must fail because it is not no-cors request.
     22  // Particularly, the XHR must not reuse the opaque response from the
     23  // preload request.
     24  xhr.onerror = function() {
     25    parent.done('PASS');
     26  };
     27  xhr.onload = function() {
     28    parent.done('FAIL: ' + xhr.responseText);
     29  };
     30  xhr.send();
     31 }
     32 </script>
     33 <body onload="setTimeout(runTest, 100)"></body>