tor-browser

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

navigation-state-reset-sameorigin.html (2126B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <script src="/resources/testharness.js"></script>
      5    <script src="/resources/testharnessreport.js"></script>
      6    <script src="/resources/testdriver.js"></script>
      7    <script src="/resources/testdriver-vendor.js"></script>
      8  </head>
      9  <body>
     10    <h1>Post-navigation activation state in child</h1>
     11    <p>
     12      Tests that navigating a same-origin child frame resets its activation
     13      states.
     14    </p>
     15    <ol id="instructions">
     16      <li>Click inside the yellow area.</li>
     17    </ol>
     18 
     19    <iframe id="child" width="200" height="50"> </iframe>
     20    <script>
     21      function message(type) {
     22        return new Promise((resolve) => {
     23          window.addEventListener("message", function listener(event) {
     24            const data = JSON.parse(event.data);
     25            if (data.type === type) {
     26              window.removeEventListener("message", listener);
     27              resolve(data);
     28            }
     29          });
     30        });
     31      }
     32      promise_test(async (t) => {
     33        var child = document.getElementById("child");
     34        child.src = "./resources/child-one.html";
     35        const unclickeData = await message("child-one-loaded");
     36        assert_false(navigator.userActivation.isActive);
     37        assert_false(navigator.userActivation.hasBeenActive);
     38        assert_false(unclickeData.isActive);
     39        assert_false(unclickeData.hasBeenActive);
     40 
     41        const [, child1Data] = await Promise.all([
     42          test_driver.click(child),
     43          message("child-one-clicked"),
     44        ]);
     45 
     46        assert_true(navigator.userActivation.isActive);
     47        assert_true(navigator.userActivation.hasBeenActive);
     48        assert_true(child1Data.isActive);
     49        assert_true(child1Data.hasBeenActive);
     50 
     51        child.src = "./resources/child-two.html";
     52 
     53        const child2Data = await message("child-two-loaded");
     54 
     55        assert_true(navigator.userActivation.isActive);
     56        assert_true(navigator.userActivation.hasBeenActive);
     57        assert_false(child2Data.isActive);
     58        assert_false(child2Data.hasBeenActive);
     59      }, "Post-navigation state reset.");
     60    </script>
     61  </body>
     62 </html>