|
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 |
|
18 function testCommentNode() { |
|
19 return document.head.childNodes[5]; |
|
20 } |
|
21 |
|
22 function testDocumentFragment() { |
|
23 var frag = document.createDocumentFragment(); |
|
24 |
|
25 var div = document.createElement("div"); |
|
26 div.id = "foo1"; |
|
27 div.className = "bar"; |
|
28 frag.appendChild(div); |
|
29 |
|
30 var span = document.createElement("span"); |
|
31 span.id = "foo2"; |
|
32 span.textContent = "hello world"; |
|
33 div.appendChild(span); |
|
34 |
|
35 var div2 = document.createElement("div"); |
|
36 div2.id = "foo3"; |
|
37 frag.appendChild(div2); |
|
38 |
|
39 return frag; |
|
40 } |
|
41 |
|
42 function testError() { |
|
43 try { |
|
44 window.foobar("a"); |
|
45 } catch (ex) { |
|
46 return ex; |
|
47 } |
|
48 return null; |
|
49 } |
|
50 |
|
51 function testDOMException() { |
|
52 try { |
|
53 var foo = document.querySelector("foo;()bar!"); |
|
54 } catch (ex) { |
|
55 return ex; |
|
56 } |
|
57 return null; |
|
58 } |
|
59 |
|
60 function testCSSStyleDeclaration() { |
|
61 document.body.style = 'color: green; font-size: 2em'; |
|
62 return document.body.style; |
|
63 } |
|
64 |
|
65 function testStyleSheetList() { |
|
66 var style = document.querySelector("style"); |
|
67 if (!style) { |
|
68 style = document.createElement("style"); |
|
69 style.textContent = "p, div { color: blue; font-weight: bold }\n" + |
|
70 "@media print { p { background-color: yellow } }"; |
|
71 document.head.appendChild(style); |
|
72 } |
|
73 return document.styleSheets; |
|
74 } |
|
75 </script> |
|
76 </body> |
|
77 </html> |