summaryrefslogtreecommitdiffstats
path: root/dom/base/test/file_bug357450.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/base/test/file_bug357450.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/test/file_bug357450.js')
-rw-r--r--dom/base/test/file_bug357450.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/dom/base/test/file_bug357450.js b/dom/base/test/file_bug357450.js
new file mode 100644
index 000000000..c432052b8
--- /dev/null
+++ b/dom/base/test/file_bug357450.js
@@ -0,0 +1,64 @@
+/** Test for Bug 357450 **/
+
+SimpleTest.waitForExplicitFinish();
+
+function testGetElements (root, classtestCount) {
+
+ ok(root.getElementsByClassName, "getElementsByClassName exists");
+ is(typeof(root.getElementsByClassName), "function", "getElementsByClassName is a function");
+
+ var nodes = root.getElementsByClassName("f");
+
+ is(typeof(nodes.item), "function");
+ is(typeof(nodes.length), "number");
+ is(nodes.length, 0, "string with no matching class should get an empty list");
+
+ nodes = root.getElementsByClassName("foo");
+ ok(nodes, "should have nodelist object");
+
+ // HTML5 says ints are allowed in class names
+ // should match int class
+
+ nodes = root.getElementsByClassName("1");
+ is(nodes[0], $('int-class'), "match integer class name");
+ nodes = root.getElementsByClassName([1]);
+ is(nodes[0], $('int-class'), "match integer class name 2");
+ nodes = root.getElementsByClassName(["1 junk"]);
+
+ is(nodes.length, 0, "two classes, but no elements have both");
+
+ nodes = root.getElementsByClassName("test1");
+ is(nodes[0], $('test1'), "Id and class name turn up the same node");
+ nodes = root.getElementsByClassName("test1 test2");
+ is(nodes.length, 0, "two classes, but no elements have both");
+
+ // WHATWG examples
+ nodes = document.getElementById('example').getElementsByClassName('aaa');
+ is(nodes.length, 2, "returns 2 elements");
+
+ nodes = document.getElementById('example').getElementsByClassName('ccc bbb')
+ is(nodes.length, 1, "only match elements that have all the classes specified in that array. tokenize string arg.")
+ is(nodes[0], $('p3'), "matched tokenized string");
+
+ nodes = document.getElementById('example').getElementsByClassName('');
+ is(nodes.length, 0, "class name with empty string shouldn't return nodes");
+
+ nodes = root.getElementsByClassName({});
+ ok(nodes, "bogus arg shouldn't be null");
+ is(typeof(nodes.item), "function");
+ is(typeof(nodes.length), "number");
+ is(nodes.length, 0, "bogus arg should get an empty nodelist");
+}
+
+addLoadEvent(function() {
+ if (document.getElementsByName) {
+ var anchorNodes = document.getElementsByName("nametest");
+ is(anchorNodes.length, 1, "getElementsByName still works");
+ is(anchorNodes[0].getAttribute("name"), "nametest",
+ "getElementsByName still works");
+ }
+ testGetElements($("content"), 1);
+ testGetElements(document.documentElement, 3);
+ testGetElements(document, 3);
+});
+addLoadEvent(SimpleTest.finish);