tor-browser

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

history-back-and-forward-should-not-work-in-fenced-tree.https.html (2954B)


      1 <!DOCTYPE html>
      2 <html>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="resources/utils.js"></script>
      6 <script src="/common/utils.js"></script>
      7 <title>history-back-and-forward-should-not-work-in-fenced-tree</title>
      8 
      9 <body>
     10  <script>
     11    // TODO(crbug.com/1262022): Remove references to ShadowDOM now that the
     12    // implementation is obsolete.
     13    const test_desc = "history.back() and history.forward() should be " +
     14                      "restricted within a fenced tree in shadowDOM thus have" +
     15                      " no effect when called within a fenced tree scope.";
     16    const history_navigation_performed_key = token();
     17    const outer_page_ready_key = token();
     18 
     19    // attach a fenced frame to exeute a series of back and forward history
     20    // navigations.
     21    attachFencedFrame(
     22        generateURL(
     23            "resources/history-back-and-forward-should-not-work-in-" +
     24            "fenced-tree-inner.html",
     25            [history_navigation_performed_key, outer_page_ready_key]));
     26 
     27    promise_test(async function () {
     28      await nextValueFromServer(history_navigation_performed_key);
     29 
     30      // Perform a series of history.pushState() to help observe any popstate due
     31      // to back and forward history navigations.
     32      window.history.pushState(1, document.title, '#tag1');
     33      window.history.pushState(2, document.title, '#tag2');
     34      window.history.pushState(3, document.title, '#tag3');
     35 
     36      writeValueToServer(outer_page_ready_key, "yes");
     37 
     38      // Assert restricted history.back() within fenced frame.
     39      await nextValueFromServer(history_navigation_performed_key);
     40      assert_equals(window.history.state, 3, "history.back() should be " +
     41        "restricted and will not work when called from a fenced frame.");
     42 
     43      writeValueToServer(outer_page_ready_key, "yes");
     44 
     45      // Assert restricted history.forward() within fenced frame.
     46      await nextValueFromServer(history_navigation_performed_key);
     47      assert_equals(window.history.state, 3, "history.forward() should be " +
     48        "restricted and will not work when called from a fenced frame.");
     49 
     50      writeValueToServer(outer_page_ready_key, "yes");
     51 
     52      // Assert restricted history.back() within iframe in fenced frame.
     53      await nextValueFromServer(history_navigation_performed_key);
     54      assert_equals(window.history.state, 3, "history.back() should be " +
     55        "restricted and will not work within an iframe embeeded in a fenced " +
     56        "frame.");
     57 
     58      writeValueToServer(outer_page_ready_key, "yes");
     59 
     60      // Assert restricted history.forward() within iframe in fenced frame.
     61      await nextValueFromServer(history_navigation_performed_key);
     62      assert_equals(window.history.state, 3, "history.forward() should be " +
     63        "restricted and will not work within an iframe embeeded in a fenced " +
     64        "frame.");
     65    }, test_desc);
     66  </script>
     67 </body>
     68 </html>