Chromium Code Reviews| 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..68f7995b84c5c014434ed0b5dfcae14d0627f7f5 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,32 @@ 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'); |
| + let constructor = function () {}; |
| + constructor.prototype.attributeChangedCallback = function () { |
| + invocations.push(arguments[0]); |
| + }; |
| + constructor.observedAttributes = {[Symbol.iterator]: |
| + function* () { yield 'a'; } |
| + }; |
| + w.customElements.define('a-a', constructor); |
| + w.document.body.appendChild(element); |
| + assert_array_equals(invocations, ['a'], 'attributeChangedCllback should be invoked once for "a"'); |
| +}, 'ObservedAttributes'); |
|
dominicc (has gone to gerrit)
2016/09/12 05:31:44
Could you write prose here? Like observed attribut
|
| + |
| +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 observedAttributes to sequence<DOMString>, not an object'); |
|
dominicc (has gone to gerrit)
2016/09/12 05:31:44
Maybe write
... non-object observedAttributes ...
|
| + |
| +test_with_window((w) => { |
| class X extends w.HTMLElement{ |
| constructor() { super(); } |
| attributeChangedCallback() {} |
| @@ -357,9 +383,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 observedAttributes to sequence<DOMString>, regular expression'); |
| + |
| +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 to sequence<DOMString>, iterator method not defined'); |
| // 14.9.2 test Get(constructor, observedAttributes) does not throw if |
| // attributeChangedCallback is undefined. |