tor-browser

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

respond-with-body-accessed-response-iframe.html (657B)


      1 <script>
      2 var callback;
      3 
      4 // Creates a <script> element with |url| source, and returns a promise for the
      5 // result of the executed script. Uses JSONP because some responses to |url|
      6 // are opaque so their body cannot be tested directly.
      7 function getJSONP(url) {
      8  var sc = document.createElement('script');
      9  sc.src = url;
     10  var promise = new Promise(function(resolve, reject) {
     11      // This callback function is called by appending a script element.
     12      callback = resolve;
     13      sc.addEventListener(
     14          'error',
     15          function() { reject('Failed to load url:' + url); });
     16    });
     17  document.body.appendChild(sc);
     18  return promise;
     19 }
     20 </script>