tor-browser

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

007.xml (1914B)


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