tor-browser

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

location-assign-user-click.html (1376B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="resources/helpers.js"></script>
      6 <script src="/resources/testdriver.js"></script>
      7 <script src="/resources/testdriver-vendor.js"></script>
      8 
      9 <body>
     10 <script>
     11 "use strict";
     12 promise_test(async t => {
     13  const sentinelIframe = await setupSentinelIframe(t);
     14  const startingHistoryLength = history.length;
     15 
     16  const code = `
     17    const button = document.createElement("button");
     18    button.id = "the-button";
     19    button.textContent = "needs to have content to be clickable";
     20    button.onclick = () => { location.assign("/common/blank.html?thereplacement"); };
     21    document.currentScript.before(button);
     22    parent.test_driver.click(button);
     23  `;
     24 
     25  const startURL = "resources/slow-code-injector.html?pipe=sub(none)&code=" + encodeURIComponent(code);
     26  const afterReplacementURL = "/common/blank.html?thereplacement";
     27  const iframe = insertIframe(t, startURL);
     28 
     29  assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");
     30 
     31  await waitForLoad(t, iframe, afterReplacementURL);
     32  assert_equals(history.length, startingHistoryLength + 1, "history.length must change after waiting for the load");
     33 }, "NO replace before load, triggered by location.assign()");
     34 </script>