diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2015-08-09 18:54:37 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2015-08-09 18:54:37 +0100 |
commit | 0df3439eb26914466b91ce529e7f3366094030d6 (patch) | |
tree | 9a8a8011efff300ad46f994718304b646bac62e9 /test/js | |
parent | 3d7de6cf8d67bd7761a907cb171d8a4af8088a08 (diff) | |
download | netsurf-0df3439eb26914466b91ce529e7f3366094030d6.tar.gz netsurf-0df3439eb26914466b91ce529e7f3366094030d6.tar.bz2 |
Fix constructor injection to use new constructor type, add test
Diffstat (limited to 'test/js')
-rw-r--r-- | test/js/index.html | 1 | ||||
-rw-r--r-- | test/js/verify-instanceofness.html | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/test/js/index.html b/test/js/index.html index 56482ec98..e3cecd682 100644 --- a/test/js/index.html +++ b/test/js/index.html @@ -69,6 +69,7 @@ <ul> <li><a href="assorted-log-doc-write.html">console.log and document.write</a></li> <li><a href="wikipedia-lcm.html">Example from wikipedia</a></li> +<li><a href="verify-instanceofness.html">Check instanceof behaviour</a></li> </ul> </body> diff --git a/test/js/verify-instanceofness.html b/test/js/verify-instanceofness.html new file mode 100644 index 000000000..631dc99c4 --- /dev/null +++ b/test/js/verify-instanceofness.html @@ -0,0 +1,40 @@ +<html> + <head><title>Verify instanceof checking</title></head> + <body> + <h1>Check instanceof behaviour</h1> + <table cellpadding=2 border=1> + <tr><th>A</th><th>instanceof</th><th>B</th><th>?</th><th>Correct?</th></tr> + <script> +var checks = [ + [ "window", "Window", true ], + [ "document", "HTMLDocument", true ], + [ "document.head", "Node", true ], + [ "document.getElementsByTagName(\"body\")", "HTMLCollection", true ], + [ "document.body", "Window", false ], + [ "EventListener", "Object", undefined ], +]; + +for (var _check in checks) { + var check = checks[_check]; + document.write("<tr>"); + document.write("<td>" + check[0] + "</td><td>instanceof</td><td>" + check[1] + "</td>"); + try { + var A = eval(check[0]); + var B = eval(check[1]); + var C = check[2]; + var V = A instanceof B; + var OK = V == C; + document.write("<td>" + V + "</td><td>" + (OK ? "YES" : "<b style=\"color: red\">NO</b>") + "</td>"); + } catch (e) { + if (check[2] == undefined) { + document.write("<td>" + e + "</td><td>YES</td>"); + } else { + document.write("<td colspan=2><b style=\"color: red\">" + e + "</b></td>"); + } + } + document.write("</tr>"); +} + </script> + </table> + </body> +</html> |