tor-browser

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

005.xml (2020B)


      1 <html xmlns="http://www.w3.org/1999/xhtml">
      2 <head>
      3  <title>DOM Traversal: NodeIterator: Removal of the Reference Node (deep check)</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      var X = addChildTo(AA);
     20      check(iterator.nextNode(), X);
     21      check(iterator.previousNode(), X);
     22      remove(X);
     23      var Y = addChildTo(AA);
     24      check(iterator.previousNode(), Y);
     25      if (errors)
     26        document.getElementById('result').firstChild.data = 'FAIL: ' + errors + ' errors:\n' + log;
     27      else
     28        document.getElementById('result').firstChild.data = 'PASS';
     29    }
     30    function check(a, b) {
     31      if (!a) {
     32        errors += 1;
     33        log += 'Found null but expected ' + b + ' (' + b.id + ').\n';
     34      } else if (a != b) {
     35        errors += 1;
     36        log += 'Found ' + a + ' (' + a.id + ') but expected ' + b + ' (' + b.id + ').\n';
     37      }
     38    }
     39    function remove(a) {
     40      if (!a) {
     41        errors += 1;
     42        log += 'Tried removing null node.\n';
     43      } else
     44      a.parentNode.removeChild(a);
     45    }
     46    function addChildTo(a) {
     47      var x = document.createElementNS('http://www.w3.org/1999/xhtml', 'span');
     48      a.appendChild(x);
     49      return x;
     50    }
     51  ]]></script>
     52 </head>
     53 <body onload="doTest()">
     54  <pre id="result">FAIL: Script did not complete.</pre>
     55  <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>
     56 </body>
     57 </html>