tor-browser

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

event-global-is-still-set-when-reporting-exception-onerror.html (1721B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>window.onerror handler restores window.event after it reports an exception</title>
      4 <link rel="help" href="https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 
      8 <body>
      9 <iframe src="resources/empty-document.html"></iframe>
     10 <iframe src="resources/empty-document.html"></iframe>
     11 
     12 <script>
     13 setup({ allow_uncaught_exception: true });
     14 
     15 async_test(t => {
     16    window.onload = t.step_func_done(onLoadEvent => {
     17        frames[0].onerror = new frames[1].Function(`
     18            top.eventDuringSecondOnError = top.window.event;
     19            top.frames[0].eventDuringSecondOnError = top.frames[0].event;
     20            top.frames[1].eventDuringSecondOnError = top.frames[1].event;
     21        `);
     22 
     23        window.onerror = new frames[0].Function(`
     24            top.eventDuringFirstOnError = top.window.event;
     25            top.frames[0].eventDuringFirstOnError = top.frames[0].event;
     26            top.frames[1].eventDuringFirstOnError = top.frames[1].event;
     27 
     28            foo; // cause second onerror
     29        `);
     30 
     31        const myEvent = new ErrorEvent("error", { error: new Error("myError") });
     32        window.dispatchEvent(myEvent);
     33 
     34        assert_equals(top.eventDuringFirstOnError, onLoadEvent);
     35        assert_equals(frames[0].eventDuringFirstOnError, myEvent);
     36        assert_equals(frames[1].eventDuringFirstOnError, undefined);
     37 
     38        assert_equals(top.eventDuringSecondOnError, onLoadEvent);
     39        assert_equals(frames[0].eventDuringSecondOnError, myEvent);
     40        assert_equals(frames[1].eventDuringSecondOnError.error.name, "ReferenceError");
     41    });
     42 });
     43 </script>