| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <style> | |
| 5 div.resetTest { | |
| 6 background-color: #eef; | |
| 7 border: solid; | |
| 8 margin: 4px; | |
| 9 padding: 16px; | |
| 10 color: #fee; | |
| 11 font-family: Serif; | |
| 12 font-size: 24px; | |
| 13 font-style: italic; | |
| 14 font-variant: small-caps; | |
| 15 font-weight: bold; | |
| 16 letter-spacing: 2px; | |
| 17 line-height: 200%; | |
| 18 text-align: start; | |
| 19 text-indent: 50px; | |
| 20 text-transform: uppercase; | |
| 21 white-space: nowrap; | |
| 22 word-spacing: 30px; | |
| 23 } | |
| 24 </style> | |
| 25 <script> | |
| 26 function assertTrue(id, actual) { | |
| 27 if (!actual) | |
| 28 throw "failure:" + id + ": assertTrue failed"; | |
| 29 } | |
| 30 | |
| 31 function assertFalse(id, actual) { | |
| 32 if (actual) | |
| 33 throw "failure:" + id + ": assertFalse failed"; | |
| 34 } | |
| 35 | |
| 36 function shouldBe(a, b) | |
| 37 { | |
| 38 if (a != b) | |
| 39 throw "failure:" + a + ": should be " + b; | |
| 40 } | |
| 41 | |
| 42 function shouldNotBe(a, b) | |
| 43 { | |
| 44 if (a == b) | |
| 45 throw "failure:" + a + ": should not be " + b; | |
| 46 } | |
| 47 </script> | |
| 48 </head> | |
| 49 <body> | |
| 50 <div id="reset-style-inheritance"></div> | |
| 51 <div id="no-reset-style-inheritance"></div> | |
| 52 <div id="reset-style-inheritance-true-to-false"></div> | |
| 53 <div id="reset-style-inheritance-false-to-true"></div> | |
| 54 <div id="reset-style-inheritance-for-content"></div> | |
| 55 <div id="no-reset-style-inheritance-for-content"></div> | |
| 56 | |
| 57 <script> | |
| 58 function renderWithNoResetStyleInheritance() { | |
| 59 var div = document.createElement('div'); | |
| 60 div.className = 'resetTest'; | |
| 61 | |
| 62 var shadowRoot = div.createShadowRoot(); | |
| 63 assertFalse('default resetStyleInheritance should be false', shadowRoot.rese
tStyleInheritance); | |
| 64 shadowRoot.innerHTML = '<div>text</div>'; | |
| 65 | |
| 66 document.getElementById('no-reset-style-inheritance').appendChild(div); | |
| 67 } | |
| 68 | |
| 69 function renderWithResetStyleInheritance() { | |
| 70 var div = document.createElement('div'); | |
| 71 div.className = 'resetTest'; | |
| 72 | |
| 73 var shadowRoot = div.createShadowRoot(); | |
| 74 assertFalse('default resetStyleInheritance should be false', shadowRoot.rese
tStyleInheritance); | |
| 75 shadowRoot.resetStyleInheritance = true; | |
| 76 shadowRoot.innerHTML = '<div>text</div>'; | |
| 77 assertTrue('resetStyleInheritance should be true as explicitly set', shadowR
oot.resetStyleInheritance); | |
| 78 | |
| 79 document.getElementById('reset-style-inheritance').appendChild(div); | |
| 80 } | |
| 81 | |
| 82 function renderWithChangingResetStyleInheritanceFromTrueToFalse() { | |
| 83 var div = document.createElement('div'); | |
| 84 div.className = 'resetTest'; | |
| 85 | |
| 86 var shadowRoot = div.createShadowRoot(); | |
| 87 assertFalse('default resetStyleInheritance should be false', shadowRoot.rese
tStyleInheritance); | |
| 88 shadowRoot.resetStyleInheritance = true; | |
| 89 shadowRoot.innerHTML = '<div id="test1">text</div>'; | |
| 90 assertTrue('resetStyleInheritance should be true', shadowRoot.resetStyleInhe
ritance); | |
| 91 | |
| 92 document.getElementById('reset-style-inheritance-true-to-false').appendChild
(div); | |
| 93 div.offsetLeft; | |
| 94 var target = shadowRoot.getElementById('test1'); | |
| 95 shouldNotBe(window.getComputedStyle(target).getPropertyValue('font-family'),
'serif'); | |
| 96 shouldNotBe(window.getComputedStyle(target).getPropertyValue('line-height'),
'48px'); | |
| 97 | |
| 98 shadowRoot.resetStyleInheritance = false; | |
| 99 assertFalse('resetStyleInheritance should be false', shadowRoot.resetStyleIn
heritance); | |
| 100 div.offsetLeft; | |
| 101 shouldBe(window.getComputedStyle(target).getPropertyValue('font-family'), 's
erif'); | |
| 102 shouldBe(window.getComputedStyle(target).getPropertyValue('line-height'), '4
8px'); | |
| 103 } | |
| 104 | |
| 105 function renderWithChangingResetStyleInheritanceFromFalseToTrue() { | |
| 106 var div = document.createElement('div'); | |
| 107 div.className = 'resetTest'; | |
| 108 | |
| 109 var shadowRoot = div.createShadowRoot(); | |
| 110 assertFalse('default resetStyleInheritance should be false', shadowRoot.rese
tStyleInheritance); | |
| 111 shadowRoot.resetStyleInheritance = false; | |
| 112 shadowRoot.innerHTML = '<div id="test2">text</div>'; | |
| 113 assertFalse('default resetStyleInheritance should be false', shadowRoot.rese
tStyleInheritance); | |
| 114 | |
| 115 document.getElementById('reset-style-inheritance-false-to-true').appendChild
(div); | |
| 116 div.offsetLeft; | |
| 117 var target = shadowRoot.getElementById('test2'); | |
| 118 shouldBe(window.getComputedStyle(target).getPropertyValue('font-family'), 's
erif'); | |
| 119 shouldBe(window.getComputedStyle(target).getPropertyValue('line-height'), '4
8px'); | |
| 120 | |
| 121 shadowRoot.resetStyleInheritance = true; | |
| 122 assertTrue('resetStyleInheritance should be true', shadowRoot.resetStyleInhe
ritance); | |
| 123 div.offsetLeft; | |
| 124 shouldNotBe(window.getComputedStyle(target).getPropertyValue('font-family'),
'serif'); | |
| 125 shouldNotBe(window.getComputedStyle(target).getPropertyValue('line-height'),
'48px'); | |
| 126 } | |
| 127 | |
| 128 function createDivWithText(text) { | |
| 129 var div = document.createElement('div'); | |
| 130 div.appendChild(document.createTextNode(text)); | |
| 131 return div; | |
| 132 } | |
| 133 | |
| 134 function renderResetStyleInheritanceForContent() { | |
| 135 var div = document.createElement('div'); | |
| 136 div.className = 'resetTest'; | |
| 137 div.appendChild(createDivWithText('text')); | |
| 138 | |
| 139 var shadowRoot = div.createShadowRoot(); | |
| 140 shadowRoot.innerHTML = '<content select="div"></content>'; | |
| 141 shadowRoot.resetStyleInheritance = true; | |
| 142 assertTrue('resetStyleInheritance should be true', shadowRoot.resetStyleInhe
ritance); | |
| 143 document.getElementById('reset-style-inheritance-for-content').appendChild(d
iv); | |
| 144 div.offsetLeft; | |
| 145 } | |
| 146 | |
| 147 function renderNoResetStyleInheritanceForContent() { | |
| 148 var div = document.createElement('div'); | |
| 149 div.className = 'resetTest'; | |
| 150 div.appendChild(createDivWithText('text')); | |
| 151 | |
| 152 var shadowRoot = div.createShadowRoot(); | |
| 153 shadowRoot.innerHTML = '<content select="div"></content>'; | |
| 154 shadowRoot.resetStyleInheritance = false; | |
| 155 assertFalse('resetStyleInheritance should be false', shadowRoot.resetStyleIn
heritance); | |
| 156 document.getElementById('no-reset-style-inheritance-for-content').appendChil
d(div); | |
| 157 div.offsetLeft; | |
| 158 } | |
| 159 | |
| 160 renderWithNoResetStyleInheritance(); | |
| 161 renderWithResetStyleInheritance(); | |
| 162 renderWithChangingResetStyleInheritanceFromTrueToFalse(); | |
| 163 renderWithChangingResetStyleInheritanceFromFalseToTrue(); | |
| 164 renderResetStyleInheritanceForContent(); | |
| 165 renderNoResetStyleInheritanceForContent(); | |
| 166 </script> | |
| 167 </body> | |
| 168 </html> | |
| OLD | NEW |