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

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

Issue 2029923003: Recursively defining custom elements should not lead to redefinition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 6 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/bindings/core/v8/ScriptCustomElementDefinitionBuilder.h » ('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 c18623cf29dd794cbdee7de66793b6cbb4e4c6d3..b3fed436a10a506f3eed44e807c7e5ae27e0f68d 100644
--- a/third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html
+++ b/third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html
@@ -64,6 +64,30 @@ test_with_window((w) => {
'a NotSupportedError');
}, 'Duplicate name');
+// TODO(dominicc): Update this (perhaps by removing this comment) when
+// https://github.com/whatwg/html/pull/1333 lands/issue
+// https://github.com/whatwg/html/issues/1329 is closed.
+test_with_window((w) => {
+ class Y extends w.HTMLElement {}
+ let X = (function () {}).bind({});
+ Object.defineProperty(X, 'prototype', {
+ get() {
+ assert_throws('NotSupportedError', () => {
+ w.customElements.define('a-a', Y);
+ }, 'defining an element with a name that is being defined should ' +
+ 'throw a NotSupportedError');
+ return new Object();
+ }
+ });
+ // TODO(dominicc): When callback retrieval is implemented, change this
+ // to pass a valid constructor and recursively call define when retrieving
+ // callbacks instead; then it is possible to assert the first definition
+ // worked:
+ // let element = Reflect.construct(HTMLElement, [], X);
+ // assert_equals(element.localName, 'a-a');
+ w.customElements.define('a-a', X);
+}, 'Duplicate name defined recursively');
+
test_with_window((w) => {
class X extends w.HTMLElement {}
w.customElements.define('a-a', X);
@@ -73,6 +97,29 @@ test_with_window((w) => {
'registry should throw a NotSupportedError');
}, 'Reused constructor');
+// TODO(dominicc): Update this (perhaps by removing this comment) when
+// https://github.com/whatwg/html/pull/1333 lands/issue
+// https://github.com/whatwg/html/issues/1329 is closed.
+test_with_window((w) => {
+ let X = (function () {}).bind({});
+ Object.defineProperty(X, 'prototype', {
+ get() {
+ assert_throws('NotSupportedError', () => {
+ w.customElements.define('second-name', X);
+ }, 'defining an element with a constructor that is being defined ' +
+ 'should throw a NotSupportedError');
+ return new Object();
+ }
+ });
+ // TODO(dominicc): When callback retrieval is implemented, change this
+ // to pass a valid constructor and recursively call define when retrieving
+ // callbacks instead; then it is possible to assert the first definition
+ // worked:
+ // let element = Reflect.construct(HTMLElement, [], X);
+ // assert_equals(element.localName, 'a-a');
+ w.customElements.define('first-name', X);
+}, 'Reused constructor recursively');
+
test_with_window((w) => {
function F() {}
F.prototype = 42;
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinitionBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698