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