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

Unified Diff: third_party/WebKit/LayoutTests/custom-elements/spec/construct.html

Issue 1952893003: Implement custom element construction and some 'define' checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/construct.html
diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/construct.html b/third_party/WebKit/LayoutTests/custom-elements/spec/construct.html
new file mode 100644
index 0000000000000000000000000000000000000000..f328fa130699acefa2440e71df865a7570429ad7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/custom-elements/spec/construct.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<title>Custom Elements Constructor Tests</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharness-helpers.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="resources/custom-elements-helpers.js"></script>
domenic 2016/05/05 19:15:27 In preparation for upstreaming might want to add <
+<body>
+<script>
+test_with_window((w) => {
+ assert_throws(TypeError.prototype, () => {
+ w.HTMLElement();
+ }, 'calling the HTMLElement constructor should throw a TypeError');
+}, 'HTMLElement constructor, invoke');
+
+test_with_window((w) => {
+ assert_throws(TypeError.prototype, () => {
+ new w.HTMLElement();
+ }, 'invoking the HTMLElement constructor with a construct call should ' +
+ 'throw a TypeError');
+}, 'HTMLElement constructor, construct');
+
+test_with_window((w) => {
+ class X extends w.HTMLElement {}
+ w.customElements.define('a-a', X);
+ assert_throws(TypeError.prototype, () => {
+ X();
+ }, 'calling a custom element constructor should throw a TypeError');
+}, 'Custom element constructor, invoke');
+
+test_with_window((w) => {
+ class C extends w.HTMLElement {}
+ w.customElements.define('a-a', C);
+ let e = new C();
+ assert_true(e instanceof w.HTMLElement,
justinfagnani 2016/05/05 17:04:48 might want to verify the localName
domenic 2016/05/05 19:15:27 Other ideas: e.namespaceURI === "http://www.w3.or
+ 'the element should be an HTMLElement');
+}, 'Custom element constructor, construct');
+
+test_with_window((w) => {
+ class C extends w.HTMLElement { }
+ class D extends C {}
+ w.customElements.define('a-a', C); // Note: Not D.
+ assert_throws(TypeError.prototype, () => {
+ new D();
+ },
+ 'constructing a custom element with a new.target with no registry ' +
+ 'entry should throw a TypeError');
+}, 'Custom element constructor, construct invalid new.target');
+
+// TODO(dominicc): Use Reflect.construct to set weird and wonderful new.target
+</script>

Powered by Google App Engine
This is Rietveld 408576698