tor-browser

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

signal-abort-window-stop-after-intercept.html (1524B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script>
      5 async_test(t => {
      6  window.onload = t.step_func(() => {
      7    let start_url = location.href;
      8    let abort_signal;
      9    let onabort_called = false;
     10    let navigateErrorException;
     11    navigation.onnavigateerror = t.step_func(e => {
     12      assert_equals(e.constructor, ErrorEvent);
     13      navigateErrorException = e.error;
     14      assert_equals(e.filename, start_url);
     15      assert_greater_than(e.lineno, 0);
     16      assert_greater_than(e.colno, 0);
     17    });
     18    navigation.onnavigatesuccess = t.unreached_func("onnavigatesuccess");
     19    navigation.onnavigate = t.step_func(e => {
     20      abort_signal = e.signal;
     21      abort_signal.onabort = () => onabort_called = true;
     22      e.intercept({ handler: () => new Promise(resolve => t.step_timeout(resolve, 0)) });
     23    });
     24    let result = navigation.navigate("?1");
     25    window.stop();
     26    assert_true(abort_signal.aborted);
     27    assert_true(onabort_called);
     28 
     29    result.committed.then(() => {
     30      return promise_rejects_dom(t, 'AbortError', result.finished);
     31    }).then(() => {
     32      return result.finished.catch(e => assert_equals(e, navigateErrorException));
     33    }).then(() => {
     34      // Complete the test asynchronously to ensure that onnavigatesuccess
     35      // didn't fire on a microtask.
     36      t.step_timeout(t.step_func_done(() => {}), 5);
     37    });
     38  });
     39 }, "window.stop() cancels the navigate event's intercept() and signals event.signal");
     40 </script>