tor-browser

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

test_getElementsByName_after_mutation.html (1562B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1376695
      5 -->
      6 <head>
      7  <title>Test for Bug 1376695</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=1376695">Mozilla Bug 1376695</a>
     13 <p id="display"></p>
     14 <div id="originalFoo" name="foo">
     15 <pre id="test">
     16 <script type="application/javascript">
     17 
     18 /**
     19  * Test to ensure that the list returned by getElementsByName is updated after
     20  * mutations.
     21  */
     22 
     23 var fooList = document.getElementsByName("foo");
     24 var originalDiv = document.getElementById("originalFoo");
     25 
     26 is(fooList.length, 1, "Should find one element with name 'foo' initially");
     27 is(fooList[0], originalDiv, "Element should be the original div");
     28 
     29 var newTree = document.createElement("p");
     30 var child1 = document.createElement("div");
     31 var child2 = document.createElement("div");
     32 child2.setAttribute("name", "foo");
     33 
     34 newTree.appendChild(child1);
     35 newTree.appendChild(child2);
     36 document.body.appendChild(newTree);
     37 
     38 is(fooList.length, 2,
     39   "Should find two elements with name 'foo' after appending the new tree");
     40 is(fooList[1], child2, "Element should be the new appended div with name 'foo'");
     41 
     42 document.body.removeChild(newTree);
     43 
     44 is(fooList.length, 1,
     45   "Should find one element with name 'foo' after removing the new tree");
     46 is(fooList[0], originalDiv,
     47   "Element should be the original div after removing the new tree");
     48 
     49 </script>
     50 </pre>
     51 </body>
     52 </html>