tor-browser

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

test_location_setters.html (1848B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=639720
      5 -->
      6 <head>
      7  <title>Test for Bug 639720</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=639720">Mozilla Bug 639720</a>
     13 <p id="display">
     14  <iframe id="f"></iframe>
     15 </p>
     16 <div id="content" style="display: none">
     17  
     18 </div>
     19 <pre id="test">
     20 <script type="application/javascript">
     21 
     22 /** Test for Bug 639720 */
     23 SimpleTest.waitForExplicitFinish();
     24 
     25 var BASE_URI = "http://mochi.test:8888/tests/dom/tests/mochitest/dom-level0/";
     26 var tests = [
     27 { url: BASE_URI + "iframe1_location_setters.html" },
     28 { url: BASE_URI + "iframe2_location_setters.html",
     29   useDocument: true },
     30 { prepURL: "http://www.example.com",
     31   url: BASE_URI + "iframe3_location_setters.html" }
     32 ];
     33 
     34 var currentTest = 0;
     35 
     36 function checkTest() {
     37  is($("f").contentWindow.location.href, tests[currentTest].url,
     38     "href of content window's location should match url of current test");
     39  ++currentTest;
     40  runNextTest();
     41 }
     42 
     43 function runCurrentTest() {
     44  var test = tests[currentTest];
     45  $("f").onload = checkTest;
     46  if (test.useDocument) {
     47    $("f").contentDocument.location = test.url;
     48  } else {
     49    $("f").contentWindow.location = test.url;
     50  }
     51  is(typeof($("f").contentWindow.location), "object",
     52     "Location should not have become string");
     53 }
     54 
     55 function prepComplete() {
     56  runCurrentTest();
     57 }
     58 
     59 function runNextTest() {
     60  if (currentTest == tests.length) {
     61    SimpleTest.finish();
     62    return;
     63  }
     64 
     65  var test = tests[currentTest];
     66  if ("prepURL" in test) {
     67    $("f").onload = prepComplete;
     68    $("f").src = test.prepURL;
     69    return;
     70  }
     71 
     72  runCurrentTest();
     73 }
     74 
     75 addLoadEvent(runNextTest);
     76 </script>
     77 </pre>
     78 </body>
     79 </html>