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