tor-browser

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

touch_iframe_parent.html (1436B)


      1 <!-- This is the same as touch_iframe_parent_desktop.html with an additional viewport tag -->
      2 <!doctype html>
      3 <meta name="viewport" content="width=device-width, user-scalable=no">
      4 <style>
      5  iframe {
      6    position: absolute;
      7    top: 0px;
      8    width: 100px;
      9    height: 100px;
     10    &#local-iframe {
     11      left: 100px;
     12    }
     13    &#remote-iframe {
     14      left: 200px;
     15    }
     16  }
     17 </style>
     18 <iframe id="local-iframe" src="./touch_iframe_child.html"></iframe>
     19 <iframe id="remote-iframe"></iframe>
     20 
     21 <script>
     22  "use strict";
     23 
     24  function recordEvent(frameName, type) {
     25    const events = document.body.dataset[frameName];
     26    document.body.dataset[frameName] = (events ? (events + " ") : "") + type;
     27  }
     28 
     29  for (const type of ["mousedown", "mousemove", "mouseup",
     30                      "touchstart", "touchmove", "touchend",
     31                      "pointerdown", "pointermove", "pointerup",
     32                      "click", "dblclick", "contextmenu"]) {
     33    document.addEventListener(type, ev => {
     34      recordEvent("topFrame", ev.type);
     35      // Workaround for Bug 1976659: First click after contextmenu event is ignored with touch simulation
     36      if (ev.type === "contextmenu") {
     37        ev.preventDefault();
     38      }
     39    });
     40  }
     41 
     42  window.addEventListener("message", ev => {
     43    if (ev.data.from === location.origin) {
     44      recordEvent("localIFrame", ev.data.type);
     45    } else {
     46      recordEvent("remoteIFrame", ev.data.type);
     47    }
     48  });
     49 </script>