1 <html xmlns="http://www.w3.org/1999/xhtml">
3 https://bugzilla.mozilla.org/show_bug.cgi?id=311681
6 <title>Test for Bug 311681</title>
7 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
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">
15 SimpleTest.waitForExplicitFinish();
17 // Make sure to trigger the hashtable case by asking for enough elements
19 for (var i = 0; i < 256; ++i) {
20 var x = document.getElementById(i);
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"
31 return fun.call(document, "content");
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
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 orig 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");
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");
79 function clear(node) {
80 while (node.hasChildNodes()) {
81 node.removeChild(node.firstChild);
85 addLoadEvent(testClone);
86 addLoadEvent(SimpleTest.finish);
90 <div id="content" style="display: none">
91 <script class="testbody" type="text/javascript">
93 testNode = fun.call(document, "content");
94 // Needs incremental XML parser
95 isnot(testNode, null, "Should have node here");