tor-browser

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

precommitHandler-traverse.html (1559B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="../navigation-methods/return-value/resources/helpers.js"></script>
      5 <script src="resources/precommitHandler-helpers.js"></script>
      6 <body>
      7 <script>
      8 let start_index = navigation.currentEntry.index;
      9 
     10 // Note that `destinationIndex` is chosen relative to `start_index`, and the
     11 // tests begin at `start_index` + 4. So:
     12 // * "rejectBeforeCommit" will try to go back 4 steps and fail.
     13 // * "rejectAfterCommit" will go back 3 steps, then reject after commit.
     14 // * "success" will go forward 2 steps
     15 let tests = [
     16  { mode: "rejectBeforeCommit", destinationIndex: start_index, description: "precommitHandler for a traverse navigation, reject before commit" },
     17  { mode: "rejectAfterCommit",  destinationIndex: start_index + 1, description: "precommitHandler for a traverse navigation, reject after commit" },
     18  { mode: "success",            destinationIndex: start_index + 3, description: "precommitHandler for a traverse navigation, success" }
     19 ];
     20 
     21 // Push a bunch of history entries so each test case can target a unique entry.
     22 history.pushState("", "", "#1");
     23 history.pushState("", "", "#2");
     24 history.pushState("", "", "#3");
     25 history.pushState("", "", "#4");
     26 
     27 let onload_promise = new Promise(resolve => window.onload = resolve);
     28 for (let test of tests) {
     29  promise_test(async t => {
     30    await onload_promise;
     31    await testDeferredCommit(t, "traverse", test.mode, test.destinationIndex);
     32  }, test.description);
     33 }
     34 </script>
     35 </body>