tor-browser

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

indexed-browsing-contexts-01.html (2211B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>HTML Test: the browsing contexts must be sorted in the order that their containers were inserted into the Document</title>
      4 <link rel="author" title="Intel" href="http://www.intel.com/" />
      5 <link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/browsers.html#accessing-other-browsing-contexts" />
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <div id="log"></div>
      9 <script>
     10 
     11 var t1 = async_test("The window's length must return the number of child browsing contexts(in iframe)");
     12 function on_load1(fr) {
     13  t1.step(function () {
     14    var doc = fr.contentDocument;
     15    var fr3 = doc.createElement("iframe");
     16    fr3.setAttribute("id", "fr3");
     17    doc.body.insertBefore(fr3, doc.getElementById("tbl"));
     18 
     19    assert_equals(fr.contentWindow.length, 3, "The window.length should be 3.");
     20    assert_array_equals([fr.contentWindow[0].frameElement, fr.contentWindow[1].frameElement, fr.contentWindow[2].frameElement],
     21                        [fr.contentDocument.getElementById("fr4"), fr.contentDocument.getElementById("fr5"), fr.contentDocument.getElementById("fr3")],
     22                        "The child browsing contexts must be sorted in the order that their containers were inserted into the Document.");
     23  });
     24  t1.done();
     25 }
     26 
     27 var t2 = async_test("The window's length must return zero if it has no child browsing context");
     28 function on_load2(fr) {
     29  t2.step(function () {
     30    assert_equals(fr.contentWindow.length, 0, "The window.length should be 0.");
     31  });
     32  t2.done();
     33 }
     34 
     35 </script>
     36 <iframe id="fr1" src="test1.html" style="display:none" onload="on_load1(this)"></iframe>
     37 <iframe id="fr2" src="test2.html" style="display:none" onload="on_load2(this)"></iframe>
     38 <script>
     39 
     40 test(function () {
     41  assert_equals(window.length, 2, "The window.length should be 2.");
     42  assert_array_equals([window[0].frameElement, window[1].frameElement],
     43                      [document.getElementById("fr1"), document.getElementById("fr2")],
     44                     "The child browsing contexts must be sorted in the tree order.");
     45 }, "The window's length must return the number of child browsing contexts");
     46 
     47 </script>