OLD | NEW |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
| 5 <script src="../../resources/gc.js"></script> |
5 </head> | 6 </head> |
6 <body> | 7 <body> |
7 <script> | 8 <script> |
8 description("This tests that custom properties on element.dataset persist GC."); | 9 description("This tests that custom properties on element.dataset persist GC."); |
9 | 10 |
10 function gc() | |
11 { | |
12 if (window.GCController) | |
13 return GCController.collect(); | |
14 | |
15 for (var i = 0; i < 10000; i++) { | |
16 var s = new String(""); | |
17 } | |
18 } | |
19 | |
20 | |
21 var d = document.createElement("div"); | 11 var d = document.createElement("div"); |
22 | 12 |
23 var dataset = d.dataset; | 13 var dataset = d.dataset; |
24 // Add a property to our prototype. It will be hidden by the corresponding data-
attribute. | 14 // Add a property to our prototype. It will be hidden by the corresponding data-
attribute. |
25 dataset.__proto__.customProperty = 1; | 15 dataset.__proto__.customProperty = 1; |
26 dataset.customProperty = 1; // Now set a property on ourselves. | 16 dataset.customProperty = 1; // Now set a property on ourselves. |
27 shouldBe("d.getAttribute('data-custom-property')", "'1'"); | 17 shouldBe("d.getAttribute('data-custom-property')", "'1'"); |
28 shouldBe("d.dataset.customProperty", "'1'"); | 18 shouldBe("d.dataset.customProperty", "'1'"); |
29 | 19 |
30 dataset = null; | 20 dataset = null; |
31 | 21 |
32 gc(); | 22 gc(); |
33 | 23 |
34 // Test that the custom property persisted the GC. | 24 // Test that the custom property persisted the GC. |
35 shouldBe("d.dataset.customProperty", "'1'"); | 25 shouldBe("d.dataset.customProperty", "'1'"); |
36 </script> | 26 </script> |
37 </body> | 27 </body> |
38 </html> | 28 </html> |
OLD | NEW |