tor-browser

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

focus-next-tick-before-iframe-loaded-different-site-outer.sub.html (1409B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>focus() from next tick before iframe loaded different site</title>
      5 </head>
      6 <body>
      7 <script>
      8 var pendingTimeout = false;
      9 window.onmessage = function(e) {
     10    if (e.data == "tick") {
     11        iframe.focus();
     12        if (document.activeElement != iframe) {
     13            if (pendingTimeout) {
     14                clearTimeout(pendingTimeout);
     15            }
     16            pendingTimeout = true;
     17            opener.postMessage("FAIL activeElement", "*");
     18        }
     19        return;
     20    }
     21 
     22    if (e.data == "onload") {
     23        if (pendingTimeout) {
     24            return;
     25        }
     26        pendingTimeout = opener.step_timeout(function() {
     27            opener.postMessage("FAIL missing onfocus", "*");
     28        }, 2000);
     29        return;
     30    }
     31    if (pendingTimeout) {
     32        clearTimeout(pendingTimeout);
     33    }
     34    pendingTimeout = true;
     35    if (e.data == "onfocus") {
     36        // Test not upstreamed, because this even is a Firefoxism
     37        // https://github.com/whatwg/html/issues/6209
     38        opener.postMessage("PASS", "*");
     39        return;
     40    }
     41    opener.postMessage("FAIL " + e.data, "*");
     42 }
     43 
     44 var iframe = document.createElement("iframe");
     45 iframe.src = "http://{{hosts[alt][www]}}:{{ports[http][0]}}/_mozilla/focus/support/focus-next-tick-before-iframe-loaded-different-site-inner.html";
     46 document.body.appendChild(iframe);
     47 window.postMessage("tick", "*");
     48 </script>
     49 </body>
     50 </html>