Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Unified Diff: third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html

Issue 2954843002: Fix upgrading built-in custom elements
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html
diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html b/third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html
index 9b5b1ddec34e801d8833681138e6f961d8ca8997..8f23a53edabf58baa2d927b2cd9c1a15d4b407a6 100644
--- a/third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html
+++ b/third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html
@@ -67,7 +67,44 @@ test_with_content((w) => {
['constructor', 'x="y"', 'connected', 'script']);
});
</script>
+<!-- TODO: the test pass now due to the elements upgrade.
+ Creating synchronously built-in elements still needs to be implemented."
+-->
+<template data-test="the parser synchronously creates built-in elements">
+ <script>
+ 'use strict';
+ window.invocations = [];
+ customElements.define('d-d', class extends HTMLDivElement {
+ constructor() {
+ super();
+ invocations.push('constructor');
+ }
+ static get observedAttributes() { return ['is']; }
+ attributeChangedCallback(name, oldValue, newValue, nsuri) {
+ invocations.push(`${name}="${newValue}"`);
+ }
+ connectedCallback() {
+ invocations.push('connected');
+ }
+ }, {extends: 'div'});
+ </script>
+ <div is="d-d">
+ <script>
+ 'use strict';
+
+ invocations.push('script');
+ </script>
+ </div>
+</template>
+<script>
+'use strict';
+
+test_with_content((w) => {
+ assert_array_equals(w.invocations,
+ ['constructor', 'is="d-d"', 'connected', 'script']);
+});
+</script>
<template data-test="foreign content insertion executes connected">
<script>
'use strict';
@@ -330,3 +367,36 @@ test_with_content((w) => {
'the second element should be un-upgraded, not failed');
});
</script>
+
+<template data-test="parsing upgrades the built-in element">
+ <div is="d-d"></div>
+ <script>
+ 'use strict';
+
+ window.invocations = [];
+ customElements.define('d-d', class extends HTMLDivElement {
+ constructor() {
+ super();
+ invocations.push('constructor');
+ }
+ static get observedAttributes() { return ['is']; }
+ attributeChangedCallback(name, oldValue, newValue, nsuri) {
+ invocations.push(`${name}="${newValue}"`);
+ }
+ connectedCallback() {
+ invocations.push('connected');
+ }
+ }, {extends: 'div'});
+ </script>
+</template>
+<script>
+'use strict';
+
+test_with_content((w) => {
+ assert_array_equals(
+ w.invocations,
+ ['constructor', 'is="d-d"', 'connected'],
+ 'the built-in element should be upgraded');
+});
+</script>
+
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Element.cpp » ('j') | third_party/WebKit/Source/core/dom/Element.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698