test-console-output-04.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <!DOCTYPE HTML>
  2. <html dir="ltr" lang="en-US">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Test the web console output - 04</title>
  6. <!--
  7. - Any copyright is dedicated to the Public Domain.
  8. - http://creativecommons.org/publicdomain/zero/1.0/
  9. -->
  10. </head>
  11. <body>
  12. <p>hello world!</p>
  13. <script type="text/javascript">
  14. function testTextNode() {
  15. return document.querySelector("p").childNodes[0];
  16. }
  17. function testCommentNode() {
  18. return document.head.childNodes[5];
  19. }
  20. function testDocumentFragment() {
  21. var frag = document.createDocumentFragment();
  22. var div = document.createElement("div");
  23. div.id = "foo1";
  24. div.className = "bar";
  25. frag.appendChild(div);
  26. var span = document.createElement("span");
  27. span.id = "foo2";
  28. span.textContent = "hello world";
  29. div.appendChild(span);
  30. var div2 = document.createElement("div");
  31. div2.id = "foo3";
  32. frag.appendChild(div2);
  33. return frag;
  34. }
  35. function testError() {
  36. try {
  37. window.foobar("a");
  38. } catch (ex) {
  39. return ex;
  40. }
  41. return null;
  42. }
  43. function testDOMException() {
  44. try {
  45. var foo = document.querySelector("foo;()bar!");
  46. } catch (ex) {
  47. return ex;
  48. }
  49. return null;
  50. }
  51. function testCSSStyleDeclaration() {
  52. document.body.style = 'color: green; font-size: 2em';
  53. return document.body.style;
  54. }
  55. function testStyleSheetList() {
  56. var style = document.querySelector("style");
  57. if (!style) {
  58. style = document.createElement("style");
  59. style.textContent = "p, div { color: blue; font-weight: bold }\n" +
  60. "@media print { p { background-color: yellow } }";
  61. document.head.appendChild(style);
  62. }
  63. return document.styleSheets;
  64. }
  65. </script>
  66. </body>
  67. </html>