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

Unified Diff: third_party/WebKit/LayoutTests/custom-elements/imports/sync-create-element-order.html

Issue 2242743002: Make custom elements work in HTML imports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses tkent's comments. Created 4 years, 4 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/imports/sync-create-element-order.html
diff --git a/third_party/WebKit/LayoutTests/custom-elements/imports/sync-create-element-order.html b/third_party/WebKit/LayoutTests/custom-elements/imports/sync-create-element-order.html
new file mode 100644
index 0000000000000000000000000000000000000000..6587255b97cb07908c28c26e3ef4972e38693f3c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/custom-elements/imports/sync-create-element-order.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+'use strict';
+
+let reactions = [];
+
+let test = async_test('Constructor should run in the order elements are created');
+
+test.step(() => {
+ customElements.define('x-x', class extends HTMLElement {
+ constructor() {
+ super();
+ reactions.push(this);
+ }
+ });
+ assert_array_equals(reactions, [], 'Should not have parsed <x-x> yet');
+});
+</script>
+
+<x-x></x-x>
+
+<script>
+'use strict';
+
+test.step(() => {
+ assert_equals(reactions.length, 1, 'Parser should invoke the custom element constructor');
+});
+
+let import1 = document.createElement('link');
+import1.rel = 'import';
+import1.href = 'resources/import-custom.html';
+
+// TODO(kochi): crbug.com/640465 synchronous creation fails in imports.
+import1.onload = test.step_func_done(() => {
+ let elementsInMaster = document.querySelector('x-x');
+ let elementsInImport = import1.import.querySelector('x-x');
+
+ assert_array_equals(reactions, [elementsInMaster, elementsInImport],
+ 'Constructor should run in the order elements are created');
+});
+
+document.head.appendChild(import1);
+</script>

Powered by Google App Engine
This is Rietveld 408576698