tor-browser

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

toBlob-cross-realm-callback-report-exception.html (1165B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>toBlob() reports the exception from its callback in the callback's global object</title>
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <iframe srcdoc="<canvas></canvas>"></iframe>
      7 <iframe></iframe>
      8 <iframe></iframe>
      9 <script>
     10 setup({ allow_uncaught_exception: true });
     11 
     12 const onerrorCalls = [];
     13 window.onerror = () => { onerrorCalls.push("top"); };
     14 frames[0].onerror = () => { onerrorCalls.push("frame0"); };
     15 frames[1].onerror = () => { onerrorCalls.push("frame1"); };
     16 frames[2].onerror = () => { onerrorCalls.push("frame2"); };
     17 
     18 async_test(t => {
     19  window.onload = t.step_func(() => {
     20    const canvas = frames[0].document.querySelector("canvas");
     21    canvas.toBlob(new frames[1].Function(`throw new parent.frames[2].Error("PASS");`));
     22 
     23    // Wait until at least one `onerror` fires.
     24    t.step_wait_func(() => onerrorCalls.length != 0);
     25 
     26    // Wait for 25ms more in case one other `onerror` fires.  This is inherently
     27    // flaky...
     28    t.step_timeout(() => {
     29      assert_array_equals(onerrorCalls, ["frame1"]);
     30      t.done();
     31    }, 25);
     32  });
     33 });
     34 </script>