1 description("Tests that accessing Attr after its Element has been destroyed works without crashing."); 2 3 function gc() 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 13 var element = document.createElement("p"); 14 element.setAttribute("a", "b"); 15 var attributes = element.attributes; 16 element = null; 17 18 gc(); 19 20 shouldBe("attributes.length", "1"); 21 shouldBe("attributes[0]", "attributes.item(0)"); 22 shouldBe("attributes.getNamedItem('a')", "attributes.item(0)"); 23 24 shouldBe("attributes.item(0).name", "'a'"); 25 shouldBe("attributes.item(0).specified", "true"); 26 shouldBe("attributes.item(0).value", "'b'"); 27 shouldBe("attributes.item(0).ownerElement.tagName", "'P'"); 28 29 attributes.item(0).value = 'c'; 30 31 shouldBe("attributes.item(0).value", "'c'"); 32 33 attributes.removeNamedItem('a'); 34 35 shouldBe("attributes.length", "0"); 36 37 element = document.createElement("p"); 38 element.setAttribute("a", "b"); 39 var attr = element.attributes.item(0); 40 element = null; 41 42 gc(); 43 44 shouldBe("attr.name", "'a'"); 45 shouldBe("attr.specified", "true"); 46 shouldBe("attr.value", "'b'"); 47 shouldBe("attr.ownerElement.tagName", "'P'"); 48 49 attr.value = 'c'; 50 51 shouldBe("attr.value", "'c'"); 52 53 var successfullyParsed = true; 54