OLD | NEW |
1 <html><head> | 1 <html><head> |
2 <script> | 2 <script> |
3 if (window.testRunner) | 3 if (window.testRunner) |
4 testRunner.dumpAsText(); | 4 testRunner.dumpAsText(); |
5 | 5 |
6 var types = [ | 6 var types = [ |
7 XPathResult.ORDERED_NODE_ITERATOR_TYPE, | 7 XPathResult.ORDERED_NODE_ITERATOR_TYPE, |
8 XPathResult.UNORDERED_NODE_ITERATOR_TYPE | 8 XPathResult.UNORDERED_NODE_ITERATOR_TYPE |
9 ]; | 9 ]; |
10 | 10 |
11 function gc() | 11 function gc() |
12 { | 12 { |
13 if (window.GCController) | 13 if (window.GCController) |
14 return GCController.collect(); | 14 return GCController.collect(); |
15 | 15 |
16 for (var i = 0; i < 10000; i++) { // > force garbage collection (FF
requires about 9K allocations before a collect) | 16 for (var i = 0; i < 10000; i++) { // > force garbage collection (FF
requires about 9K allocations before a collect) |
17 var s = new String("abc"); | 17 var s = new String("abc"); |
18 } | 18 } |
19 } | 19 } |
20 | 20 |
21 function test(type) | 21 function test(type) |
22 { | 22 { |
23 var doc = (new DOMParser).parseFromString("<html><body><span></span>
</body></html>", "text/xml"); | 23 var doc, result; |
24 doc.getElementsByTagName("span")[0].foo = "PASS"; | 24 function initialize() { |
25 var result = doc.evaluate("//span", doc.documentElement, null, type,
null); | 25 doc = (new DOMParser).parseFromString("<html><body><span></span></
body></html>", "text/xml"); |
26 doc = 0; | 26 doc.getElementsByTagName("span")[0].foo = "PASS"; |
| 27 result = doc.evaluate("//span", doc.documentElement, null, type, n
ull); |
| 28 doc = 0; |
| 29 } |
| 30 |
| 31 // Do initialization work in an inner function to avoid references |
| 32 // to objects remaining live on this function's stack frame |
| 33 // (http://crbug.com/595672/). |
| 34 initialize(); |
27 gc(); | 35 gc(); |
28 var console = document.getElementById("console"); | 36 var console = document.getElementById("console"); |
29 console.appendChild(document.createTextNode(result.iterateNext().foo
)); | 37 console.appendChild(document.createTextNode(result.iterateNext().foo
)); |
30 console.appendChild(document.createElement("br")); | 38 console.appendChild(document.createElement("br")); |
31 } | 39 } |
32 | 40 |
33 function tests() | 41 function tests() |
34 { | 42 { |
35 while (types.length) { | 43 while (types.length) { |
36 test(types.pop()); | 44 test(types.pop()); |
37 } | 45 } |
38 } | 46 } |
39 </script> | 47 </script> |
40 </head> | 48 </head> |
41 <body onload="tests()"> | 49 <body onload="tests()"> |
42 <div> Test for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=34231">34231
</a>: Nodes in XPathResult should keep JS wrappers alive.</div> | 50 <div> Test for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=34231">34231
</a>: Nodes in XPathResult should keep JS wrappers alive.</div> |
43 <div> For this test to PASS you should see 2 PASS below.</div><br> | 51 <div> For this test to PASS you should see 2 PASS below.</div><br> |
44 <div id="console"></div> | 52 <div id="console"></div> |
45 </body></html> | 53 </body></html> |
OLD | NEW |