content/html/document/test/test_bug311681.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=311681
     5 -->
     6 <head>
     7   <title>Test for Bug 311681</title>
     8   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    10 </head>
    11 <body>
    12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=311681">Mozilla Bug 311681</a>
    13 <script class="testbody" type="text/javascript">
    14   // Setup script
    15   SimpleTest.waitForExplicitFinish();
    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   }
    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;
    27   // Slot for our initial element with id "content"
    28   var testNode;
    30   function getCont() {
    31     return fun.call(document, "content");
    32   }
    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");
    42     newParent.appendChild(node);
    44     // Check what getElementById returns, no flushing
    45     is(getCont(), node, "Should be getting new node pre-flush 1");
    47     // Trigger a layout flush, just in case.
    48     var itemHeight = newParent.offsetHeight/10;
    50     // Check what getElementById returns now.
    51     is(getCont(), node, "Should be getting new node post-flush 1");
    53     clear(newParent);
    55     // Check what getElementById returns, no flushing
    56     is(getCont(), testNode, "Should be getting orig node pre-flush 2");
    58     // Trigger a layout flush, just in case.
    59     var itemHeight = newParent.offsetHeight/10;
    61     // Check what getElementById returns now.
    62     is(getCont(), testNode, "Should be getting orig node post-flush 2");
    64     node = testNode.cloneNode(true);
    65     newParent.appendChild(node);
    66     testNode.parentNode.removeChild(testNode);
    68     // Check what getElementById returns, no flushing
    69     is(getCont(), node, "Should be getting clone pre-flush");
    71     // Trigger a layout flush, just in case.
    72     var itemHeight = newParent.offsetHeight/10;
    74     // Check what getElementById returns now.
    75     is(getCont(), node, "Should be getting clone post-flush");
    77   }
    79   function clear(node) {
    80     while (node.hasChildNodes()) {
    81       node.removeChild(node.firstChild);
    82     }
    83   }
    85   addLoadEvent(testClone);
    86   addLoadEvent(SimpleTest.finish);
    87 </script>
    88 <p id="display"></p>
    89 <div id="content" style="display: none">
    90   <script class="testbody" type="text/javascript">
    91     testNode = fun.call(document, "content");
    92     isnot(testNode, null, "Should have node here");
    93   </script>
    94 </div>
    95 <pre id="test">
    96 </pre>
    97 </body>
    98 </html>

mercurial