tor-browser

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

004.xml (1753B)


      1 <html xmlns="http://www.w3.org/1999/xhtml">
      2 <head>
      3  <title>DOM Traversal: NodeIterator: Removal of the Reference Node</title>
      4  <script type="text/javascript"> <![CDATA[
      5    var errors = 0;
      6    var log = '';
      7    function doTest() {
      8      var iterator = document.createNodeIterator(document.getElementById('root'), NodeFilter.SHOW_ALL, null, false);
      9      var root = document.getElementById('root');
     10      var A = document.getElementById('A');
     11      var AA = document.getElementById('AA');
     12      var B = document.getElementById('B');
     13      var C = document.getElementById('C');
     14      check(iterator.nextNode(), root);
     15      check(iterator.nextNode(), A);
     16      check(iterator.nextNode(), AA);
     17      check(iterator.nextNode(), B);
     18      remove(B);
     19      check(iterator.previousNode(), AA);
     20      remove(AA);
     21      check(iterator.nextNode(), C);
     22      if (errors)
     23        document.getElementById('result').firstChild.data = 'FAIL: ' + errors + ' errors:\n' + log;
     24      else
     25        document.getElementById('result').firstChild.data = 'PASS';
     26    }
     27    function check(a, b) {
     28      if (!a) {
     29        errors += 1;
     30        log += 'Found null but expected ' + b + ' (' + b.id + ').\n';
     31      } else if (a != b) {
     32        errors += 1;
     33        log += 'Found ' + a + ' (' + a.id + ') but expected ' + b + ' (' + b.id + ').\n';
     34      }
     35    }
     36    function remove(a) {
     37      if (!a) {
     38        errors += 1;
     39        log += 'Tried removing null node.\n';
     40      } else
     41      a.parentNode.removeChild(a);
     42    }
     43  ]]></script>
     44 </head>
     45 <body onload="doTest()">
     46  <pre id="result">FAIL: Script did not complete.</pre>
     47  <p><span id="root"><span id="A"><span id="AA"></span></span><span id="B"></span><span id="C"><span id="CC"></span></span></span></p>
     48 </body>
     49 </html>