summaryrefslogtreecommitdiffstats
path: root/dom/tests/js/lists.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/tests/js/lists.html')
-rw-r--r--dom/tests/js/lists.html68
1 files changed, 68 insertions, 0 deletions
diff --git a/dom/tests/js/lists.html b/dom/tests/js/lists.html
new file mode 100644
index 000000000..eecb345f9
--- /dev/null
+++ b/dom/tests/js/lists.html
@@ -0,0 +1,68 @@
+<html>
+<body>
+<p>This test does a few things:
+<ul>
+ <li>It has a couple of:
+ <ul>
+ <li>Images: <IMG SRC="http://zabadubop/layers/tests/mzcolor.gif" ID="foo"> and
+ <IMG SRC="http://peoplestage.netscape.com/kipp/nerdly_int.gif" NAME="kipp">.
+ <li>Links to <a href="http://home.netscape.com">Netscape</a> and
+ <A HREF="http://peoplestage.netscape.com/kipp">Kippy's Home Page</A>.
+ <li>and Anchors to <a NAME="anchor1">here</A> and
+ <A name="anchor2">here</a>.
+ </ul>
+ <li>It dumps (check the JS console) the images, links and anchors using
+ the document.images, document.links and document.anchors arrays.
+ <li>Then it removes one of the images.
+ <li>Dumps the images array again. This is to prove that the images array
+ is live.
+ <li>Adds back the image.
+ <li>And the dumps the images array again. The image arrays order should
+ now be different.
+ <li>It gets a list of LIs (using getElementsByTagName()) and prints
+ out all their tagNames. There should be 10.
+</ul>
+<script>
+var x;
+dump("Images:\n");
+for (x=0; x < document.images.length; x++) {
+ dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
+}
+dump("\nLinks:\n");
+for (x=0; x < document.links.length; x++) {
+ dump("Link#" + x + ": " + document.links[x].getDOMAttribute("HREF") + "\n");
+}
+dump("\nAnchors:\n");
+for (x=0; x < document.anchors.length; x++) {
+ dump("Anchors#" + x + ": " + document.anchors[x].getDOMAttribute("NAME") + "\n");
+}
+
+dump("\nRemoving image\n");
+var img=document.images[1];
+var parent=img.parentNode;
+parent.removeChild(img);
+dump("Images:\n");
+for (x=0; x < document.images.length; x++) {
+ dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
+}
+
+dump("\nInserting image back into list\n");
+var sib=parent.childNodes[0];
+parent.insertBefore(img, sib);
+dump("Images:\n");
+for (x=0; x < document.images.length; x++) {
+ dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
+}
+
+var lis = document.getElementsByTagName("LI");
+dump("Lists:\n");
+for (x=0; x < lis.length; x++) {
+ dump(lis[x].tagName + "\n");
+}
+
+dump("Named elements:\n");
+dump(document.kipp.tagName + " with NAME=" + document.kipp.getDOMAttribute("NAME") + "\n");
+
+</script>
+</body>
+</html> \ No newline at end of file