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