tor-browser

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

credentials-iframe.html (981B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>Controlled frame for Cache API test with credentials</title>
      4 <script>
      5 
      6 function xhr(url, username, password) {
      7  return new Promise(function(resolve, reject) {
      8    var xhr = new XMLHttpRequest(), async = true;
      9    xhr.open('GET', url, async, username, password);
     10    xhr.send();
     11    xhr.onreadystatechange = function() {
     12      if (xhr.readyState !== XMLHttpRequest.DONE)
     13        return;
     14      if (xhr.status === 200) {
     15        resolve(xhr.responseText);
     16      } else {
     17        reject(new Error(xhr.statusText));
     18      }
     19    };
     20  });
     21 }
     22 
     23 window.onmessage = function(e) {
     24  Promise.all(e.data.map(function(item) {
     25    return xhr(item.name, item.username, item.password);
     26  }))
     27    .then(function() {
     28      navigator.serviceWorker.controller.postMessage('keys');
     29      navigator.serviceWorker.onmessage = function(e) {
     30        window.parent.postMessage(e.data, '*');
     31      };
     32    });
     33 };
     34 
     35 </script>
     36 <body>
     37 Hello? Yes, this is iframe.
     38 </body>