|
102 | 102 | var XBarBarPrototype = Object.create(XBarPrototype); |
103 | 103 | var XBarBar = document.register('x-barbar', { |
104 | 104 | prototype: XBarBarPrototype, |
105 | | - extends: 'x-bar' |
| 105 | + extends: 'button' |
106 | 106 | }); |
107 | 107 | var xbarbar = new XBarBar(); |
108 | 108 | work.appendChild(xbarbar).textContent = 'x-barbar'; |
|
113 | 113 | var XBarBarBarPrototype = Object.create(XBarBarPrototype); |
114 | 114 | var XBarBarBar = document.register('x-barbarbar', { |
115 | 115 | prototype: XBarBarBarPrototype, |
116 | | - extends: 'x-barbar' |
| 116 | + extends: 'button' |
117 | 117 | }); |
118 | 118 | var xbarbarbar = new XBarBarBar(); |
119 | 119 | work.appendChild(xbarbarbar).textContent = 'x-barbarbar'; |
|
139 | 139 | this.style.fontSize = '32pt'; |
140 | 140 | }; |
141 | 141 | var XBooBoo = document.register('x-booboo', { |
142 | | - prototype: XBooBooPrototype, |
143 | | - extends: 'x-boo' |
| 142 | + prototype: XBooBooPrototype |
144 | 143 | }); |
145 | 144 | var xbooboo = new XBooBoo(); |
146 | 145 | assert.equal(xbooboo.style.fontStyle, 'italic'); |
147 | 146 | assert.equal(xbooboo.style.fontSize, '32pt'); |
148 | 147 | }); |
149 | 148 |
|
150 | 149 |
|
151 | | - test('document.register [created|enteredDocument|leftDocument]Callbacks in prototype', function(done) { |
| 150 | + test('document.register [created|enteredView|leftView]Callbacks in prototype', function(done) { |
152 | 151 | var ready, inserted, removed; |
153 | 152 | var XBooPrototype = Object.create(HTMLElement.prototype); |
154 | 153 | XBooPrototype.createdCallback = function() { |
155 | 154 | ready = true; |
156 | 155 | } |
157 | | - XBooPrototype.enteredDocumentCallback = function() { |
| 156 | + XBooPrototype.enteredViewCallback = function() { |
158 | 157 | inserted = true; |
159 | 158 | } |
160 | | - XBooPrototype.leftDocumentCallback = function() { |
| 159 | + XBooPrototype.leftViewCallback = function() { |
161 | 160 | removed = true; |
162 | 161 | } |
163 | 162 | var XBoo = document.register('x-boo-ir', { |
|
169 | 168 | assert(!removed, 'removed must be false [XBoo]'); |
170 | 169 | work.appendChild(xboo); |
171 | 170 | CustomElements.takeRecords(); |
172 | | - setTimeout(function() { |
173 | | - assert(inserted, 'inserted must be true [XBoo]'); |
174 | | - work.removeChild(xboo); |
175 | | - CustomElements.takeRecords(); |
176 | | - setTimeout(function() { |
177 | | - assert(removed, 'removed must be true [XBoo]'); |
178 | | - // |
179 | | - ready = inserted = removed = false; |
180 | | - var XBooBooPrototype = Object.create(XBooPrototype); |
181 | | - XBooBooPrototype.createdCallback = function() { |
182 | | - XBoo.prototype.createdCallback.call(this); |
183 | | - }; |
184 | | - XBooBooPrototype.enteredDocumentCallback = function() { |
185 | | - XBoo.prototype.enteredDocumentCallback.call(this); |
186 | | - }; |
187 | | - XBooBooPrototype.leftDocumentCallback = function() { |
188 | | - XBoo.prototype.leftDocumentCallback.call(this); |
189 | | - }; |
190 | | - var XBooBoo = document.register('x-booboo-ir', { |
191 | | - prototype: XBooBooPrototype, |
192 | | - extends: 'x-boo-ir' |
193 | | - }); |
194 | | - var xbooboo = new XBooBoo(); |
195 | | - assert(ready, 'ready must be true [XBooBoo]'); |
196 | | - assert(!inserted, 'inserted must be false [XBooBoo]'); |
197 | | - assert(!removed, 'removed must be false [XBooBoo]'); |
198 | | - work.appendChild(xbooboo); |
199 | | - CustomElements.takeRecords(); |
200 | | - //setTimeout(function() { |
201 | | - assert(inserted, 'inserted must be true [XBooBoo]'); |
202 | | - work.removeChild(xbooboo); |
203 | | - CustomElements.takeRecords(); |
204 | | - //setTimeout(function() { |
205 | | - assert(removed, 'removed must be true [XBooBoo]'); |
206 | | - done(); |
207 | | - //}, 1); |
208 | | - //}, 1); |
209 | | - }, 1); |
210 | | - }, 1); |
| 171 | + assert(inserted, 'inserted must be true [XBoo]'); |
| 172 | + work.removeChild(xboo); |
| 173 | + CustomElements.takeRecords(); |
| 174 | + assert(removed, 'removed must be true [XBoo]'); |
| 175 | + // |
| 176 | + ready = inserted = removed = false; |
| 177 | + var XBooBooPrototype = Object.create(XBooPrototype); |
| 178 | + XBooBooPrototype.createdCallback = function() { |
| 179 | + XBoo.prototype.createdCallback.call(this); |
| 180 | + }; |
| 181 | + XBooBooPrototype.enteredViewCallback = function() { |
| 182 | + XBoo.prototype.enteredViewCallback.call(this); |
| 183 | + }; |
| 184 | + XBooBooPrototype.leftViewCallback = function() { |
| 185 | + XBoo.prototype.leftViewCallback.call(this); |
| 186 | + }; |
| 187 | + var XBooBoo = document.register('x-booboo-ir', { |
| 188 | + prototype: XBooBooPrototype |
| 189 | + }); |
| 190 | + var xbooboo = new XBooBoo(); |
| 191 | + assert(ready, 'ready must be true [XBooBoo]'); |
| 192 | + assert(!inserted, 'inserted must be false [XBooBoo]'); |
| 193 | + assert(!removed, 'removed must be false [XBooBoo]'); |
| 194 | + work.appendChild(xbooboo); |
| 195 | + CustomElements.takeRecords(); |
| 196 | + assert(inserted, 'inserted must be true [XBooBoo]'); |
| 197 | + work.removeChild(xbooboo); |
| 198 | + CustomElements.takeRecords(); |
| 199 | + assert(removed, 'removed must be true [XBooBoo]'); |
| 200 | + done(); |
211 | 201 | }); |
212 | 202 |
|
213 | 203 | test('document.register attributeChangedCallback in prototype', function(done) { |
|
236 | 226 | }); |
237 | 227 | var xboo = new XBoo(); |
238 | 228 | work.appendChild(xboo); |
239 | | - setTimeout(function() { |
240 | | - var xboo2 = xboo.cloneNode(true); |
241 | | - assert(xboo2.__ready__, 'clone createdCallback must be called'); |
242 | | - done(); |
243 | | - }, 0); |
| 229 | + CustomElements.takeRecords(); |
| 230 | + var xboo2 = xboo.cloneNode(true); |
| 231 | + assert(xboo2.__ready__, 'clone createdCallback must be called'); |
| 232 | + done(); |
244 | 233 | }); |
245 | 234 | }); |
246 | 235 |
|
|
0 commit comments