summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/Attr/script-tests/access-after-element-destruction.js
blob: 91588a304e771957ca6c1c1eb231c95126dada5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
description("Tests that accessing Attr after its Element has been destroyed works without crashing.");

function gc()
{
    if (window.GCController)
        return GCController.collect();

    // Trigger garbage collection indirectly.
    for (var i = 0; i < 100000; i++)
        new String(i);
}

var element = document.createElement("p");
element.setAttribute("a", "b");
var attributes = element.attributes;
element = null;

gc();

shouldBe("attributes.length", "1");
shouldBe("attributes[0]", "attributes.item(0)");
shouldBe("attributes.getNamedItem('a')", "attributes.item(0)");

shouldBe("attributes.item(0).name", "'a'");
shouldBe("attributes.item(0).specified", "true");
shouldBe("attributes.item(0).value", "'b'");
shouldBe("attributes.item(0).ownerElement.tagName", "'P'");
shouldBe("attributes.item(0).style", "null");

attributes.item(0).value = 'c';

shouldBe("attributes.item(0).value", "'c'");

attributes.removeNamedItem('a');

shouldBe("attributes.length", "0");

element = document.createElement("p");
element.setAttribute("a", "b");
var attr = element.attributes.item(0);
element = null;

gc();

shouldBe("attr.name", "'a'");
shouldBe("attr.specified", "true");
shouldBe("attr.value", "'b'");
shouldBe("attr.ownerElement.tagName", "'P'");
shouldBe("attr.style", "null");

attr.value = 'c';

shouldBe("attr.value", "'c'");

var successfullyParsed = true;