tor-browser

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

named-objects.html (3199B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>HTML Test: Named access on the Window object</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#named-access-on-the-window-object">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <div id="log"></div>
      9 <div style="display:none">
     10  <p name="a" id="p1"></p>
     11  <a name="a" id="a1" href="#"></a>
     12  <area name="a" id="area1"></area>
     13  <embed name="a" id="embed1"></embed>
     14  <form name="a" id="form1"></form>
     15  <img name="a" id="img1">
     16  <object name="a" id="obj1"></object>
     17  <span name="a" id="span1"></span>
     18 
     19  <b id="b" name="c"></b>
     20  <a name="c"></a>
     21  <iframe name="c" id="fm1"></iframe>
     22  <iframe name="c" id="fm2" src="test.html" onload="on_load()"></iframe>
     23  <input id="b"></input>
     24  <span id="d"></span>
     25  <a name=""></a>
     26  <b id=""></b>
     27 </div>
     28 <script>
     29 
     30 test(function() {
     31  assert_equals(window['c'], document.getElementById("fm1").contentWindow, "The first iframe's window should be returned.");
     32 }, "Check if the first nested browsing context is returned by window['c']");
     33 
     34 test(function() {
     35  assert_true(window['a'] instanceof HTMLCollection);
     36  assert_array_equals(window['a'],
     37                      [ document.getElementById('embed1'),
     38                        document.getElementById('form1'), document.getElementById('img1'),
     39                        document.getElementById('obj1') ],
     40                      "The elements are not in tree order.");
     41 
     42  document.getElementById('form1').setAttribute("name", "");
     43  document.getElementById('embed1').setAttribute("name", "");
     44  assert_array_equals(window['a'],
     45                      [ document.getElementById('img1'),
     46                        document.getElementById('obj1') ],
     47                      "Window['a'] should not contain the elements with empty name attribute.");
     48 }, "Check if window['a'] contains all embed, form, img, and object elements, and their order");
     49 
     50 var t = async_test("Check that window['fs'] does not return the frameset element with name='fs' (historical)");
     51 function on_load () {
     52  t.step(function () {
     53    assert_equals(document.getElementById('fm2').contentWindow['fs'],
     54                  undefined,
     55                  "The frameset element should not be returned.");
     56  });
     57  t.done();
     58 }
     59 
     60 test(function() {
     61  assert_true(window['b'] instanceof HTMLCollection);
     62  assert_array_equals(window['b'], [document.getElementsByTagName('b')[0], document.getElementsByTagName('input')[0]]);
     63 
     64  document.getElementsByTagName('b')[0].setAttribute("id", "");
     65  assert_equals(window['b'], document.getElementsByTagName('input')[0],
     66                "The window['b'] should not contain the elements with empty id attribute.");
     67 }, "Check if window['b'] returns the elements with the id='b'");
     68 
     69 test(function() {
     70  assert_equals(window['d'], document.getElementById('d'));
     71 }, "Check if window['d'] returns the element with id='d'");
     72 
     73 test(function() {
     74  assert_equals(window[''], undefined, "The window[''] should be undefined");
     75 }, "Check widow[''] when there are some elements with empty id or name attribute");
     76 </script>