diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/js/htmlcollection.html | 29 | ||||
-rw-r--r-- | test/js/outerhtml.html | 4 | ||||
-rw-r--r-- | test/js/reflect.html | 25 | ||||
-rw-r--r-- | test/js/text.html | 9 |
4 files changed, 32 insertions, 35 deletions
diff --git a/test/js/htmlcollection.html b/test/js/htmlcollection.html index 6231237a..2b5b4983 100644 --- a/test/js/htmlcollection.html +++ b/test/js/htmlcollection.html @@ -1,22 +1,21 @@ <!doctype html> <title>HTMLCollection test</title> <div class="abc">Fail</div> +<style>style 0</style> <style>style 1</style> <style>style 2</style> -<style>style 3</style> +<script src=asserts.js></script> <script> -(function() { - const abc = document.getElementsByClassName("abc"); - if (abc.length !== 1) return; - abc[0].className = "defg"; - if (abc.length !== 0) return; - const styles = document.getElementsByTagName("style"); - if (styles.length !== 3) return; - if (styles[0].textContent !== "style 1") return; - if (styles[1].textContent !== "style 2") return; - if (styles[2].textContent !== "style 3") return; - for (const style of styles) style.remove(); - let defg = document.getElementsByClassName("defg"); - defg[0].textContent = "Success"; -})() +const abc = document.getElementsByClassName("abc"); +assert_equals(abc.length, 1); +abc[0].className = "defg"; +assert_equals(abc.length, 0); +const styles = document.getElementsByTagName("style"); +assert_equals(styles.length, 3); +for (let i = 0; i < styles.length; ++i) + assert_equals(styles[i].textContent, "style " + i); +for (const style of styles) + style.remove(); +const defg = document.getElementsByClassName("defg"); +defg[0].textContent = "Success"; </script> diff --git a/test/js/outerhtml.html b/test/js/outerhtml.html index 5c30bc52..8e4bbd2c 100644 --- a/test/js/outerhtml.html +++ b/test/js/outerhtml.html @@ -1,9 +1,9 @@ <!doctype html> <title>innerHTML test</title> <div id="test">Fail</div> +<script src=asserts.js></script> <script> const div = document.getElementById("test"); -if (div.outerHTML != '<div id="test">Fail</div>') - throw new TypeError("invalid outerHTML " + div.outerHTML); +assert_equals(div.outerHTML, '<div id="test">Fail</div>'); div.textContent = "Success"; </script> diff --git a/test/js/reflect.html b/test/js/reflect.html index 45debe39..9b2ed4cb 100644 --- a/test/js/reflect.html +++ b/test/js/reflect.html @@ -1,18 +1,17 @@ <!doctype html> <div id=abc>Fail</div> <a class=claz target="abcd">test test</a> +<script src=asserts.js></script> <script> -(function() { - let x = document.getElementById("abc") - let a = document.getElementsByTagName("a")[0]; - if (a.target != "abcd") return; - a.target = "defg"; - if (a.target != "defg") return; - if (a.relList != "") return; - a.relList = "..."; - if (a.relList != "...") return; - if (a.className != "claz") return; - x.textContent = "Success"; - a.remove(); /* ignore target... */ -})() +const x = document.getElementById("abc") +const a = document.getElementsByTagName("a")[0]; +assert_equals(a.target, "abcd"); +a.target = "defg"; +assert_equals(a.target, "defg"); +assert_equals(a.relList + "", ""); +a.relList = "..."; +assert_equals(a.relList + "", "..."); +assert_equals(a.className, "claz"); +x.textContent = "Success"; +a.remove(); /* ignore target... */ </script> diff --git a/test/js/text.html b/test/js/text.html index 7d7bcfca..8a511868 100644 --- a/test/js/text.html +++ b/test/js/text.html @@ -1,8 +1,7 @@ <!doctype html> -<div id="succ">Fail</div> +<div id=x>Fail</div> +<script src=asserts.js></script> <script> -(function() { - if (new Text("data").ownerDocument != document) return; - document.getElementById("succ").textContent = "Success" -})() +assert_equals(new Text("data").ownerDocument, document); +document.getElementById("x").textContent = "Success"; </script> |