tor-browser

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

bug1833279-iframe.html (1373B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <script src="foo" type="text/javascript"></script>
      4 <script>
      5 // Note: this file gets loaded twice in the course of this test: first, in an
      6 // iframe hosted in the top-level test; and second, in an <object> inside that
      7 // iframe's document. (The object element gets created dynamically in the
      8 // script below.)
      9 window.onload = () => {
     10  // For efficiency: check our window.location, to be sure we only run this
     11  // logic in the iframe, and *not* in the <object> that ends up getting loaded
     12  // with the same URL plus a "?" at the end:
     13  let locationStr = "" + location;
     14  if (!locationStr.endsWith("?")) {
     15    window.print();
     16 
     17    // Add an object whose location is set to '?' (which means our same
     18    // base URL plus a "?" character):
     19    let a = document.createElement("object");
     20    a.data = "?";
     21    document.documentElement.appendChild(a)
     22  } else if (parent.parent && parent.parent.iframeStepComplete) {
     23    // We're the nested document in the `<object>` tag that was created above.
     24    // Signal the outer document (our grandparent) that we've completed the
     25    // step of loading this inner object document.
     26    parent.parent.iframeStepComplete();
     27  }
     28 }
     29 
     30 window.onafterprint = () => {
     31  // We've finished printing; signal to our outer document that we've completed
     32  // that step.
     33  parent.iframeStepComplete();
     34 }
     35 </script>