OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/dom/custom/CustomElementsRegistry.h" | 5 #include "core/dom/custom/CustomElementsRegistry.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ScriptValue.h" | 8 #include "bindings/core/v8/ScriptValue.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 224 } |
225 | 225 |
226 class TestCustomElementDefinition : public CustomElementDefinition { | 226 class TestCustomElementDefinition : public CustomElementDefinition { |
227 WTF_MAKE_NONCOPYABLE(TestCustomElementDefinition); | 227 WTF_MAKE_NONCOPYABLE(TestCustomElementDefinition); |
228 public: | 228 public: |
229 TestCustomElementDefinition(const CustomElementDescriptor& descriptor) | 229 TestCustomElementDefinition(const CustomElementDescriptor& descriptor) |
230 : CustomElementDefinition(descriptor) | 230 : CustomElementDefinition(descriptor) |
231 { | 231 { |
232 } | 232 } |
233 | 233 |
| 234 TestCustomElementDefinition(const CustomElementDescriptor& descriptor, |
| 235 const HashSet<AtomicString>& observedAttributes) |
| 236 : CustomElementDefinition(descriptor, observedAttributes) |
| 237 { |
| 238 } |
| 239 |
234 ~TestCustomElementDefinition() override = default; | 240 ~TestCustomElementDefinition() override = default; |
235 | 241 |
236 ScriptValue getConstructorForScript() override | 242 ScriptValue getConstructorForScript() override |
237 { | 243 { |
238 return ScriptValue(); | 244 return ScriptValue(); |
239 } | 245 } |
240 | 246 |
241 bool runConstructor(Element* element) override | 247 bool runConstructor(Element* element) override |
242 { | 248 { |
243 if (constructionStack().isEmpty() | 249 if (constructionStack().isEmpty() |
(...skipping 14 matching lines...) Expand all Loading... |
258 return nullptr; | 264 return nullptr; |
259 } | 265 } |
260 }; | 266 }; |
261 | 267 |
262 // Classes which use trace macros cannot be local because of the | 268 // Classes which use trace macros cannot be local because of the |
263 // traceImpl template. | 269 // traceImpl template. |
264 class LogUpgradeDefinition : public TestCustomElementDefinition { | 270 class LogUpgradeDefinition : public TestCustomElementDefinition { |
265 WTF_MAKE_NONCOPYABLE(LogUpgradeDefinition); | 271 WTF_MAKE_NONCOPYABLE(LogUpgradeDefinition); |
266 public: | 272 public: |
267 LogUpgradeDefinition(const CustomElementDescriptor& descriptor) | 273 LogUpgradeDefinition(const CustomElementDescriptor& descriptor) |
268 : TestCustomElementDefinition(descriptor) | 274 : TestCustomElementDefinition(descriptor, { |
| 275 "attr1", |
| 276 "attr2", |
| 277 HTMLNames::contenteditableAttr.localName(), |
| 278 }) |
269 { | 279 { |
270 m_observedAttributes.add("attr1"); | |
271 m_observedAttributes.add("attr2"); | |
272 m_observedAttributes.add(HTMLNames::contenteditableAttr.localName()); | |
273 } | 280 } |
274 | 281 |
275 DEFINE_INLINE_VIRTUAL_TRACE() | 282 DEFINE_INLINE_VIRTUAL_TRACE() |
276 { | 283 { |
277 TestCustomElementDefinition::trace(visitor); | 284 TestCustomElementDefinition::trace(visitor); |
278 visitor->trace(m_element); | 285 visitor->trace(m_element); |
279 } | 286 } |
280 | 287 |
281 // TODO(dominicc): Make this class collect a vector of what's | 288 // TODO(dominicc): Make this class collect a vector of what's |
282 // upgraded; it will be useful in more tests. | 289 // upgraded; it will be useful in more tests. |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 << "remove() should invoke disconnectedCallback"; | 468 << "remove() should invoke disconnectedCallback"; |
462 | 469 |
463 EXPECT_EQ(1u, definition->m_logs.size()) | 470 EXPECT_EQ(1u, definition->m_logs.size()) |
464 << "remove() should not invoke other callbacks"; | 471 << "remove() should not invoke other callbacks"; |
465 } | 472 } |
466 | 473 |
467 // TODO(dominicc): Add tests which adjust the "is" attribute when type | 474 // TODO(dominicc): Add tests which adjust the "is" attribute when type |
468 // extensions are implemented. | 475 // extensions are implemented. |
469 | 476 |
470 } // namespace blink | 477 } // namespace blink |
OLD | NEW |