Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 <html>
2 <body>
3 <p>This test does a few things:
4 <ul>
5 <li>It has a couple of:
6 <ul>
7 <li>Images: <IMG SRC="http://zabadubop/layers/tests/mzcolor.gif" ID="foo"> and
8 <IMG SRC="http://peoplestage.netscape.com/kipp/nerdly_int.gif" NAME="kipp">.
9 <li>Links to <a href="http://home.netscape.com">Netscape</a> and
10 <A HREF="http://peoplestage.netscape.com/kipp">Kippy's Home Page</A>.
11 <li>and Anchors to <a NAME="anchor1">here</A> and
12 <A name="anchor2">here</a>.
13 </ul>
14 <li>It dumps (check the JS console) the images, links and anchors using
15 the document.images, document.links and document.anchors arrays.
16 <li>Then it removes one of the images.
17 <li>Dumps the images array again. This is to prove that the images array
18 is live.
19 <li>Adds back the image.
20 <li>And the dumps the images array again. The image arrays order should
21 now be different.
22 <li>It gets a list of LIs (using getElementsByTagName()) and prints
23 out all their tagNames. There should be 10.
24 </ul>
25 <script>
26 var x;
27 dump("Images:\n");
28 for (x=0; x < document.images.length; x++) {
29 dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
30 }
31 dump("\nLinks:\n");
32 for (x=0; x < document.links.length; x++) {
33 dump("Link#" + x + ": " + document.links[x].getDOMAttribute("HREF") + "\n");
34 }
35 dump("\nAnchors:\n");
36 for (x=0; x < document.anchors.length; x++) {
37 dump("Anchors#" + x + ": " + document.anchors[x].getDOMAttribute("NAME") + "\n");
38 }
40 dump("\nRemoving image\n");
41 var img=document.images[1];
42 var parent=img.parentNode;
43 parent.removeChild(img);
44 dump("Images:\n");
45 for (x=0; x < document.images.length; x++) {
46 dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
47 }
49 dump("\nInserting image back into list\n");
50 var sib=parent.childNodes[0];
51 parent.insertBefore(img, sib);
52 dump("Images:\n");
53 for (x=0; x < document.images.length; x++) {
54 dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
55 }
57 var lis = document.getElementsByTagName("LI");
58 dump("Lists:\n");
59 for (x=0; x < lis.length; x++) {
60 dump(lis[x].tagName + "\n");
61 }
63 dump("Named elements:\n");
64 dump(document.kipp.tagName + " with NAME=" + document.kipp.getDOMAttribute("NAME") + "\n");
66 </script>
67 </body>
68 </html>