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

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

Issue 2321903003: Custom Elements: layout tests for observedAttributes (Closed)
Patch Set: updates in comment Created 4 years, 3 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 | no next file » | 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 ca3c310d29f87fd57cb8ce96fa2cb44683df5cdc..8f09b880642a126c3d6e22389a7d1c293c7be08d 100644
--- a/third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html
+++ b/third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html
@@ -350,6 +350,36 @@ test_with_window((w) => {
// to the result of converting observedAttributesIterable to a sequence<DOMString>.
// Rethrow any exceptions.
test_with_window((w) => {
+ let invocations = [];
+ let element = w.document.createElement('a-a');
+ element.setAttribute('a', '1');
+ element.setAttribute('b', '2');
+ element.setAttribute('c', '3');
+ let constructor = function () {};
+ constructor.prototype.attributeChangedCallback = function () {
+ invocations.push(arguments[0]);
+ };
+ constructor.observedAttributes = {[Symbol.iterator]:
+ function* () {
+ yield 'a';
+ yield 'c';
+ }
+ };
+ w.customElements.define('a-a', constructor);
+ w.document.body.appendChild(element);
+ assert_array_equals(invocations, ['a', 'c'], 'attributeChangedCallback should be invoked twice for "a" and "c"');
+}, 'ObservedAttributes are retrieved from iterators');
+
+test_with_window((w) => {
+ let constructor = function () {};
+ constructor.prototype.attributeChangedCallback = function () { };
+ constructor.observedAttributes = {[Symbol.iterator]: 1};
+ assert_throws(TypeError.prototype, () => {
+ w.customElements.define('a-a', constructor);
+ }, 'converting value that is not an object should throw TypeError');
+}, 'Converting non-object observedAttributes to sequence<DOMString>');
+
+test_with_window((w) => {
class X extends w.HTMLElement{
constructor() { super(); }
attributeChangedCallback() {}
@@ -357,9 +387,17 @@ test_with_window((w) => {
}
assert_throws(TypeError.prototype, () => {
w.customElements.define('a-a', X);
- }, 'converting RegExp to sequence<DOMString> should throw TypeError');
-}, 'exception thrown while converting observedAttributes to ' +
- 'sequence<DOMString> should be rethrown');
+ }, 'converting RegExp should throw TypeError');
+}, 'Converting regular expression observedAttributes to sequence<DOMString>');
+
+test_with_window((w) => {
+ let constructor = function () {};
+ constructor.prototype.attributeChangedCallback = function () { };
+ constructor.observedAttributes = {};
+ assert_throws(TypeError.prototype, () => {
+ w.customElements.define('a-a', constructor);
+ }, 'If iterator method is undefined, it should throw TypeError');
+}, 'Converting observedAttributes without iterator method to sequence<DOMString>');
// 14.9.2 test Get(constructor, observedAttributes) does not throw if
// attributeChangedCallback is undefined.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698