tor-browser

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

file_clonewrapper.html (947B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4 <script type="application/javascript">
      5 
      6  function waitForMessage() {
      7    return new Promise(function(resolve) {
      8      window.addEventListener('message', function(evt) {
      9        resolve(evt.data);
     10      }, {once: true});
     11    });
     12  }
     13 
     14  // Set up the objects for cloning.
     15  function setup() {
     16    window.testObject = { myNumber: 42,
     17                          myString: "hello",
     18                          myImageData: new ImageData(10, 10) };
     19  }
     20 
     21  // Called by the chrome parent window.
     22  function tryToClone(obj, shouldSucceed, message) {
     23    var success = false;
     24    try { window.postMessage(obj, '*'); success = true; }
     25    catch (e) { message = message + ' (threw: ' + e.message + ')'; }
     26    is(success, shouldSucceed, message);
     27    return (success && shouldSucceed) ? waitForMessage() : Promise.resolve();
     28  }
     29 
     30 </script>
     31 </head>
     32 <body onload="setup()">
     33 <input id="fileinput" type="file"></input>
     34 </body>
     35 </html>