tor-browser

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

reporterror-cross-realm-method.html (1008B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <title>self.reportError() dispatches an "error" event for this's relevant global object</title>
      4 <link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-reporterror">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 
      8 <body>
      9 <script>
     10 setup({ allow_uncaught_exception: true });
     11 
     12 async_test(t => {
     13  window.addEventListener("error", t.unreached_func("'error' event should not be dispatched for top window!"));
     14 
     15  const iframe = document.createElement("iframe");
     16  iframe.onload = t.step_func_done(() => {
     17    let eventFired = false;
     18    const error = new TypeError("foo");
     19    const otherWindow = iframe.contentWindow;
     20    otherWindow.addEventListener("error", t.step_func(event => {
     21      assert_equals(event.error, error);
     22      eventFired = true;
     23    }));
     24 
     25    window.reportError.call(otherWindow, error);
     26    assert_true(eventFired);
     27  });
     28  document.body.append(iframe);
     29 });
     30 </script>