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

Unified Diff: third_party/WebKit/LayoutTests/custom-elements/spec/state-failed-upgrade.html

Issue 2173623003: Add "Failed" custom element state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoid multiple toElement Created 4 years, 5 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/state-failed-upgrade.html
diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/state-failed-upgrade.html b/third_party/WebKit/LayoutTests/custom-elements/spec/state-failed-upgrade.html
new file mode 100644
index 0000000000000000000000000000000000000000..995ee272ea2a87d5ddfcf3a51a08282c01718bd2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/custom-elements/spec/state-failed-upgrade.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<title>Custom Elements: Custom Element State "Failed" in Upgrades</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="resources/custom-elements-helpers.js"></script>
+<body>
+<script>
+'use strict';
+
+// Custom Element State
+// https://dom.spec.whatwg.org/#concept-element-custom-element-state
+
+test_with_window(w => {
+ let document = w.document;
+ let element = document.createElement('a-a');
+
+ let constructorCount = 0;
+ w.customElements.define('a-a', class extends w.HTMLElement {
+ constructor() {
+ constructorCount++;
+ throw new Error();
+ }
+ connectedCallback() {
+ assert_unreached('connectedCallback should not be invoked if constructor threw');
+ }
+ });
+
+ // Upgrade calls the constructor.
+ // 9. If constructResult is an abrupt completion, then
+ // Set element's custom element state to "failed".
+ // https://html.spec.whatwg.org/multipage/scripting.html#upgrades
+ let container = document.body;
+ container.appendChild(element);
+ assert_equals(constructorCount, 1, 'constructor should be invoked once');
+
+ // "failed" is not "defined"
+ // https://dom.spec.whatwg.org/#concept-element-defined
+ assert_false(element.matches(':defined'));
+});
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698