| OLD | NEW |
| 1 description("Tests that accessing Attr after its Element has been destroyed work
s without crashing."); | 1 description("Tests that accessing Attr after its Element has been destroyed work
s without crashing."); |
| 2 | 2 |
| 3 function gc() | 3 jsTestIsAsync = true; |
| 4 { | |
| 5 if (window.GCController) | |
| 6 return GCController.collect(); | |
| 7 | |
| 8 // Trigger garbage collection indirectly. | |
| 9 for (var i = 0; i < 100000; i++) | |
| 10 new String(i); | |
| 11 } | |
| 12 | 4 |
| 13 var element = document.createElement("p"); | 5 var element = document.createElement("p"); |
| 14 element.setAttribute("a", "b"); | 6 element.setAttribute("a", "b"); |
| 15 var attributes = element.attributes; | 7 var attributes = element.attributes; |
| 16 element = null; | 8 element = null; |
| 9 var attr = null; |
| 17 | 10 |
| 18 gc(); | 11 asyncGC(function() { |
| 12 shouldBe("attributes.length", "1"); |
| 13 shouldBe("attributes[0]", "attributes.item(0)"); |
| 14 shouldBe("attributes.getNamedItem('a')", "attributes.item(0)"); |
| 19 | 15 |
| 20 shouldBe("attributes.length", "1"); | 16 shouldBe("attributes.item(0).name", "'a'"); |
| 21 shouldBe("attributes[0]", "attributes.item(0)"); | 17 shouldBe("attributes.item(0).value", "'b'"); |
| 22 shouldBe("attributes.getNamedItem('a')", "attributes.item(0)"); | |
| 23 | 18 |
| 24 shouldBe("attributes.item(0).name", "'a'"); | 19 attributes.item(0).value = 'c'; |
| 25 shouldBe("attributes.item(0).value", "'b'"); | |
| 26 | 20 |
| 27 attributes.item(0).value = 'c'; | 21 shouldBe("attributes.item(0).value", "'c'"); |
| 28 | 22 |
| 29 shouldBe("attributes.item(0).value", "'c'"); | 23 attributes.removeNamedItem('a'); |
| 30 | 24 |
| 31 attributes.removeNamedItem('a'); | 25 shouldBe("attributes.length", "0"); |
| 32 | 26 |
| 33 shouldBe("attributes.length", "0"); | 27 element = document.createElement("p"); |
| 28 element.setAttribute("a", "b"); |
| 29 attr = element.attributes.item(0); |
| 30 element = null; |
| 34 | 31 |
| 35 element = document.createElement("p"); | 32 asyncGC(function() { |
| 36 element.setAttribute("a", "b"); | |
| 37 var attr = element.attributes.item(0); | |
| 38 element = null; | |
| 39 | 33 |
| 40 gc(); | 34 shouldBe("attr.name", "'a'"); |
| 35 shouldBe("attr.value", "'b'"); |
| 41 | 36 |
| 42 shouldBe("attr.name", "'a'"); | 37 attr.value = 'c'; |
| 43 shouldBe("attr.value", "'b'"); | |
| 44 | 38 |
| 45 attr.value = 'c'; | 39 shouldBe("attr.value", "'c'"); |
| 46 | 40 |
| 47 shouldBe("attr.value", "'c'"); | 41 finishJSTest(); |
| 42 }); |
| 43 }); |
| OLD | NEW |