tor-browser

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

test_bug311681.xhtml (2971B)


      1 <html xmlns="http://www.w3.org/1999/xhtml">
      2 <!--
      3 https://bugzilla.mozilla.org/show_bug.cgi?id=311681
      4 -->
      5 <head>
      6  <title>Test for Bug 311681</title>
      7  <script src="/tests/SimpleTest/SimpleTest.js"></script>        
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      9 </head>
     10 <body>
     11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=311681">Mozilla Bug 311681</a>
     12 <script class="testbody" type="text/javascript">
     13 <![CDATA[
     14  // Setup script
     15  SimpleTest.waitForExplicitFinish();
     16 
     17  // Make sure to trigger the hashtable case by asking for enough elements
     18  // by ID.
     19  for (var i = 0; i < 256; ++i) {
     20    var x = document.getElementById(i);
     21  }
     22 
     23  // save off the document.getElementById function, since getting it as a
     24  // property off the document it causes a content flush.      
     25  var fun = document.getElementById;
     26 
     27  // Slot for our initial element with id "content"
     28  var testNode;
     29 
     30  function getCont() {
     31    return fun.call(document, "content");
     32  }
     33  
     34  function testClone() {
     35    // Test to make sure that if we have multiple nodes with the same ID in
     36    // a document we don't forget about one of them when the other is
     37    // removed.
     38    var newParent = $("display");
     39    var node = testNode.cloneNode(true);
     40    isnot(node, testNode, "Clone should be a different node");
     41 
     42    newParent.appendChild(node);
     43 
     44    // Check what getElementById returns, no flushing
     45    is(getCont(), node, "Should be getting new node pre-flush 1");
     46    
     47    // Trigger a layout flush, just in case.
     48    var itemHeight = newParent.offsetHeight/10;
     49 
     50    // Check what getElementById returns now.
     51    is(getCont(), node, "Should be getting new node post-flush 1");
     52    
     53    clear(newParent);
     54    
     55    // Check what getElementById returns, no flushing
     56    is(getCont(), testNode, "Should be getting orig node pre-flush 2");
     57    
     58    // Trigger a layout flush, just in case.
     59    var itemHeight = newParent.offsetHeight/10;
     60 
     61    // Check what getElementById returns now.
     62    is(getCont(), testNode, "Should be getting orig node post-flush 2");
     63 
     64    node = testNode.cloneNode(true);
     65    newParent.appendChild(node);
     66    testNode.remove();
     67 
     68    // Check what getElementById returns, no flushing
     69    is(getCont(), node, "Should be getting clone pre-flush");
     70    
     71    // Trigger a layout flush, just in case.
     72    var itemHeight = newParent.offsetHeight/10;
     73 
     74    // Check what getElementById returns now.
     75    is(getCont(), node, "Should be getting clone post-flush");
     76 
     77  }
     78 
     79  function clear(node) {
     80    while (node.hasChildNodes()) {
     81      node.firstChild.remove();
     82    }
     83  }
     84 
     85  addLoadEvent(testClone);
     86  addLoadEvent(SimpleTest.finish);
     87 ]]>
     88 </script>
     89 <p id="display"></p>
     90 <div id="content" style="display: none">
     91  <script class="testbody" type="text/javascript">
     92  <![CDATA[
     93    testNode = fun.call(document, "content");
     94    ok(testNode != null, "Should have node here");
     95  ]]>
     96  </script>  
     97 </div>
     98 <pre id="test">
     99 </pre>
    100 </body>
    101 </html>