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