summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/lists
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 /testing/web-platform/tests/dom/lists
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 'testing/web-platform/tests/dom/lists')
-rw-r--r--testing/web-platform/tests/dom/lists/DOMTokenList-Iterable.html34
-rw-r--r--testing/web-platform/tests/dom/lists/DOMTokenList-coverage-for-attributes.html51
-rw-r--r--testing/web-platform/tests/dom/lists/DOMTokenList-iteration.html50
-rw-r--r--testing/web-platform/tests/dom/lists/DOMTokenList-stringifier.html25
-rw-r--r--testing/web-platform/tests/dom/lists/DOMTokenList-value.html24
5 files changed, 184 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/lists/DOMTokenList-Iterable.html b/testing/web-platform/tests/dom/lists/DOMTokenList-Iterable.html
new file mode 100644
index 000000000..4cf84b12a
--- /dev/null
+++ b/testing/web-platform/tests/dom/lists/DOMTokenList-Iterable.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>DOMTokenList Iterable Test</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<span class="foo Foo foo "></span>
+<script>
+ var elementClasses;
+ setup(function() {
+ elementClasses = document.querySelector("span").classList;
+ })
+ test(function() {
+ assert_true('length' in elementClasses);
+ }, 'DOMTokenList has length method.');
+ test(function() {
+ assert_true('values' in elementClasses);
+ }, 'DOMTokenList has values method.');
+ test(function() {
+ assert_true('entries' in elementClasses);
+ }, 'DOMTokenList has entries method.');
+ test(function() {
+ assert_true('forEach' in elementClasses);
+ }, 'DOMTokenList has forEach method.');
+ test(function() {
+ assert_true(Symbol.iterator in elementClasses);
+ }, 'DOMTokenList has Symbol.iterator.');
+ test(function() {
+ var classList = [];
+ for (var className of elementClasses){
+ classList.push(className);
+ }
+ assert_array_equals(classList, ['foo', 'Foo']);
+ }, 'DOMTokenList is iterable via for-of loop.');
+</script>
diff --git a/testing/web-platform/tests/dom/lists/DOMTokenList-coverage-for-attributes.html b/testing/web-platform/tests/dom/lists/DOMTokenList-coverage-for-attributes.html
new file mode 100644
index 000000000..880ce2864
--- /dev/null
+++ b/testing/web-platform/tests/dom/lists/DOMTokenList-coverage-for-attributes.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>DOMTokenList coverage for attributes</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+"use strict";
+
+var pairs = [
+ // Defined in DOM
+ {attr: "classList", sup: ["anyElement"]},
+ // Defined in HTML
+ {attr: "dropzone", sup: ["anyHTMLElement"]},
+ {attr: "htmlFor", sup: ["output"]},
+ {attr: "relList", sup: ["a", "area", "link"]},
+ {attr: "sandbox", sup: ["iframe"]},
+ {attr: "sizes", sup: ["link"]}
+];
+var namespaces = [
+ "http://www.w3.org/1999/xhtml",
+ "http://www.w3.org/2000/svg",
+ "http://www.w3.org/1998/Math/MathML",
+ "http://example.com/",
+ ""
+];
+
+var elements = ["a", "area", "link", "iframe", "output", "td", "th"];
+function testAttr(pair, new_el){
+ return (pair.attr === "classList" || (new_el.namespaceURI === "http://www.w3.org/1999/xhtml" && (pair.attr === "dropzone" || pair.sup.indexOf(new_el.localName) != -1)));
+}
+
+pairs.forEach(function(pair) {
+ namespaces.forEach(function(ns) {
+ elements.forEach(function(el) {
+ var new_el = document.createElementNS(ns, el);
+ if (testAttr(pair, new_el)) {
+ test(function() {
+ assert_class_string(new_el[pair.attr], "DOMTokenList");
+ }, new_el.localName + "." + pair.attr + " in " + new_el.namespaceURI + " namespace should be DOMTokenList.");
+ }
+ else {
+ test(function() {
+ assert_equals(new_el[pair.attr], undefined);
+ }, new_el.localName + "." + pair.attr + " in " + new_el.namespaceURI + " namespace should be undefined.");
+ }
+ });
+ });
+});
+
+</script>
diff --git a/testing/web-platform/tests/dom/lists/DOMTokenList-iteration.html b/testing/web-platform/tests/dom/lists/DOMTokenList-iteration.html
new file mode 100644
index 000000000..321bbe00d
--- /dev/null
+++ b/testing/web-platform/tests/dom/lists/DOMTokenList-iteration.html
@@ -0,0 +1,50 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>DOMTokenList iteration: keys, values, etc.</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<span class=" a a b "></span>
+<script>
+ test(function() {
+ var list = document.querySelector("span").classList;
+ assert_array_equals([...list], ["a", "a", "b"]);
+
+ var keys = list.keys();
+ assert_false(keys instanceof Array);
+ keys = [...keys];
+ assert_array_equals(keys, [0, 1, 2]);
+
+ var values = list.values();
+ assert_false(values instanceof Array);
+ values = [...values];
+ assert_array_equals(values, ["a", "a", "b"]);
+
+ var entries = list.entries();
+ assert_false(entries instanceof Array);
+ entries = [...entries];
+ assert_equals(entries.length, keys.length);
+ assert_equals(entries.length, values.length);
+ for (var i = 0; i < entries.length; ++i) {
+ assert_array_equals(entries[i], [keys[i], values[i]]);
+ }
+
+ var cur = 0;
+ var thisObj = {};
+ list.forEach(function(value, key, listObj) {
+ assert_equals(listObj, list);
+ assert_equals(this, thisObj);
+ assert_equals(value, values[cur]);
+ assert_equals(key, keys[cur]);
+ cur++;
+ }, thisObj);
+ assert_equals(cur, entries.length);
+
+ assert_equals(list[Symbol.iterator], Array.prototype[Symbol.iterator]);
+ assert_equals(list.keys, Array.prototype.keys);
+ if (Array.prototype.values) {
+ assert_equals(list.values, Array.prototype.values);
+ }
+ assert_equals(list.entries, Array.prototype.entries);
+ assert_equals(list.forEach, Array.prototype.forEach);
+ });
+</script>
diff --git a/testing/web-platform/tests/dom/lists/DOMTokenList-stringifier.html b/testing/web-platform/tests/dom/lists/DOMTokenList-stringifier.html
new file mode 100644
index 000000000..b125388e0
--- /dev/null
+++ b/testing/web-platform/tests/dom/lists/DOMTokenList-stringifier.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>DOMTokenList stringifier</title>
+<link rel=help href="https://dom.spec.whatwg.org/#dom-domtokenlist-stringifier">
+<link rel=author title=Ms2ger href="mailto:Ms2ger@gmail.com">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<span class=" a a b "></span>
+<script>
+test(function() {
+ assert_equals(String(document.createElement("span").classList), "",
+ "String(classList) should return the empty list for an undefined class attribute");
+ var span = document.querySelector("span");
+ assert_equals(span.getAttribute("class"), " a a b ",
+ "getAttribute should return the literal value");
+ assert_equals(span.className, " a a b ",
+ "className should return the literal value");
+ assert_equals(String(span.classList), " a a b ",
+ "String(classList) should return the literal value");
+ assert_equals(span.classList.toString(), " a a b ",
+ "classList.toString() should return the literal value");
+ assert_class_string(span.classList, "DOMTokenList");
+});
+</script>
diff --git a/testing/web-platform/tests/dom/lists/DOMTokenList-value.html b/testing/web-platform/tests/dom/lists/DOMTokenList-value.html
new file mode 100644
index 000000000..b0e39111d
--- /dev/null
+++ b/testing/web-platform/tests/dom/lists/DOMTokenList-value.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>DOMTokenList value</title>
+<link rel=help href="https://dom.spec.whatwg.org/#dom-domtokenlist-value">
+<link rel=author title=Tangresh href="mailto:dmenzi@tangresh.ch">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<span class=" a a b "></span>
+<script>
+test(function() {
+ assert_equals(String(document.createElement("span").classList.value), "",
+ "classList.value should return the empty list for an undefined class attribute");
+ var span = document.querySelector("span");
+ assert_equals(span.classList.value, " a a b ",
+ "value should return the literal value");
+ span.classList.value = " foo bar foo ";
+ assert_equals(span.classList.value, " foo bar foo ",
+ "assigning value should set the literal value");
+ assert_equals(span.classList.length, 2,
+ "length should be the number of tokens");
+ assert_class_string(span.classList, "DOMTokenList");
+ assert_class_string(span.classList.value, "String");
+});
+</script>