OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../js/resources/js-test-pre.js"></script> | 4 <script src="../../js/resources/js-test-pre.js"></script> |
5 <script src="../../dom/shadow/resources/polyfill.js"></script> | 5 <script src="../../dom/shadow/resources/polyfill.js"></script> |
hayato
2013/05/30 08:16:30
You can remove this line since polyfill.js is no l
tasak
2013/05/31 10:06:58
Done.
| |
6 <script> | 6 <script> |
7 if (window.testRunner) | 7 if (window.testRunner) |
8 testRunner.dumpAsText(); | 8 testRunner.dumpAsText(); |
9 | 9 |
10 shouldBeDefined("window.internals"); | 10 shouldBeDefined("window.internals"); |
hayato
2013/05/30 08:16:30
Looks like window.internals is not used.
tasak
2013/05/31 10:06:58
I rewrote this test by using shadow-dom.js, becaus
| |
11 | 11 |
12 function dumpComputedStyle(node) | 12 function dumpComputedStyle(node) |
13 { | 13 { |
14 debug(node.id + ": " + document.defaultView.getComputedStyle(node, null).get PropertyValue('border-color')); | 14 debug(node.id + ": " + document.defaultView.getComputedStyle(node, null).get PropertyValue('border-color')); |
15 } | 15 } |
16 | 16 |
17 function testBasic() | 17 function testBasic() |
18 { | 18 { |
19 debug('test a scoped style in document is applied to a node in shadow dom su btree when apply-author-styles is true.'); | 19 debug('test a scoped style in document is applied to a node in shadow dom su btree when apply-author-styles is true.'); |
20 var div = document.createElement('div'); | 20 var div = document.createElement('div'); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 shadow1.applyAuthorStyles = true; | 83 shadow1.applyAuthorStyles = true; |
84 shadow2.applyAuthorStyles = true; | 84 shadow2.applyAuthorStyles = true; |
85 dumpComputedStyle(shadow1.getElementById("targetInScope")); | 85 dumpComputedStyle(shadow1.getElementById("targetInScope")); |
86 dumpComputedStyle(shadow2.getElementById("targetOutOfScope")); | 86 dumpComputedStyle(shadow2.getElementById("targetOutOfScope")); |
87 | 87 |
88 document.body.removeChild(div); | 88 document.body.removeChild(div); |
89 } | 89 } |
90 | 90 |
91 function testNestedShadow() | 91 function testNestedShadow() |
92 { | 92 { |
93 debug('test a style in a shadow subtree is applied to a node in its descenda nt shadow subtree when all apply-author-styles in shadow subtrees between the sh adow subtree and the descendant are true.'); | 93 debug('test a style in a shadow subtree is applied to a node in its descenda nt shadow subtree when apply-author-styles in the shadow subtree is true.'); |
hayato
2013/05/29 11:16:27
I feel 'the shadow tree' is ambiguous in this sent
tasak
2013/05/31 10:06:58
Sure. Probably done.
| |
94 | 94 |
95 var div = document.createElement('div'); | 95 var div = document.createElement('div'); |
96 div.innerHTML = '<style scoped>div { border: 1px solid red }</style><div id= "host"></div>'; | 96 div.innerHTML = '<style scoped>div { border: 1px solid red }</style><div id= "host"></div>'; |
97 document.body.appendChild(div); | 97 document.body.appendChild(div); |
98 | 98 |
99 var outerMostShadow = document.getElementById("host").webkitCreateShadowRoot (); | 99 var outerMostShadow = document.getElementById("host").webkitCreateShadowRoot (); |
100 outerMostShadow.innerHTML = '<style>div { border: 1px solid blue; }</style>< div id="outerMost">outerMost</div>'; | 100 outerMostShadow.innerHTML = '<style>div { border: 1px solid blue; }</style>< div id="outerMost">outerMost</div>'; |
101 outerMostShadow.applyAuthorStyles = false; | 101 outerMostShadow.applyAuthorStyles = false; |
102 | 102 |
103 var outerShadow = outerMostShadow.getElementById("outerMost").webkitCreateSh adowRoot(); | 103 var outerShadow = outerMostShadow.getElementById("outerMost").webkitCreateSh adowRoot(); |
104 outerShadow.innerHTML = '<div id="outer">outer</div>'; | 104 outerShadow.innerHTML = '<div id="outer">outer</div>'; |
105 outerShadow.applyAuthorStyles = false; | 105 outerShadow.applyAuthorStyles = false; |
106 | 106 |
107 var shadow = outerShadow.getElementById("outer").webkitCreateShadowRoot(); | 107 var shadow = outerShadow.getElementById("outer").webkitCreateShadowRoot(); |
108 shadow.innerHTML = '<div id="target">target</div>'; | 108 shadow.innerHTML = '<div id="target">target</div>'; |
109 shadow.applyAuthorStyles = false; | 109 shadow.applyAuthorStyles = false; |
110 | 110 |
111 // No styles should be applied. | 111 // No styles should be applied. |
112 dumpComputedStyle(shadow.getElementById("target")); | 112 dumpComputedStyle(shadow.getElementById("target")); |
113 | 113 |
114 shadow.applyAuthorStyles = true; | 114 shadow.applyAuthorStyles = true; |
115 // A style in document should be applied. | 115 // A style in document should be applied. |
116 dumpComputedStyle(shadow.getElementById("target")); | 116 dumpComputedStyle(shadow.getElementById("target")); |
117 | 117 |
118 outerShadow.applyAuthorStyles = true | 118 outerShadow.applyAuthorStyles = true; |
119 // A style in 'outerMost' shadow should be applied. | 119 // A style in 'outerMost' shadow should be applied. |
120 dumpComputedStyle(shadow.getElementById("target")); | 120 dumpComputedStyle(shadow.getElementById("target")); |
121 | 121 |
122 document.body.removeChild(div); | 122 document.body.removeChild(div); |
123 } | 123 } |
124 | 124 |
125 function testMultipleShadow() | 125 function testMultipleShadow() |
126 { | 126 { |
127 debug('test a style in document is applied to nodes in multiple shadow subtr ees when apply-author-styles is true.'); | 127 debug('test a style in document is applied to nodes in multiple shadow subtr ees when apply-author-styles is true.'); |
128 | 128 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 testMultipleShadow(); | 214 testMultipleShadow(); |
215 testOrderOfApplyStyle(); | 215 testOrderOfApplyStyle(); |
216 } | 216 } |
217 | 217 |
218 </script> | 218 </script> |
219 </head> | 219 </head> |
220 <body onload="runTests()"> | 220 <body onload="runTests()"> |
221 <script src="../../js/resources/js-test-post.js"></script> | 221 <script src="../../js/resources/js-test-post.js"></script> |
222 </body> | 222 </body> |
223 </html> | 223 </html> |
OLD | NEW |