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

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

Issue 1983743002: When defining custom elements, check that the argument is a constructor (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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html
diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html b/third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html
index c88a11079f837407e013f958f540351cd1a598db..f678ca2115442c95bfc4fb6643640d948266462c 100644
--- a/third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html
+++ b/third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html
@@ -16,7 +16,13 @@
test_with_window((w) => {
assert_throws(TypeError.prototype, () => {
w.customElements.define('a-a', 42);
- }, 'defining a non-constructor should throw a TypeError');
+ }, 'defining a number "constructor" should throw a TypeError');
+ assert_throws(TypeError.prototype, () => {
+ w.customElements.define('a-a', () => {});
+ }, 'defining an arrow function "constructor" should throw a TypeError');
+ assert_throws(TypeError.prototype, () => {
+ w.customElements.define('a-a', { m() {} }.m);
+ }, 'defining a concise method "constructor" should throw a TypeError');
}, 'A "constructor" that is not a constructor');
test_with_window((w) => {
@@ -78,10 +84,8 @@ test_with_window((w) => {
test_with_window((w) => {
assert_throws(TypeError.prototype, () => {
- let not_a_constructor = new Object();
+ let not_a_constructor = () => {};
let invalid_name = 'annotation-xml';
- // TODO(dominicc): When V8 supports IsConstructor, replace this with a
- // function.
w.customElements.define(invalid_name, not_a_constructor);
}, 'Defining an element with an invalid name and invalid constructor ' +
'should throw a TypeError for the constructor and not a SyntaxError');
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698