diff options
Diffstat (limited to 'test/js')
-rw-r--r-- | test/js/collection.html | 26 | ||||
-rw-r--r-- | test/js/documentall.html | 22 |
2 files changed, 37 insertions, 11 deletions
diff --git a/test/js/collection.html b/test/js/collection.html new file mode 100644 index 00000000..4f83875f --- /dev/null +++ b/test/js/collection.html @@ -0,0 +1,26 @@ +<!doctype html> +<title>HTMLCollection test</title> +<div id=x>Fail</div> +<script src=asserts.js></script> +<form id=test> +<input id=1 name=input> +<input id=0 name=input> +</form> +<script> +const x = document.getElementById("x"); +const test = document.getElementById("test"); +assert_equals(document.forms[0], test); +assert_equals(document.forms["test"], test); +const elements = test.elements; +assert_equals(elements["a"], undefined); +assert_instanceof(elements[0], HTMLInputElement); +assert_equals(elements[0].id, "1"); +assert_equals(elements["0"].id, "1"); +assert_equals(elements[0].name, "input"); +assert_instanceof(elements["input"], RadioNodeList); +let el = elements[0]; +el.remove(); +el.remove(); +elements[0].remove(); +x.textContent = "Success"; +</script> diff --git a/test/js/documentall.html b/test/js/documentall.html index 14db9d70..c0272ca3 100644 --- a/test/js/documentall.html +++ b/test/js/documentall.html @@ -1,19 +1,19 @@ <!doctype html> <title>HTMLCollection test</title> <div id="result">Fail</div> +<script src=asserts.js></script> <style>style 1</style> <style>style 2</style> <style>style 3</style> <script> -(function() { - const abc = document.all; - if (document.all || abc) return; /* document.all must be falsy */ - if (abc.length !== 9) return; - const styles = [abc[5], abc[6], abc[7]]; - if (styles[0].textContent !== "style 1") return; - if (styles[1].textContent !== "style 2") return; - if (styles[2].textContent !== "style 3") return; - const result = document.getElementById("result"); - result.textContent = "Success"; -})() +const abc = document.all; +assert(!document.all, "document.all must be falsy"); +assert(!abc, "document.all must be falsy"); +assert_equals(document.all.length, 10); +const styles = [abc[6], abc[7], abc[8]]; +assert_equals(styles[0].textContent, "style 1"); +assert_equals(styles[1].textContent, "style 2"); +assert_equals(styles[2].textContent, "style 3"); +const result = document.getElementById("result"); +result.textContent = "Success"; </script> |