diff options
Diffstat (limited to 'LayoutTests/fast/dom/NodeList')
25 files changed, 505 insertions, 0 deletions
diff --git a/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-1-expected.txt b/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-1-expected.txt new file mode 100644 index 0000000..c5b8ca4 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-1-expected.txt @@ -0,0 +1,3 @@ +Test for (rdar://problem/5725058). If you see this text, then all is well and no crash has occurred. + + diff --git a/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-1.html b/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-1.html new file mode 100644 index 0000000..19d08d7 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-1.html @@ -0,0 +1,25 @@ +<p>Test for (rdar://problem/5725058). If you see this text, then all is well and no crash has occurred.</p> + +<span> + <div name='test'></div> +</span> +<script type='text/javascript'> + if (window.layoutTestController) + layoutTestController.dumpAsText(); + + function triggerGarbageCollection() + { + if (window.GCController) { + GCController.collect(); + return; + } + for (var i = 0; i < 10000; ++i) + ({}) + } + + document.getElementsByName('test')[0]; + triggerGarbageCollection(); + document.getElementsByTagName('span')[0].innerHTML = ''; + triggerGarbageCollection(); + document.getElementsByName('test')[0]; +</script> diff --git a/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-2-expected.txt b/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-2-expected.txt new file mode 100644 index 0000000..38de29a --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-2-expected.txt @@ -0,0 +1,3 @@ +Test for (rdar://problem/5725058). If you see this text, then all is well and no crash has occurred. + +paragraph b diff --git a/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-2.html b/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-2.html new file mode 100644 index 0000000..147b2df --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-2.html @@ -0,0 +1,42 @@ +<p>Test for (rdar://problem/5725058). If you see this text, then all is well and no crash has occurred.</p> + +<p id="a">paragraph a</p> +<p id="b">paragraph b</p> +<script> +if (window.layoutTestController) + layoutTestController.dumpAsText(); + +function triggerGarbageCollection() +{ + if (window.GCController) { + GCController.collect(); + return; + } + for (var i = 0; i < 10000; ++i) + ({}) +} + +function setUp() +{ + // This only works if in a function. I'm not sure why. + + // Get node and length from paragraph A into the cache. + document.getElementById("a").childNodes[0]; + document.getElementById("a").childNodes.length; +} + +setUp(); + +// Get back to "zero node lists". +triggerGarbageCollection(); + +// Remove the child node of paragraph A. Use innerHTML to avoid getting a reference to the node being removed. +document.getElementById("a").innerHTML = ""; + +// Get back to "one node list". +var childNodesB = document.getElementById("b").childNodes; + +// Now try the original list. +var x = document.getElementById("a").childNodes[0]; +x = document.getElementById("a").childNodes.length; +</script> diff --git a/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-3-expected.txt b/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-3-expected.txt new file mode 100644 index 0000000..c5b8ca4 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-3-expected.txt @@ -0,0 +1,3 @@ +Test for (rdar://problem/5725058). If you see this text, then all is well and no crash has occurred. + + diff --git a/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-3.html b/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-3.html new file mode 100644 index 0000000..e3b8d61 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-3.html @@ -0,0 +1,18 @@ +<p>Test for (rdar://problem/5725058). If you see this text, then all is well and no crash has occurred.</p> + +<p id="a"><a name="anchor">paragraph a</a></p> +<script> +if (window.layoutTestController) + layoutTestController.dumpAsText(); + +var list = document.getElementsByName("anchor"); +var x = list.length +x = list[0]; + +// Remove the child node of paragraph A. Use innerHTML to avoid getting a reference to the node being removed. +document.getElementById("a").innerHTML = ""; + +// Now try the original list. +x = list.length; +x = list[0]; +</script> diff --git a/LayoutTests/fast/dom/NodeList/adoptNode-node-list-cache-expected.txt b/LayoutTests/fast/dom/NodeList/adoptNode-node-list-cache-expected.txt new file mode 100644 index 0000000..5818178 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/adoptNode-node-list-cache-expected.txt @@ -0,0 +1,2 @@ + +TEST PASSED - Unless an assertion or crash happens soon. diff --git a/LayoutTests/fast/dom/NodeList/adoptNode-node-list-cache.html b/LayoutTests/fast/dom/NodeList/adoptNode-node-list-cache.html new file mode 100644 index 0000000..376adb4 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/adoptNode-node-list-cache.html @@ -0,0 +1,56 @@ +<head> +<script> + +var pageHasLoaded = false; +var frameHasLoaded = false; + +function gc() +{ + if (window.GCController) + return GCController.collect(); + + for (var i = 0; i < 10000; i++) + var s = new String(""); +} + +function pageLoaded() +{ + if (window.layoutTestController) + layoutTestController.waitUntilDone(); + + pageHasLoaded = true; + if (pageHasLoaded && frameHasLoaded) + runTest(); +} + +function frameLoaded() +{ + frameHasLoaded = true; + if (pageHasLoaded && frameHasLoaded) + runTest(); +} + +function runTest() +{ + if (window.layoutTestController) + layoutTestController.dumpAsText(); + + var frame = document.getElementById("frame"); + frame.setAttribute("onload", "frameLoadedAgain()"); + frame.setAttribute("src", "about:blank"); +} + +function frameLoadedAgain() +{ + gc(); + document.getElementById("result").firstChild.data = "TEST PASSED - Unless an assertion or crash happens soon."; + if (window.layoutTestController) + layoutTestController.notifyDone(); +} + +</script> +</head> +<body onload="pageLoaded()"> +<iframe id="frame" src="resources/adoptNode-node-list-cache-subframe.html" onload="frameLoaded()"></iframe> +<div id="result">TEST DID NOT RUN YET</div> +</body> diff --git a/LayoutTests/fast/dom/NodeList/childNodes-reset-cache-expected.txt b/LayoutTests/fast/dom/NodeList/childNodes-reset-cache-expected.txt new file mode 100644 index 0000000..df04fba --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/childNodes-reset-cache-expected.txt @@ -0,0 +1,3 @@ +Test for bug 13514: REGRESSION (r20997-21003): Crash in WebCore::Node::Document. + +SUCCESS diff --git a/LayoutTests/fast/dom/NodeList/childNodes-reset-cache.html b/LayoutTests/fast/dom/NodeList/childNodes-reset-cache.html new file mode 100644 index 0000000..de47e39 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/childNodes-reset-cache.html @@ -0,0 +1,36 @@ +<html> +<body> +<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=13514">bug 13514</a>: +REGRESSION (r20997-21003): Crash in WebCore::Node::Document.</p> +<div id="elem"><p></p></div> + +<script> +if (window.layoutTestController) + layoutTestController.dumpAsText(); + +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(""); + } +} + +elem = document.getElementById('elem'); + +elem.childNodes.length; +elem.childNodes[0].length; +gc(); +elem.innerHTML = ""; +gc(); +elem.childNodes[0]; +if (elem.childNodes.length == 0) + document.write("SUCCESS"); +else + document.write("FAILURE: childNodes.length was cached inappropriately"); + +</script> +</body> +</html> diff --git a/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing-expected.txt b/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing-expected.txt new file mode 100644 index 0000000..f1c8c04 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing-expected.txt @@ -0,0 +1,10 @@ +This test checks to see if the DOM ContainerNode's NodeList cache is correctly invalidated when new content is parsed. + +If the test passes, you should see "before: not found", "after: found" and "onload: found". + +If the cache is not invalidated when the testElement is parsed, both before and after will be "not found", which is a failure. + +before: not found +after: found +onload: found + diff --git a/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html b/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html new file mode 100644 index 0000000..c4397dd --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html @@ -0,0 +1,77 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <title>5360748</title> + + <script type="text/javascript"> + if (window.layoutTestController) + layoutTestController.dumpAsText(); + + function print(message) + { + var paragraph = document.createElement("li"); + paragraph.appendChild(document.createTextNode(message)); + document.getElementById("console").appendChild(paragraph); + } + + function runTest() { + result3 = testForElement("onload", "testElement2"); // expect to see "testElement2" + + // don't show the results until the tests are finished -- it changes the DOM and could affect the tests + print(result1); + print(result2); + print(result3); + } + function testForElement(testName, elementId) { + var found = containsElementWithId(document.body, elementId); + if (window.GCController) + GCController.collect(); + else { + // create lots of objects to force a garbage collection + var i = 0; + var s; + while (i < 5000) { + i = i+1.11; + s = s + " "; + } + } + + return testName + ": " + (found ? "found" : "not found"); + } + function containsElementWithId(el, id) { + var found = false; + + if (el.id == id) { + found = true; + } else { + var children = el.childNodes; + for (var i=0; !found && i < children.length; i++) + found = containsElementWithId(children[i], id); + } + + return found; + } + </script> + </head> + <body onload="runTest()"> + + <p>This test checks to see if the DOM ContainerNode's NodeList cache is correctly invalidated when new content is parsed.</p> + <p>If the test passes, you should see "before: not found", "after: found" and "onload: found".</p> + <p>If the cache is not invalidated when the testElement is parsed, both before and after will be "not found", which is a failure.</p> + <hr> + <p><ol id=console></ol></p> + + <script type="text/javascript"> + result1 = testForElement("before", "testElement"); // expect not to see "testElement" + </script> + + <p id="testElement"></p> + + <script type="text/javascript"> + result2 = testForElement("after", "testElement"); // expect to see "testElement" + </script> + + <p id="testElement2"></p> +</body> +</html> diff --git a/LayoutTests/fast/dom/NodeList/item-by-id-with-no-document-expected.txt b/LayoutTests/fast/dom/NodeList/item-by-id-with-no-document-expected.txt new file mode 100644 index 0000000..195a88f --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/item-by-id-with-no-document-expected.txt @@ -0,0 +1 @@ +SUCCESS (you didn't crash) diff --git a/LayoutTests/fast/dom/NodeList/item-by-id-with-no-document.html b/LayoutTests/fast/dom/NodeList/item-by-id-with-no-document.html new file mode 100644 index 0000000..3b272af --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/item-by-id-with-no-document.html @@ -0,0 +1,13 @@ +<title>Test case for Radar 4411663</title> +<script> +if (window.layoutTestController) + layoutTestController.dumpAsText(); +var para = document.createElement("p"); +for (var x = 0; x < 1000; x++) { + var newNode = document.createTextNode("asdf " + x); + para.appendChild(newNode); +} +var list = para.childNodes; +var bar = list["bar"]; +</script> +<p>SUCCESS (you didn't crash)</p>
\ No newline at end of file diff --git a/LayoutTests/fast/dom/NodeList/nodelist-item-assignment-expected.txt b/LayoutTests/fast/dom/NodeList/nodelist-item-assignment-expected.txt new file mode 100644 index 0000000..814b456 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/nodelist-item-assignment-expected.txt @@ -0,0 +1,23 @@ +This tests that indexed assignments to items of a NodeList do not override original values. See http://code.google.com/p/chromium/issues/detail?id=27967 + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS first == null is false +PASS nodeList[0] is first +PASS nodeList[0] is first +PASS nodeList[0] is first +PASS nodeList[0] is first +PASS nodeList[0] is first +PASS nodeList[0] is first +PASS nodeList[0] is first +PASS nodeList[0] is first +PASS nodeList[0] is first +PASS nodeList[0] is first +PASS nodeList[0] is first +PASS nodeList[0] is first +PASS nodeList[0] is first +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/NodeList/nodelist-item-assignment.html b/LayoutTests/fast/dom/NodeList/nodelist-item-assignment.html new file mode 100644 index 0000000..5a5b971 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/nodelist-item-assignment.html @@ -0,0 +1,30 @@ +<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> +<ol></ol> + +<div id="console"></div> + +<script> +description( + 'This tests that indexed assignments to items of a NodeList do not override original values. ' + + 'See http://code.google.com/p/chromium/issues/detail?id=27967'); + +var nodeList = document.getElementsByTagName('ol'); +var first = nodeList[0]; +shouldBeFalse("first == null"); + +nodeList[0] = null; +for (var i = 0; i < 13; i++) { + shouldBe("nodeList[0]", "first"); +} + +var successfullyParsed = true; +</script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt b/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt new file mode 100644 index 0000000..96549e8 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt @@ -0,0 +1,12 @@ +This tests that items in a NodeList can be retrieved directly by calling as a function with an integral index parameter, starting from 0. +It means NodeList[0] and NodeList(0) both work. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS nodeList[0] is nodeList(0) +PASS !nodeList[nodeList.length] is !nodeList(nodeList.length) +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function.html b/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function.html new file mode 100644 index 0000000..ae1cf36 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function.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/nodelist-item-call-as-function.js"></script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/NodeList/nodelist-item-with-index-expected.txt b/LayoutTests/fast/dom/NodeList/nodelist-item-with-index-expected.txt new file mode 100644 index 0000000..1c4040d --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/nodelist-item-with-index-expected.txt @@ -0,0 +1,18 @@ +This tests that items in a NodeList can be retrieved by index. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +text1 +text2 + +PASS div0 == div0s is true +PASS div0 == div0s_ is false +PASS div0 == div1 is false +PASS div0s == div0s_ is false +PASS div0s == div1 is false +PASS div0s_ == div1 is false +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/NodeList/nodelist-item-with-index.html b/LayoutTests/fast/dom/NodeList/nodelist-item-with-index.html new file mode 100644 index 0000000..369e021 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/nodelist-item-with-index.html @@ -0,0 +1,38 @@ +<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='div1'>text1</div> +<div id='div2'>text2</div><br> + +<div id="console"></div> + +<script> +description('This tests that items in a NodeList can be retrieved by index.'); + +var nodeList = document.getElementsByTagName('div'); +var div0 = nodeList[0]; +var div0s = nodeList["0"]; +var div0s_ = nodeList["0 "]; +var div1 = nodeList["1"]; + +// Getting properties 0 and "0" should get the same thing, but getting +// properties "0 " and 1 should get different items. "0 " should not +// be converted to 0, so should be undefined, and the item at index +// 1 should be defined (since there are at least two divs on the page), +// but should be a different div to the one at index 0. +shouldBeTrue("div0 == div0s"); +shouldBeFalse("div0 == div0s_"); +shouldBeFalse("div0 == div1"); +shouldBeFalse("div0s == div0s_"); +shouldBeFalse("div0s == div1"); +shouldBeFalse("div0s_ == div1"); + +var successfullyParsed = true; +</script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/NodeList/nodelist-item-with-name-expected.txt b/LayoutTests/fast/dom/NodeList/nodelist-item-with-name-expected.txt new file mode 100644 index 0000000..32ff0a7 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/nodelist-item-with-name-expected.txt @@ -0,0 +1,16 @@ +This tests that items in a NodeList can be retrieved directly by name. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +text1 +text2 + +PASS div1 instanceof HTMLDivElement is true +PASS div2 instanceof HTMLDivElement is true +PASS div1.innerHTML is 'text1' +PASS div2.innerHTML is 'text2' +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/NodeList/nodelist-item-with-name.html b/LayoutTests/fast/dom/NodeList/nodelist-item-with-name.html new file mode 100644 index 0000000..a96b51c --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/nodelist-item-with-name.html @@ -0,0 +1,30 @@ +<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='div1'>text1</div> +<div id='div2'>text2</div><br> + +<div id="console"></div> + +<script> +description('This tests that items in a NodeList can be retrieved directly by name.'); + +var NodeList = document.getElementsByTagName('div'); +var div1 = NodeList.div1; +var div2 = NodeList.div2; + +shouldBeTrue("div1 instanceof HTMLDivElement"); +shouldBeTrue("div2 instanceof HTMLDivElement"); +// Also check that the correct divs were retrieved. +shouldBe("div1.innerHTML", "'text1'"); +shouldBe("div2.innerHTML", "'text2'"); + +var successfullyParsed = true; +</script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/NodeList/resources/adoptNode-node-list-cache-subframe.html b/LayoutTests/fast/dom/NodeList/resources/adoptNode-node-list-cache-subframe.html new file mode 100644 index 0000000..46d3447 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/resources/adoptNode-node-list-cache-subframe.html @@ -0,0 +1,12 @@ +<script> +var doc = document.implementation.createHTMLDocument('a'); +var b = document.createElement('b'); +// Give it a node list cache on document +b.childNodes; + +// Attach it to doc to update m_document +doc.adoptNode(b); +doc.body.appendChild(b); +doc.body.removeChild(b); +</script> +<p>Close the document to see if there's an assertion failure.</p>
\ No newline at end of file diff --git a/LayoutTests/fast/dom/NodeList/script-tests/TEMPLATE.html b/LayoutTests/fast/dom/NodeList/script-tests/TEMPLATE.html new file mode 100644 index 0000000..1951c43 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/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/NodeList/script-tests/nodelist-item-call-as-function.js b/LayoutTests/fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js new file mode 100644 index 0000000..a12a2c9 --- /dev/null +++ b/LayoutTests/fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js @@ -0,0 +1,8 @@ +description('This tests that items in a NodeList can be retrieved directly by calling as a function with an integral index parameter, starting from 0.<br>It means NodeList[0] and NodeList(0) both work.'); + +var nodeList = document.getElementsByTagName('div'); +shouldBe("nodeList[0]", "nodeList(0)"); +shouldBe("!nodeList[nodeList.length]", "!nodeList(nodeList.length)"); + +var successfullyParsed = true; + |