tor-browser

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

focus-before-iframe-loaded-different-site-outer.sub.html (1166B)


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