Bug 1463963 [wpt PR 11131] - Add a test for connectedCallback, a=testonly
authorManuel Rego Casasnovas <rego@igalia.com>
Wed, 06 Jun 2018 16:23:20 +0000
changeset 478922 6e557626edd0235fd17e45705cf04d8f26d119f4
parent 478921 1b4b7c3babaaf64a2b7eae7a6fa0f3c3c225ae9c
child 478923 6489b0fa1d0384b2b8ca8b8e297a769fa3b0ff33
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1463963, 11131
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1463963 [wpt PR 11131] - Add a test for connectedCallback, a=testonly Automatic update from web-platform-testsMerge pull request #11131 from Igalia/webkit_bug_183586 Add a test for connectedCallback -- wpt-commits: a4d78aa967c23bd610fbad4ea6908aec2ddc858a wpt-pr: 11131
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/custom-elements/connected-callbacks-html-fragment-parsing.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -324564,16 +324564,22 @@
     ]
    ],
    "custom-elements/builtin-coverage.html": [
     [
      "/custom-elements/builtin-coverage.html",
      {}
     ]
    ],
+   "custom-elements/connected-callbacks-html-fragment-parsing.html": [
+    [
+     "/custom-elements/connected-callbacks-html-fragment-parsing.html",
+     {}
+    ]
+   ],
    "custom-elements/connected-callbacks.html": [
     [
      "/custom-elements/connected-callbacks.html",
      {}
     ]
    ],
    "custom-elements/custom-element-reaction-queue.html": [
     [
@@ -553285,16 +553291,20 @@
   "custom-elements/attribute-changed-callback.html": [
    "320fb2bb26e7495d0829c39c113df3ea7ec1f4ef",
    "testharness"
   ],
   "custom-elements/builtin-coverage.html": [
    "14cda641d06979600b461a4985f36c1fbc3defc9",
    "testharness"
   ],
+  "custom-elements/connected-callbacks-html-fragment-parsing.html": [
+   "49a6cb40fa477fee798d7d09b4bd79c2aaa0fd2a",
+   "testharness"
+  ],
   "custom-elements/connected-callbacks.html": [
    "615db12371d6f1f0ed6763abee3a84af9f87c0b2",
    "testharness"
   ],
   "custom-elements/custom-element-reaction-queue.html": [
    "68b226d776736e6044f842c440b42606b63c7175",
    "testharness"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/custom-elements/connected-callbacks-html-fragment-parsing.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Custom Elements: the HTML fragment parsing algorithm must not create a custom element synchronously</title>
+<meta name="author" title="Rob Buis" href="mailto:rbuis@igalia.com">
+<meta name="assert" content="The HTML fragment parsing algorithm must enqueue a custom element upgrade reaction instead of synchronously invoking its constructor">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/custom-elements-helpers.js"></script>
+</head>
+<body>
+<div id="log"></div>
+<script>
+
+let iteration = 0;
+
+document_types().forEach(function (entry) {
+    var documentName = entry.name;
+    var getDocument = entry.create;
+    let calls = 0;
+
+    promise_test(function () {
+        class Parenter extends HTMLElement {
+            connectedCallback() {
+                const child = this.firstChild;
+                this.removeChild(child);
+                this.appendChild(child);
+            }
+        }
+        class Child extends HTMLElement {
+            connectedCallback() { calls++; }
+        }
+        iteration++;
+        let parenter = 'x-parenter' + iteration;
+        let child = 'x-child' + iteration;
+        customElements.define(parenter, Parenter);
+        customElements.define(child, Child);
+        return getDocument().then(function (doc) {
+            document.documentElement.innerHTML = `<${parenter}><${child}></${child}></${parenter}>`;
+            doc.documentElement.appendChild(document.documentElement.firstChild);
+            assert_equals(calls, 1);
+        });
+    }, `Inserting a custom element into ${documentName} using HTML fragment parsing must enqueue a custom element upgrade reaction, not synchronously invoke its constructor`);
+});
+
+</script>
+</body>
+</html>