summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/Attr
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/fast/dom/Attr')
-rw-r--r--LayoutTests/fast/dom/Attr/access-after-element-destruction-expected.txt25
-rw-r--r--LayoutTests/fast/dom/Attr/access-after-element-destruction.html13
-rw-r--r--LayoutTests/fast/dom/Attr/child-nodes-cache-expected.txt3
-rw-r--r--LayoutTests/fast/dom/Attr/child-nodes-cache.html38
-rw-r--r--LayoutTests/fast/dom/Attr/child-nodes-length-cache-expected.txt3
-rw-r--r--LayoutTests/fast/dom/Attr/child-nodes-length-cache.html38
-rw-r--r--LayoutTests/fast/dom/Attr/script-tests/TEMPLATE.html13
-rw-r--r--LayoutTests/fast/dom/Attr/script-tests/access-after-element-destruction.js55
8 files changed, 188 insertions, 0 deletions
diff --git a/LayoutTests/fast/dom/Attr/access-after-element-destruction-expected.txt b/LayoutTests/fast/dom/Attr/access-after-element-destruction-expected.txt
new file mode 100644
index 0000000..8c09132
--- /dev/null
+++ b/LayoutTests/fast/dom/Attr/access-after-element-destruction-expected.txt
@@ -0,0 +1,25 @@
+Tests that accessing Attr after its Element has been destroyed works without crashing.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS attributes.length is 1
+PASS attributes[0] is attributes.item(0)
+PASS attributes.getNamedItem('a') is attributes.item(0)
+PASS attributes.item(0).name is 'a'
+PASS attributes.item(0).specified is true
+PASS attributes.item(0).value is 'b'
+PASS attributes.item(0).ownerElement.tagName is 'P'
+PASS attributes.item(0).style is null
+PASS attributes.item(0).value is 'c'
+PASS attributes.length is 0
+PASS attr.name is 'a'
+PASS attr.specified is true
+PASS attr.value is 'b'
+PASS attr.ownerElement.tagName is 'P'
+PASS attr.style is null
+PASS attr.value is 'c'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Attr/access-after-element-destruction.html b/LayoutTests/fast/dom/Attr/access-after-element-destruction.html
new file mode 100644
index 0000000..39e014d
--- /dev/null
+++ b/LayoutTests/fast/dom/Attr/access-after-element-destruction.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/access-after-element-destruction.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/Attr/child-nodes-cache-expected.txt b/LayoutTests/fast/dom/Attr/child-nodes-cache-expected.txt
new file mode 100644
index 0000000..9976b12
--- /dev/null
+++ b/LayoutTests/fast/dom/Attr/child-nodes-cache-expected.txt
@@ -0,0 +1,3 @@
+PASS
+
+
diff --git a/LayoutTests/fast/dom/Attr/child-nodes-cache.html b/LayoutTests/fast/dom/Attr/child-nodes-cache.html
new file mode 100644
index 0000000..7805946
--- /dev/null
+++ b/LayoutTests/fast/dom/Attr/child-nodes-cache.html
@@ -0,0 +1,38 @@
+<body onload="test()">
+<p>Running test...</p>
+<textarea id=t rows=20>textarea</textarea>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function gc()
+{
+ if (window.GCController)
+ return GCController.collect();
+
+ for (var i = 0; i < 10000; i++) { // > force garbage collection (FF requires about 9K allocations before a collect)
+ var s = new String("abc");
+ }
+}
+
+function test()
+{
+ var elem = document.getElementById("t");
+ var nodes = document.getElementById("t").getAttributeNode('rows').childNodes;
+ nodes[0]; // Prime the child node cache.
+ document.body.removeChild(document.getElementById("t"));
+ elem.getAttributeNode('rows').removeChild(nodes[0]);
+ setTimeout(function() {
+ gc();
+ gc();
+ gc();
+ try { nodes[0].textContent } catch (ex) { }
+
+ document.getElementsByTagName("p")[0].innerHTML = "PASS"
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }, 0);
+}
+</script>
diff --git a/LayoutTests/fast/dom/Attr/child-nodes-length-cache-expected.txt b/LayoutTests/fast/dom/Attr/child-nodes-length-cache-expected.txt
new file mode 100644
index 0000000..b253fa1
--- /dev/null
+++ b/LayoutTests/fast/dom/Attr/child-nodes-length-cache-expected.txt
@@ -0,0 +1,3 @@
+Test for bug 19759: ChildNodeList for an attribute node is not properly invalidated after appending a child.
+
+Passed!!
diff --git a/LayoutTests/fast/dom/Attr/child-nodes-length-cache.html b/LayoutTests/fast/dom/Attr/child-nodes-length-cache.html
new file mode 100644
index 0000000..5c09794
--- /dev/null
+++ b/LayoutTests/fast/dom/Attr/child-nodes-length-cache.html
@@ -0,0 +1,38 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function onLoad()
+{
+ var theDiv = document.getElementById("theDiv");
+ var theAttrs = theDiv.attributes;
+
+ var nameAttr = theAttrs.getNamedItem("name");
+ var nameAttrChildNodes = nameAttr.childNodes;
+ var textNode = document.createTextNode("terday");
+ var unused = nameAttrChildNodes.length;
+ nameAttr.appendChild(textNode);
+
+ var name2Attr = theAttrs.getNamedItem("name2");
+ var name2AttrChildNodes = name2Attr.childNodes;
+ var textNode2 = document.createTextNode("terday");
+ name2Attr.appendChild(textNode2);
+
+ if (nameAttrChildNodes.length != name2AttrChildNodes.length)
+ document.getElementById("result").innerHTML = "Failed: nameAttrChildNodes.length=" + nameAttrChildNodes.length + ", name2AttrChildNodes.length=" + name2AttrChildNodes.length;
+ else
+ document.getElementById("result").innerHTML = "Passed!!";
+
+ document.body.removeChild(document.getElementById("theDiv"));
+}
+</script>
+</head>
+<body onload="onLoad();">
+<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=19759">bug 19759</a>:
+ChildNodeList for an attribute node is not properly invalidated after appending a child.</p>
+<div id="theDiv" name="Yes" name2="Yes">Hello</div>
+<div id="result">Testing...</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/Attr/script-tests/TEMPLATE.html b/LayoutTests/fast/dom/Attr/script-tests/TEMPLATE.html
new file mode 100644
index 0000000..1951c43
--- /dev/null
+++ b/LayoutTests/fast/dom/Attr/script-tests/TEMPLATE.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="YOUR_JS_FILE_HERE"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/Attr/script-tests/access-after-element-destruction.js b/LayoutTests/fast/dom/Attr/script-tests/access-after-element-destruction.js
new file mode 100644
index 0000000..91588a3
--- /dev/null
+++ b/LayoutTests/fast/dom/Attr/script-tests/access-after-element-destruction.js
@@ -0,0 +1,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;