tor-browser

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

006.xml (1703B)


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