tor-browser

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

Range-test-iframe.html (1657B)


      1 <!doctype html>
      2 <title>Range test iframe</title>
      3 <link rel="author" title="Aryeh Gregor" href=ayg@aryeh.name>
      4 <meta name=timeout content=long>
      5 <body onload=run()>
      6 <script src=../common.js></script>
      7 <script>
      8 "use strict";
      9 
     10 // This script only exists because we want to evaluate the range endpoints
     11 // in each iframe using that iframe's local variables set up by common.js.  It
     12 // just creates the range and does nothing else.  The data is returned via
     13 // window.testRange, and if an exception is thrown, it's put in
     14 // window.unexpectedException.
     15 window.unexpectedException = null;
     16 
     17 function run() {
     18  try {
     19    window.unexpectedException = null;
     20 
     21    if (typeof window.testNodeInput != "undefined") {
     22      window.testNode = eval(window.testNodeInput);
     23    }
     24 
     25    var rangeEndpoints;
     26    if (typeof window.testRangeInput == "undefined") {
     27      // Use the hash (old way of doing things, bad because it requires
     28      // navigation)
     29      if (location.hash == "") {
     30        return;
     31      }
     32      rangeEndpoints = eval(location.hash.substr(1));
     33    } else {
     34      // Get the variable directly off the window, faster and can be done
     35      // synchronously
     36      rangeEndpoints = eval(window.testRangeInput);
     37    }
     38 
     39    var range;
     40    if (rangeEndpoints == "detached") {
     41      range = document.createRange();
     42      range.detach();
     43    } else {
     44      range = ownerDocument(rangeEndpoints[0]).createRange();
     45      range.setStart(rangeEndpoints[0], rangeEndpoints[1]);
     46      range.setEnd(rangeEndpoints[2], rangeEndpoints[3]);
     47    }
     48 
     49    window.testRange = range;
     50  } catch(e) {
     51    window.unexpectedException = e;
     52  }
     53 }
     54 
     55 testDiv.style.display = "none";
     56 </script>