From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- dom/tests/js/DumpHTML.js | 58 +++++++++++++++++ dom/tests/js/DumpTree.js | 44 +++++++++++++ dom/tests/js/HTMLString.js | 66 ++++++++++++++++++++ dom/tests/js/attributes.html | 55 ++++++++++++++++ dom/tests/js/class.html | 30 +++++++++ dom/tests/js/clone.html | 26 ++++++++ dom/tests/js/docfrag.html | 39 ++++++++++++ dom/tests/js/flamer.gif | Bin 0 -> 11284 bytes dom/tests/js/id.html | 30 +++++++++ dom/tests/js/lists.html | 68 ++++++++++++++++++++ dom/tests/js/simple.js | 39 ++++++++++++ dom/tests/js/ssheets.js | 27 ++++++++ dom/tests/js/style1.html | 111 ++++++++++++++++++++++++++++++++ dom/tests/js/style2.html | 118 +++++++++++++++++++++++++++++++++++ dom/tests/js/tables/changeCaption.js | 74 ++++++++++++++++++++++ dom/tests/js/tables/changeCell.js | 104 ++++++++++++++++++++++++++++++ dom/tests/js/timer.js | 71 +++++++++++++++++++++ dom/tests/js/write.html | 12 ++++ dom/tests/js/write2.html | 60 ++++++++++++++++++ 19 files changed, 1032 insertions(+) create mode 100644 dom/tests/js/DumpHTML.js create mode 100644 dom/tests/js/DumpTree.js create mode 100644 dom/tests/js/HTMLString.js create mode 100644 dom/tests/js/attributes.html create mode 100644 dom/tests/js/class.html create mode 100644 dom/tests/js/clone.html create mode 100644 dom/tests/js/docfrag.html create mode 100644 dom/tests/js/flamer.gif create mode 100644 dom/tests/js/id.html create mode 100644 dom/tests/js/lists.html create mode 100644 dom/tests/js/simple.js create mode 100644 dom/tests/js/ssheets.js create mode 100644 dom/tests/js/style1.html create mode 100644 dom/tests/js/style2.html create mode 100644 dom/tests/js/tables/changeCaption.js create mode 100644 dom/tests/js/tables/changeCell.js create mode 100644 dom/tests/js/timer.js create mode 100644 dom/tests/js/write.html create mode 100644 dom/tests/js/write2.html (limited to 'dom/tests/js') 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(""); + } + + + } + // 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 + "" + } + // 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 @@ + + + Attributes test + + +

Attributes test

+ +

You should see the following in the console:

+
+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
+
+ +

The text should turn green and then you should see +the following in the console:

+
+setting an existing attribute returns the old node: true
+
+ + + + + + 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 @@ + + + + + + +

Changing CLASS test

+

Clicking on the button that follows this paragraph +should change the layout of these words +with respect to the rest of the flow.

+
+ +
+ + 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 @@ + + +Clone test + + + +

Clone test

+ +

If you press the button below, this paragraph and the +image will be cloned. +If you see an exact copy of this paragraph, the test +succeeded.

+ +
+ +
+ + \ 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 @@ + + + + + +

Document Fragment test

+ +

If this test works, clicking on this link will add two words to the end of this paragraph.

+ +

+Clicking on this link will replace the following two words with new ones: two words. +

+ + + \ 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 Binary files /dev/null and b/dom/tests/js/flamer.gif 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 @@ + + + + + + +

Changing ID test

+

Clicking on the button that follows this paragraph +should change the layout of these words +with respect to the rest of the flow.

+
+ +
+ + 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 @@ + + +

This test does a few things: +

+ + + \ 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 @@ + + +Example 0 + + + + +

Example 0: Basic HTML Text Styles

+


+

Formatted Text

+

This is a basic paragraph with bold, italic and bold-italic + text. It also includes red, green + and blue text. It has strikethru and underline. +

+

This is a paragraph with font variations: Arial, + Verdana, COURIER, + Times New Roman.

+

Font size=7, Font size=6, Font + size=5, Font size=4, Font size=3, Font + size=2, Font size=1, Font + point-size=24 font-weight=700

+

3D Text. 3D Text. 3D Text. 3D Text. 3D Text.
+


+

+

Listings

+

Bulleted List

+ +
+

Numbered List

+
    +
  1. One
  2. +
  3. Two +
      +
    1. Apples
    2. +
    3. Oranges
    4. +
    5. Bananas
    6. +
    +
  4. +
  5. Three
  6. +
+

Justified Text

+

This paragraph is aligned left. This paragraph is aligned left. + This paragraph is aligned left. This paragraph is aligned left. + This paragraph is aligned left. This paragraph is aligned left. + This paragraph is aligned left.

+

This paragarph is aligned right. This paragarph is aligned + right. This paragarph is aligned right. This paragarph is aligned + right. This paragarph is aligned right. This paragarph is aligned + right. This paragarph is aligned right. This paragarph + is aligned right.

+

This paragraph is aligned center. This paragraph is aligned + center.This paragraph is aligned center.This paragraph is aligned + center.This paragraph is aligned center.This paragraph is aligned + center.This paragraph is aligned center.This paragraph is aligned + center.This paragraph is aligned center.This paragraph is aligned + center.

+

+

 

+ + + 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 @@ + + +Example 0 + + + + + + + + + + + + + +
+

Example 0: Basic HTML Text Styles

+
+more table cell +
second rowsecond row
+


+

Formatted Text

+

This is a basic paragraph with bold, italic and bold-italic + text. It also includes red, green + and blue text. It has strikethru and underline. +

+

This is a paragraph with font variations: Arial, + Verdana, COURIER, + Times New Roman.

+

Font size=7, Font size=6, Font + size=5, Font size=4, Font size=3, Font + size=2, Font size=1, Font + point-size=24 font-weight=700

+

3D Text. 3D Text. 3D Text. 3D Text. 3D Text.
+


+

+

Listings

+

Bulleted List

+ +
+

Numbered List

+
    +
  1. One
  2. +
  3. Two +
      +
    1. Apples
    2. +
    3. Oranges
    4. +
    5. Bananas
    6. +
    +
  4. +
  5. Three
  6. +
+

Justified Text

+

This paragraph is aligned left. This paragraph is aligned left. + This paragraph is aligned left. This paragraph is aligned left. + This paragraph is aligned left. This paragraph is aligned left. + This paragraph is aligned left.

+

This paragarph is aligned right. This paragarph is aligned + right. This paragarph is aligned right. This paragarph is aligned + right. This paragarph is aligned right. This paragarph is aligned + right. This paragarph is aligned right. This paragarph + is aligned right.

+

This paragraph is aligned center. This paragraph is aligned + center.This paragraph is aligned center.This paragraph is aligned + center.This paragraph is aligned center.This paragraph is aligned + center.This paragraph is aligned center.This paragraph is aligned + center.This paragraph is aligned center.This paragraph is aligned + center.

+

+

 

+ + + 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 @@ + + +

This is text in the document.

+ +And now some more text in the document. + + \ 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 @@ + + + + + +

document.write (out-of-line) test

+

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.

+ +
+

Use this button to create a new window. If one already +exists, we'll use it. + +

+ +

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. + +

+ +

Use this button to close the document. Subsequent writes will rewrite +the document. + +

+

+ + \ No newline at end of file -- cgit v1.2.3