tor-browser

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

file_top_navigation_by_user_activation_iframe.html (763B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <script src="/tests/SimpleTest/EventUtils.js"></script>
      6 <title>Test window for top navigation with user activation</title>
      7 <script>
      8 function navigate(aURL) {
      9  try {
     10    top.location.href = aURL;
     11  } catch (e) {
     12    top.postMessage("BLOCKED", "*");
     13  }
     14 }
     15 
     16 window.onmessage = (e) => {
     17  SpecialPowers.wrap(document).clearUserGestureActivation();
     18  let [command, url] = e.data;
     19  if (command == "CLICK") {
     20    let button = document.querySelector("button");
     21    button.addEventListener("click", () => {
     22      navigate(url);
     23    }, { once: true });
     24    synthesizeMouseAtCenter(button, {});
     25  } else if (command == "SCRIPT") {
     26    navigate(url);
     27  }
     28 };
     29 </script>
     30 </head>
     31 <body><button>Click</button></body>
     32 </html>