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> |