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

Unified Diff: third_party/WebKit/LayoutTests/custom-elements/imports/resources/create-element.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/resources/create-element.html
diff --git a/third_party/WebKit/LayoutTests/custom-elements/imports/resources/create-element.html b/third_party/WebKit/LayoutTests/custom-elements/imports/resources/create-element.html
new file mode 100644
index 0000000000000000000000000000000000000000..728e06d9716e27be5b02f0468b5bbbc37070d160
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/custom-elements/imports/resources/create-element.html
@@ -0,0 +1,38 @@
+<script>
+'use strict';
+
+let constructors = [];
+
+test(() => {
+ assert_equals(constructors.length, 0);
+
+ class MyElement extends HTMLElement {
+ constructor() {
+ super();
+ constructors.push(this);
+ }
+ }
+
+ customElements.define('a-a', MyElement);
+
+ // createElement should synchronously call constructor.
+ let a = document.createElement('a-a');
+ assert_equals(constructors.length, 1);
+ assert_equals(a.ownerDocument, document);
+
+ let importDoc = document.currentScript.ownerDocument;
+
+ // TODO(kochi): crbug.com/640465 createElement returns wrong ownerDocument
+ // createElement should work in imported document.
+ let b = importDoc.createElement('a-a')
+ assert_equals(b.ownerDocument, importDoc);
+ assert_equals(constructors.length, 2);
+
+ // new MyElement() should synchronously call constructor.
+ let c = new MyElement();
+ assert_equals(c.ownerDocument, document);
+ assert_equals(constructors.length, e);
+
+ assert_array_equals(constructors, [a, b, c]);
+}, 'createElement() and new MyElement should work in imported document.');
+</script>

Powered by Google App Engine
This is Rietveld 408576698