tor-browser

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

basic.html (2125B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="/resources/testdriver.js"></script>
      5 <script src="/resources/testdriver-vendor.js"></script>
      6 
      7 <script type="module">
      8 import { testFocusWasReset, testFocusWasNotReset } from "./resources/helpers.mjs";
      9 
     10 test(() => {
     11  let throwAssertionHappened = false;
     12 
     13  navigation.addEventListener("navigate", e => {
     14    assert_throws_js(TypeError, () => {
     15      e.intercept({ focusReset: "invalid" });
     16    });
     17    throwAssertionHappened = true;
     18  }, { once: true });
     19 
     20  navigation.navigate("#1");
     21  assert_true(throwAssertionHappened);
     22 }, "Invalid values for focusReset throw");
     23 
     24 testFocusWasNotReset(() => {
     25  // Intentionally left blank.
     26 }, "Does not reset the focus when no navigate handler is present");
     27 
     28 testFocusWasReset(t => {
     29  navigation.addEventListener("navigate", e => {
     30    e.intercept();
     31  }, { once: true });
     32 }, "Resets the focus when no focusReset option is provided");
     33 
     34 testFocusWasReset(t => {
     35  navigation.addEventListener("navigate", e => {
     36    e.intercept();
     37  }, { once: true });
     38 }, "Resets the focus when focusReset is explicitly set to undefined");
     39 
     40 testFocusWasReset(t => {
     41  navigation.addEventListener("navigate", e => {
     42    e.intercept({ handler: () => new Promise(r => t.step_timeout(r, 5)) });
     43  }, { once: true });
     44 }, "Resets the focus when no focusReset option is provided (nontrivial fulfilled promise)");
     45 
     46 testFocusWasReset(t => {
     47  navigation.addEventListener("navigate", e => {
     48    e.intercept({ handler: () => Promise.reject() });
     49  }, { once: true });
     50 }, "Resets the focus when no focusReset option is provided (rejected promise)");
     51 
     52 testFocusWasReset(t => {
     53  navigation.addEventListener("navigate", e => {
     54    e.intercept({ focusReset: "after-transition" });
     55  }, { once: true });
     56 }, "Resets the focus when focusReset is explicitly set to 'after-transition'");
     57 
     58 testFocusWasNotReset(t => {
     59  navigation.addEventListener("navigate", e => {
     60    e.intercept({ focusReset: "manual" });
     61  });
     62 }, "Does not reset the focus when focusReset is set to 'manual'");
     63 </script>