summaryrefslogtreecommitdiffstats
path: root/dom/tests/js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/tests/js')
-rw-r--r--dom/tests/js/DumpHTML.js58
-rw-r--r--dom/tests/js/DumpTree.js44
-rw-r--r--dom/tests/js/HTMLString.js66
-rw-r--r--dom/tests/js/attributes.html55
-rw-r--r--dom/tests/js/class.html30
-rw-r--r--dom/tests/js/clone.html26
-rw-r--r--dom/tests/js/docfrag.html39
-rw-r--r--dom/tests/js/flamer.gifbin0 -> 11284 bytes
-rw-r--r--dom/tests/js/id.html30
-rw-r--r--dom/tests/js/lists.html68
-rw-r--r--dom/tests/js/simple.js39
-rw-r--r--dom/tests/js/ssheets.js27
-rw-r--r--dom/tests/js/style1.html111
-rw-r--r--dom/tests/js/style2.html118
-rw-r--r--dom/tests/js/tables/changeCaption.js74
-rw-r--r--dom/tests/js/tables/changeCell.js104
-rw-r--r--dom/tests/js/timer.js71
-rw-r--r--dom/tests/js/write.html12
-rw-r--r--dom/tests/js/write2.html60
19 files changed, 1032 insertions, 0 deletions
diff --git a/dom/tests/js/DumpHTML.js b/dom/tests/js/DumpHTML.js
new file mode 100644
index 000000000..b3c18b69c
--- /dev/null
+++ b/dom/tests/js/DumpHTML.js
@@ -0,0 +1,58 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+//
+// Dump the html content in html format
+//
+function html(node)
+{
+ var type = node.nodeType;
+ if (type == Node.ELEMENT_NODE) {
+
+ // open tag
+ dump("<" + node.tagName)
+
+ // dump the attributes if any
+ attributes = node.attributes;
+ if (null != attributes) {
+ var countAttrs = attributes.length;
+ var index = 0
+ while(index < countAttrs) {
+ att = attributes[index];
+ if (null != att) {
+ dump(" " + att.value)
+ }
+ index++
+ }
+ }
+
+ // close tag
+ dump(">")
+
+ // recursively dump the children
+ if (node.hasChildNodes()) {
+ // get the children
+ var children = node.childNodes;
+ var length = children.length;
+ var count = 0;
+ while(count < length) {
+ child = children[count]
+ html(child)
+ count++
+ }
+ dump("</" + node.tagName + ">");
+ }
+
+
+ }
+ // if it's a piece of text just dump the text
+ else if (type == Node.TEXT_NODE) {
+ dump(node.data)
+ }
+}
+
+html(document.documentElement)
+dump("\n")
diff --git a/dom/tests/js/DumpTree.js b/dom/tests/js/DumpTree.js
new file mode 100644
index 000000000..d23c2b3b3
--- /dev/null
+++ b/dom/tests/js/DumpTree.js
@@ -0,0 +1,44 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+//
+// travers the html tree and dump out the type of element
+//
+function traverse(node, indent)
+{
+ dump("\n")
+ indent += " "
+ var type = node.nodeType;
+
+ // if it's an element dump the tag and recurse the children
+ if (type == Node.ELEMENT_NODE) {
+
+ dump(indent + node.tagName)
+
+ // go through the children
+ if (node.hasChildNodes()) {
+ var children = node.childNodes;
+ var length = children.length;
+ var count = 0;
+ while(count < length) {
+ child = children[count]
+ traverse(child, indent)
+ count++
+ }
+ }
+ }
+ // it's just text, no tag, dump "Text"
+ else if (type == Node.TEXT_NODE) {
+ dump(indent + "Text")
+ }
+}
+
+var node = document.documentElement
+
+traverse(node, "")
+dump("\n")
+
+ \ No newline at end of file
diff --git a/dom/tests/js/HTMLString.js b/dom/tests/js/HTMLString.js
new file mode 100644
index 000000000..519c978e7
--- /dev/null
+++ b/dom/tests/js/HTMLString.js
@@ -0,0 +1,66 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+//
+// return a string representing the html content in html format
+//
+function htmlString(node, indent)
+{
+ var html = ""
+ indent += " "
+
+ var type = node.nodeType
+ if (type == Node.ELEMENT) {
+
+ // open tag
+ html += "\n" + indent + "<" + node.tagName
+
+ // dump the attributes if any
+ attributes = node.attributes
+ if (null != attributes) {
+ var countAttrs = attributes.length
+ var index = 0
+ while(index < countAttrs) {
+ att = attributes[index]
+ if (null != att) {
+ html += " "
+ html += att.name + "=" + att.value;
+ }
+ index++
+ }
+ }
+
+ // end tag
+ html += ">"
+
+ // recursively dump the children
+ if (node.hasChildNodes) {
+ // get the children
+ var children = node.childNodes
+ var length = children.length
+ var count = 0;
+ while(count < length) {
+ child = children[count]
+ html += htmlString(child, indent)
+ count++
+ }
+ }
+
+ // close tag
+ html += "\n" + indent + "</" + node.tagName + ">"
+ }
+ // if it's a piece of text just dump the text
+ else if (type == Node.TEXT) {
+ html += node.data
+ }
+
+ return html;
+}
+
+htmlString(document.documentElement, "")
+
+
+ \ No newline at end of file
diff --git a/dom/tests/js/attributes.html b/dom/tests/js/attributes.html
new file mode 100644
index 000000000..ae3bf3d6e
--- /dev/null
+++ b/dom/tests/js/attributes.html
@@ -0,0 +1,55 @@
+<HTML>
+<HEAD>
+ <TITLE>Attributes test</TITLE>
+</HEAD>
+<BODY bgColor="#ffffff" text="#000000">
+<H1>Attributes test</H1>
+
+<P>You should see the following in the console:</P>
+<PRE>
+attribute.getNamedItem == getAttributeNode: true
+attribute BGCOLOR=#ffffff
+changing attribute node value changes attribute value: true
+return value of removeNamedItem is attribute node: true
+removing attribute changes attribute count: true
+changing disembodied attribute value works: true
+removing attribute node removes attribute: true
+</PRE>
+
+<P>The text should turn green and then you should see
+the following in the console:</P>
+<PRE>
+setting an existing attribute returns the old node: true
+</PRE>
+
+<SCRIPT>
+a = document.body.attributes.getNamedItem("bgcolor")
+a2 = document.body.getAttributeNode("bgcolor")
+n = document.body.attributes.length;
+dump("attribute.getNamedItem == getAttributeNode: " + (a == a2) + "\n");
+
+dump("attribute " + a.name + "=" + a.value + "\n");
+
+a.value = "#00ffff"
+dump("changing attribute node value changes attribute value: " + (document.body.getAttribute("bgcolor") == "#00ffff") + "\n");
+
+a = document.body.attributes.removeNamedItem("bgcolor")
+dump("return value of removeNamedItem is attribute node: " + (a == a2) + "\n");
+
+dump("removing attribute changes attribute count: " + (document.body.attributes.length == (n-1)) + "\n");
+
+a.value = "#ff0000"
+dump("changing disembodied attribute value works: " + (a.value == "#ff0000") + "\n");
+
+dump("removing attribute node removes attribute: " + (document.body.getAttribute("bgcolor") == "") + "\n");
+
+a = document.body.attributes.getNamedItem("TEXT");
+a2 = document.createAttribute("text");
+a2.value = "#00ff00";
+a3 = document.body.attributes.setNamedItem(a2);
+dump("setting an existing attribute returns the old node: " + (a == a3) + "\n");
+</SCRIPT>
+
+</BODY>
+</HTML>
+
diff --git a/dom/tests/js/class.html b/dom/tests/js/class.html
new file mode 100644
index 000000000..8b9a3905c
--- /dev/null
+++ b/dom/tests/js/class.html
@@ -0,0 +1,30 @@
+<HTML>
+<HEAD>
+<STYLE>
+ .first { display: inline; color: green; }
+ .second { display: block; color: red; }
+</STYLE>
+<SCRIPT>
+var className = "first";
+function toggleClass() {
+ var node = document.getElementById("foo");
+ if (className == "first") {
+ className = "second";
+ }
+ else {
+ className = "first";
+ }
+ node.className = className;
+}
+</SCRIPT>
+</HEAD>
+<BODY>
+<H1>Changing CLASS test</H1>
+<P>Clicking on the button that follows this paragraph
+should change the layout of <SPAN ID="foo" CLASS="first">these words</SPAN>
+with respect to the rest of the flow.</P>
+<FORM>
+<INPUT TYPE="button" VALUE="Toggle class" onClick="toggleClass(); return true;">
+</FORM>
+</BODY>
+</HTML>
diff --git a/dom/tests/js/clone.html b/dom/tests/js/clone.html
new file mode 100644
index 000000000..a99f3f38d
--- /dev/null
+++ b/dom/tests/js/clone.html
@@ -0,0 +1,26 @@
+<HTML>
+<HEAD>
+<TITLE>Clone test</TITLE>
+<SCRIPT>
+function clonePara()
+{
+ var p = document.getElementsByTagName("P")[0];
+ var newp = p.cloneNode(true);
+
+ document.body.appendChild(newp);
+}
+</SCRIPT>
+</HEAD>
+<BODY>
+<H1>Clone test</H1>
+
+<P>If you press the button <B>below</B>, this paragraph and the
+image <IMG SRC="flamer.gif"> will be <FONT SIZE=+3>cloned</FONT>.
+If you see an <I>exact</I> copy of this paragraph, the test
+succeeded.</P>
+
+<FORM>
+<INPUT TYPE="button" NAME="clone" VALUE="Clone" onClick="clonePara();">
+</FORM>
+</BODY>
+</HTML> \ No newline at end of file
diff --git a/dom/tests/js/docfrag.html b/dom/tests/js/docfrag.html
new file mode 100644
index 000000000..f5520c945
--- /dev/null
+++ b/dom/tests/js/docfrag.html
@@ -0,0 +1,39 @@
+<HTML>
+<HEAD>
+<SCRIPT>
+function docFragAppendTest() {
+ var d = document.createDocumentFragment();
+ d.appendChild(document.createTextNode(" Hello"));
+ var b = document.createElement("B")
+ b.appendChild(document.createTextNode(" there"));
+ d.appendChild(b);
+ p = document.getElementById("appendTest");
+ p.appendChild(d);
+ alert("This number should be 0: " + d.childNodes.length);
+}
+function docFragReplaceTest() {
+ var d = document.createDocumentFragment();
+ d.appendChild(document.createTextNode(" new"));
+ var b = document.createElement("B")
+ b.appendChild(document.createTextNode(" ones"));
+ d.appendChild(b);
+ p = document.getElementById("replaceTest");
+ s = document.getElementById("replaceSpan");
+ if (null != s) {
+ p.replaceChild(d, s);
+ }
+ alert("This number should be 0: " + d.childNodes.length);
+}
+</SCRIPT>
+</HEAD>
+<BODY>
+<H1>Document Fragment test</H1>
+
+<P ID="appendTest">If this test works, clicking on this <A href="" onclick="docFragAppendTest(); return false;">link</A> will add two words to the end of this paragraph.</P>
+
+<P ID="replaceTest">
+Clicking on this <A href="" onclick="docFragReplaceTest(); return false;">link</A> will replace the following two words with new ones: <span id="replaceSpan">two words</span>.
+</P>
+
+</BODY>
+</HTML> \ No newline at end of file
diff --git a/dom/tests/js/flamer.gif b/dom/tests/js/flamer.gif
new file mode 100644
index 000000000..5a05df583
--- /dev/null
+++ b/dom/tests/js/flamer.gif
Binary files differ
diff --git a/dom/tests/js/id.html b/dom/tests/js/id.html
new file mode 100644
index 000000000..bcc015b70
--- /dev/null
+++ b/dom/tests/js/id.html
@@ -0,0 +1,30 @@
+<HTML>
+<HEAD>
+<STYLE>
+ #first { display: inline; color: green; }
+ #second { display: block; color: red; }
+</STYLE>
+<SCRIPT>
+var id = "first";
+function toggleId() {
+ var node = document.getElementById(id);
+ if (id == "first") {
+ id = "second";
+ }
+ else {
+ id = "first";
+ }
+ node.id = id;
+}
+</SCRIPT>
+</HEAD>
+<BODY>
+<H1>Changing ID test</H1>
+<P>Clicking on the button that follows this paragraph
+should change the layout of <SPAN ID="first">these words</SPAN>
+with respect to the rest of the flow.</P>
+<FORM>
+<INPUT TYPE="button" VALUE="Toggle ID" onClick="toggleId(); return true;">
+</FORM>
+</BODY>
+</HTML>
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
diff --git a/dom/tests/js/simple.js b/dom/tests/js/simple.js
new file mode 100644
index 000000000..6c8b9b7f6
--- /dev/null
+++ b/dom/tests/js/simple.js
@@ -0,0 +1,39 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var node = document.documentElement
+
+node.nodeType
+
+node.tagName
+
+var attrList = node.attributes
+
+attrList.length
+
+var attr = attrList.item(0)
+
+attr.name
+
+attr.value
+
+node.hasChildNodes
+
+var children = node.childNodes
+
+children.length
+
+node = children.item(1);
+node.nodeType
+
+node.tagName
+
+node = node.firstChild
+
+node = node.nextSibling
+
+node = node.parentNode
+
+ \ No newline at end of file
diff --git a/dom/tests/js/ssheets.js b/dom/tests/js/ssheets.js
new file mode 100644
index 000000000..eca4a8c64
--- /dev/null
+++ b/dom/tests/js/ssheets.js
@@ -0,0 +1,27 @@
+/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var s;
+for (s = 0; s < document.styleSheets.length; s++) {
+ var sheet = document.styleSheets[s];
+ dump("Style sheet #" + (s+1) + ": " + sheet.title + "\n");
+ var i, r;
+ dump("\n");
+ for (i = 0; i < sheet.imports.length; i++) {
+ dump("@import url(" + sheet.imports[i].href + ");\n");
+ }
+ dump("\n");
+ for (r = 0; r < sheet.rules.length; r++) {
+ var rule = sheet.rules[r];
+ dump(rule.selectorText + " {" + "\n");
+ var style = rule.style;
+ var p;
+ for (p = 0; p < style.length; p++) {
+ dump(" " + style[p] + ":" + style.getPropertyValue(style[p]) + ";\n");
+ }
+ dump(" }\n");
+ }
+ dump("\n");
+} \ No newline at end of file
diff --git a/dom/tests/js/style1.html b/dom/tests/js/style1.html
new file mode 100644
index 000000000..f345be0c4
--- /dev/null
+++ b/dom/tests/js/style1.html
@@ -0,0 +1,111 @@
+<html>
+<head>
+<title>Example 0</title>
+<style title="hello" media="screen, print">
+ :first-letter { color: green; }
+ a#id.foo:visited:first-line { color: red; }
+ a#id.foo:first-line { color: red; }
+ a#id.foo:visited { color: red; }
+ a#id:first-line { color: red; }
+ a#id:visited { color: red; }
+ a:first-line { color: red; }
+ a:visited { color: red; }
+ a:visited:first-line { color: red; }
+ a:visited:visited { color: red; }
+ a:first-line:visited { color: red; }
+ :active { color: blue; }
+ P.first:first-line { color: blue; }
+ P.first:first-letter { color: yellow; }
+</style>
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000">
+<h1>Example 0: Basic HTML Text Styles</h1>
+<p><br></p>
+<h2>Formatted Text</h2>
+<p>This is a basic paragraph with <b>bold</b>, <i>italic</i> and <i>bold-italic
+ </i> text. It also includes <font color="#FF0000">red</font>, <font color="#00FF00">green</font>
+ and <font color="#0000FF">blue</font> text. It has <s>strikethru</s> and <u>underline</u>.
+ <u> </u></p>
+<p>This is a paragraph with font variations: <b><font face="Arial, Helvetica, sans-serif">Arial,</font></b><font face="Arial, Helvetica, sans-serif">
+ <i><font face="Verdana, Arial, Helvetica, sans-serif">Verdana</font>,</i> <font face="co">COURIER,
+ <font face="Times New Roman, Times, serif">Times New Roman.</font></font></font></p>
+<p class="first"><font size=7>Font size=7, </font><font size=6>Font size=6, </font><font size=5>Font
+ size=5, </font><font size=4>Font size=4, </font><font size=3>Font size=3, </font><font size=2>Font
+ size=2, </font><font size=1>Font size=1, </font><font point-size=24 font-weight=700>Font
+ point-size=24 font-weight=700</font></p>
+<p><THREED>3D Text. 3D Text. 3D Text. 3D Text. 3D Text. </THREED><br>
+<h2><br>
+</h2>
+<h2>Listings</h2>
+<h3>Bulleted List </h3>
+<ul>
+ <li>One</li>
+ <li>Two
+ <ul>
+ <li>Apples</li>
+ <li>Oranges</li>
+ <li>Bananas</li>
+ </ul>
+ </li>
+ <li>Three</li>
+</ul>
+<br>
+<h3>Numbered List </h3>
+<ol>
+ <li>One</li>
+ <li>Two
+ <ol>
+ <li>Apples</li>
+ <li>Oranges</li>
+ <li>Bananas</li>
+ </ol>
+ </li>
+ <li>Three</li>
+</ol>
+<h2>Justified Text</h2>
+<p>This paragraph is aligned <b>left</b>. This paragraph is aligned <b>left</b>.
+ This paragraph is aligned <b>left</b>. This paragraph is aligned <b>left</b>.
+ This paragraph is aligned <b>left</b>. This paragraph is aligned <b>left</b>.
+ This paragraph is aligned <b>left</b>. </p>
+<p align="RIGHT">This paragarph is aligned <b>right. </b>This paragarph is aligned
+ <b>right. </b>This paragarph is aligned <b>right. </b>This paragarph is aligned
+ <b>right. </b>This paragarph is aligned <b>right. </b>This paragarph is aligned
+ <b>right. </b>This paragarph is aligned <b>right. </b><b> </b>This paragarph
+ is aligned <b>right. </b></p>
+<p align="CENTER">This paragraph is aligned <b>center</b>. This paragraph is aligned
+ <b>center</b>.This paragraph is aligned <b>center</b>.This paragraph is aligned
+ <b>center</b>.This paragraph is aligned <b>center</b>.This paragraph is aligned
+ <b>center</b>.This paragraph is aligned <b>center</b>.This paragraph is aligned
+ <b>center</b>.This paragraph is aligned <b>center</b>.This paragraph is aligned
+ <b>center</b>.</p>
+<p></p>
+<p>&nbsp;</p>
+<script>
+var r = 0, g = 0, b = 0;
+var h = document.documentElement.childNodes[1].childNodes[1];
+var sheet = document.styleSheets[0];
+var rule = sheet.cssRules[0];
+var size = 10;
+
+function changeColor() {
+ r += 5;
+ g += 2;
+ b += 3;
+ r %= 255;
+ g %= 255;
+ b %= 255;
+ size += 1;
+ if (size > 48) {
+ size = 10;
+ }
+
+ h.style.backgroundColor = "rgb(" + r + "," + g + "," + b + ")";
+ rule.style.color = "rgb(" + r + "," + g + "," + b + ")";
+ rule.style.fontSize = size + "pt";
+}
+
+setInterval(changeColor, 40);
+</script>
+</body>
+</html>
diff --git a/dom/tests/js/style2.html b/dom/tests/js/style2.html
new file mode 100644
index 000000000..cc4231414
--- /dev/null
+++ b/dom/tests/js/style2.html
@@ -0,0 +1,118 @@
+<html>
+<head>
+<title>Example 0</title>
+<style>
+ a#id.foo:visited:first-line { color: red; }
+ a#id.foo:first-line { color: red; }
+ a#id.foo:visited { color: red; }
+ a#id:first-line { color: red; }
+ a#id:visited { color: red; }
+ a:first-line { color: red; }
+ a:visited { color: red; }
+ a:visited:first-line { color: red; }
+ a:visited:visited { color: red; }
+ a:first-line:visited { color: red; }
+ :active { color: blue; }
+ :first-letter { color: green; }
+</style>
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000">
+<table border=4>
+<tr>
+<td>
+<h1>Example 0: Basic HTML Text Styles</h1>
+</td>
+<td>
+more table cell
+</td>
+</tr>
+<tr>
+<td>second row</td>
+<td>second row</td>
+</tr>
+</table>
+<p><br></p>
+<h2>Formatted Text</h2>
+<p>This is a basic paragraph with <b>bold</b>, <i>italic</i> and <i>bold-italic
+ </i> text. It also includes <font color="#FF0000">red</font>, <font color="#00FF00">green</font>
+ and <font color="#0000FF">blue</font> text. It has <s>strikethru</s> and <u>underline</u>.
+ <u> </u></p>
+<p>This is a paragraph with font variations: <b><font face="Arial, Helvetica, sans-serif">Arial,</font></b><font face="Arial, Helvetica, sans-serif">
+ <i><font face="Verdana, Arial, Helvetica, sans-serif">Verdana</font>,</i> <font face="co">COURIER,
+ <font face="Times New Roman, Times, serif">Times New Roman.</font></font></font></p>
+<p><font size=7>Font size=7, </font><font size=6>Font size=6, </font><font size=5>Font
+ size=5, </font><font size=4>Font size=4, </font><font size=3>Font size=3, </font><font size=2>Font
+ size=2, </font><font size=1>Font size=1, </font><font point-size=24 font-weight=700>Font
+ point-size=24 font-weight=700</font></p>
+<p><THREED>3D Text. 3D Text. 3D Text. 3D Text. 3D Text. </THREED><br>
+<h2><br>
+</h2>
+<h2>Listings</h2>
+<h3>Bulleted List </h3>
+<ul>
+ <li>One</li>
+ <li>Two
+ <ul>
+ <li>Apples</li>
+ <li>Oranges</li>
+ <li>Bananas</li>
+ </ul>
+ </li>
+ <li>Three</li>
+</ul>
+<br>
+<h3>Numbered List </h3>
+<ol>
+ <li>One</li>
+ <li>Two
+ <ol>
+ <li>Apples</li>
+ <li>Oranges</li>
+ <li>Bananas</li>
+ </ol>
+ </li>
+ <li>Three</li>
+</ol>
+<h2>Justified Text</h2>
+<p>This paragraph is aligned <b>left</b>. This paragraph is aligned <b>left</b>.
+ This paragraph is aligned <b>left</b>. This paragraph is aligned <b>left</b>.
+ This paragraph is aligned <b>left</b>. This paragraph is aligned <b>left</b>.
+ This paragraph is aligned <b>left</b>. </p>
+<p align="RIGHT">This paragarph is aligned <b>right. </b>This paragarph is aligned
+ <b>right. </b>This paragarph is aligned <b>right. </b>This paragarph is aligned
+ <b>right. </b>This paragarph is aligned <b>right. </b>This paragarph is aligned
+ <b>right. </b>This paragarph is aligned <b>right. </b><b> </b>This paragarph
+ is aligned <b>right. </b></p>
+<p align="CENTER">This paragraph is aligned <b>center</b>. This paragraph is aligned
+ <b>center</b>.This paragraph is aligned <b>center</b>.This paragraph is aligned
+ <b>center</b>.This paragraph is aligned <b>center</b>.This paragraph is aligned
+ <b>center</b>.This paragraph is aligned <b>center</b>.This paragraph is aligned
+ <b>center</b>.This paragraph is aligned <b>center</b>.This paragraph is aligned
+ <b>center</b>.</p>
+<p></p>
+<p>&nbsp;</p>
+<script>
+var r = 0, g = 0, b = 0;
+var h = document.documentElement.childNodes[1].childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[1];
+h.style.borderStyle = "groove";
+
+function changeColor() {
+ r += 5;
+ g += 2;
+ b += 3;
+ r %= 255;
+ g %= 255;
+ b %= 255;
+
+ h.style.backgroundColor = "rgb(" + r + "," + g + "," + b + ")";
+ h.style.color = "rgb(" + (255-r) + "," + (255-g) + "," + (255-b) + ")";
+ h.style.fontSize = "" + (r/3) + "pt";
+ h.style.borderWidth = "" + (r/5) + "px";
+ h.style.borderColor = h.style.color;
+}
+
+setInterval(changeColor, 40);
+</script>
+</body>
+</html>
diff --git a/dom/tests/js/tables/changeCaption.js b/dom/tests/js/tables/changeCaption.js
new file mode 100644
index 000000000..7e3a147dc
--- /dev/null
+++ b/dom/tests/js/tables/changeCaption.js
@@ -0,0 +1,74 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+function findBody(node)
+{
+ if (node.nodeType != Node.ELEMENT_NODE) {
+ return null;
+ }
+ var children = node.childNodes;
+ if (children == null) {
+ return null;
+ }
+ var length = children.length;
+ var child = null;
+ var count = 0;
+ while (count < length) {
+ child = children[count];
+ if (child.tagName == "BODY") {
+ dump("BODY found");
+ return child;
+ }
+ var body = findBody(child);
+ if (null != body) {
+ return body;
+ }
+ count++;
+ }
+ return null;
+}
+
+// Given the body element, find the first table element
+function findTable(body)
+{
+ // XXX A better way to do this would be to use getElementsByTagName(), but
+ // it isn't implemented yet...
+ var children = body.childNodes
+ if (children == null) {
+ return null;
+ }
+ var length = children.length;
+ var child = null;
+ var count = 0;
+ while (count < length) {
+ child = children[count];
+ if (child.nodeType == Node.ELEMENT_NODE) {
+ if (child.tagName == "TABLE") {
+ dump("TABLE found");
+ break;
+ }
+ }
+ count++;
+ }
+
+ return child;
+}
+
+// Change the table's caption
+function changeCaption(table)
+{
+ // Get the first element. This is the caption (maybe). We really should
+ // check...
+ var caption = table.firstChild
+
+ // Get the caption text
+ var text = caption.firstChild
+
+ // Append some text
+ text.append(" NEW TEXT")
+}
+
+changeCaption(findTable(findBody(document.documentElement)))
+
diff --git a/dom/tests/js/tables/changeCell.js b/dom/tests/js/tables/changeCell.js
new file mode 100644
index 000000000..d65a4c3d0
--- /dev/null
+++ b/dom/tests/js/tables/changeCell.js
@@ -0,0 +1,104 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+function findBody(node)
+{
+ if (node.nodeType != Node.ELEMENT_NODE) {
+ return null;
+ }
+ var children = node.childNodes;
+ if (children == null) {
+ return null;
+ }
+ var length = children.length;
+ var child = null;
+ var count = 0;
+ while (count < length) {
+ child = children[count];
+ if (child.tagName == "BODY") {
+ dump("BODY found");
+ return child;
+ }
+ var body = findBody(child);
+ if (null != body) {
+ return body;
+ }
+ count++;
+ }
+ return null;
+}
+
+// Given the body element, find the first table element
+function findTable(body)
+{
+ // XXX A better way to do this would be to use getElementsByTagName(), but
+ // it isn't implemented yet...
+ var children = body.childNodes
+ if (children == null) {
+ return null;
+ }
+ var length = children.length;
+ var child = null;
+ var count = 0;
+ while (count < length) {
+ child = children[count];
+ if (child.nodeType == Node.ELEMENT_NODE) {
+ if (child.tagName == "TABLE") {
+ dump("TABLE found");
+ break;
+ }
+ }
+ count++;
+ }
+
+ return child;
+}
+
+// Given a table element, find the first table body
+function findTableBody(table)
+{
+ // XXX A better way to do this would be to use getElementsByTagName(), but
+ // it isn't implemented yet...
+ var children = table.childNodes
+ if (children == null) {
+ return null;
+ }
+ var length = children.length;
+ var child = null;
+ var count = 0;
+ while (count < length) {
+ child = children[count];
+ if (child.nodeType == Node.ELEMENT_NODE) {
+ if (child.tagName == "TBODY") {
+ break;
+ }
+ }
+ count++;
+ }
+
+ return child;
+}
+
+// Change the text of the first table cell
+function changeCell(table)
+{
+ // Get a table body
+ var body = findTableBody(table)
+
+ // The table body's first child is a table row
+ var row = body.firstChild
+
+ // The row's first child is a table cell
+ var cell = row.firstChild
+
+ // Get the cell's text
+ var text = cell.firstChild
+
+ // Append some text
+ text.append(" NEW TEXT")
+}
+
+changeCell(findTable(findBody(document.documentElement)))
+
diff --git a/dom/tests/js/timer.js b/dom/tests/js/timer.js
new file mode 100644
index 000000000..ac1ed1ef3
--- /dev/null
+++ b/dom/tests/js/timer.js
@@ -0,0 +1,71 @@
+
+function oneShot(testNum, str)
+{
+ dump("Test #" + testNum + " successful:" + str + "\n");
+}
+
+setTimeout(oneShot, 1000, 1, "one shot timer with function argument");
+setTimeout("oneShot(2, 'one shot timer with string argument');", 2000);
+
+function reschedule(testNum, numTimes)
+{
+ if (numTimes == 4) {
+ dump("Test #" + testNum + " successful: Creating a timeout in a timeout\n");
+ kickoff4();
+ }
+ else {
+ dump("Test #" + testNum + " in progress: " + numTimes + "\n");
+ setTimeout(reschedule, 500, 3, numTimes+1);
+ }
+}
+
+setTimeout(reschedule, 3000, 3, 0);
+
+var count = 0;
+var repeat_timer = null;
+function repeat(testNum, numTimes, str, func, delay)
+{
+ dump("Test #" + testNum + " in progress: interval delayed by " + delay + " milliseconds\n");
+ if (count++ > numTimes) {
+ clearInterval(repeat_timer);
+ dump("Test #" + testNum + " successful: " + str + "\n");
+ if (func != null) {
+ func();
+ }
+ }
+}
+
+function kickoff4()
+{
+ repeat_timer = setInterval(repeat, 500, 4, 5, "interval test", kickoff5);
+}
+
+//setTimeout(kickoff4, 5000);
+
+function oneShot2(testNum)
+{
+ dump("Test #" + testNum + " in progress: one shot timer\n");
+ if (count++ == 4) {
+ dump("Test #" + testNum + " in progress: end of one shots\n");
+ }
+ else {
+ setTimeout(oneShot2, 500, 5);
+ }
+}
+
+function kickoff5()
+{
+ count = 0;
+ setTimeout(oneShot2, 500, 5);
+ repeat_timer = setInterval("repeat(5, 8, 'multiple timer test', kickoff6)", 600);
+}
+
+//setTimeout(kickoff5, 12000);
+
+function kickoff6()
+{
+ dump("Test #6: Interval timeout should end when you go to a new page\n");
+ setInterval(repeat, 1000, 6, 1000, "endless timer test", null);
+}
+
+//setTimeout(kickoff6, 18000); \ No newline at end of file
diff --git a/dom/tests/js/write.html b/dom/tests/js/write.html
new file mode 100644
index 000000000..dfee64946
--- /dev/null
+++ b/dom/tests/js/write.html
@@ -0,0 +1,12 @@
+<HTML>
+<BODY>
+<P>This is text in the document.</P>
+<SCRIPT>
+document.writeln("<P>This is text generated by a document.write.");
+document.writeln("And this is an image: <IMG SRC='http://zabadubop/layers/tests/mzcolor.gif'></P>");
+</SCRIPT>
+And now some more text in the document.
+<SCRIPT>
+document.writeln("<SCRIPT>document.writeln('<P>Text from a recursive document.write.</P>');<\/SCRIPT>");
+</SCRIPT>
+</BODY> \ No newline at end of file
diff --git a/dom/tests/js/write2.html b/dom/tests/js/write2.html
new file mode 100644
index 000000000..8fcfd1075
--- /dev/null
+++ b/dom/tests/js/write2.html
@@ -0,0 +1,60 @@
+<HTML>
+<HEAD>
+<SCRIPT>
+var w = null;
+var count = 0;
+var isOpen = false;
+
+function newWin() {
+ if ((w == null) || (w.closed == true)) {
+ w = window.open("about:blank", "writetest");
+ }
+}
+
+function incrWrite() {
+ if (w != null) {
+ if (!isOpen) {
+ count = 0;
+ isOpen = true;
+ w.document.write("<p>Opening document and counting up....</p>");
+ }
+
+ w.document.write("<p>Counter at: " + count++ + "</p>");
+ }
+}
+
+function closeDoc() {
+ if ((w != null) && isOpen) {
+ w.document.write("<p>Closing document!</p>");
+ w.document.close();
+ isOpen = false;
+ }
+}
+</SCRIPT>
+</HEAD>
+<BODY>
+<h1>document.write (out-of-line) test</h1>
+<p>This test uses the open, write and close methods of a
+document to construct a document. It tests the "out-of-line"
+capabilities of document.write i.e. the ability to use
+document.write to create an entirely new document.</p>
+
+<form>
+<p>Use this button to create a new window. If one already
+exists, we'll use it.
+<INPUT TYPE="button" NAME="newwin" VALUE="New Window" onClick="newWin(); return true;">
+</p>
+
+<p>Use this button to write the new value of a counter into
+the document. If the document was previously closed, it will be
+reopened (and the old contents will be destroyed.
+<INPUT TYPE="button" NAME="incrwrite" VALUE="Write" onClick="incrWrite(); return true;">
+</p>
+
+<p>Use this button to close the document. Subsequent writes will rewrite
+the document.
+<INPUT TYPE="button" NAME="closedoc" VALUE="Close Document" onClick="closeDoc(); return true;">
+<p>
+</FORM>
+</BODY>
+</HTML> \ No newline at end of file