| 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
|
| index 18a7f79884e7d286444dc8fade2b131305fc5363..d8396829b51388a2adc9ea987b22eb15271ab25d 100644
|
| --- a/third_party/WebKit/LayoutTests/custom-elements/spec/construct.html
|
| +++ b/third_party/WebKit/LayoutTests/custom-elements/spec/construct.html
|
| @@ -58,6 +58,7 @@ test_with_window((w) => {
|
| assert_equals(num_constructor_invocations,
|
| 1,
|
| 'the constructor should have been invoked once');
|
| + assert_true(e.matches(':defined'), 'custom element constructed with new should be "custom"');
|
| }, 'Custom element constructor, construct');
|
|
|
| test_with_window((w) => {
|
| @@ -74,4 +75,76 @@ test_with_window((w) => {
|
| }, 'constructing a custom element with a non-object new.target should ' +
|
| 'throw a TypeError');
|
| }, 'Custom element constructor, construct invalid new.target');
|
| +
|
| +test_with_window((w) => {
|
| + w.customElements.define('a-a', w.HTMLButtonElement);
|
| + assert_throws(TypeError.prototype, () => {
|
| + w.document.createElement('a-a');
|
| + }, 'If NewTarget is equal to active function object, TypeError should be thrown');
|
| +}, 'Custom element constructor, NewTarget is equal to active function object');
|
| +
|
| +test_with_window((w) => {
|
| + w.customElements.define('a-a', class extends w.HTMLButtonElement {} );
|
| + assert_throws(TypeError.prototype, () => {
|
| + w.document.createElement('a-a');
|
| + }, 'If NewTarget is equal to active function object, TypeError should be thrown');
|
| +}, 'Custom element constructor, active function object is not equal to HTMLElement');
|
| +
|
| +test_with_window((w) => {
|
| + let flag = true;
|
| + class A extends w.HTMLElement {
|
| + constructor() {
|
| + if (flag) {
|
| + flag = false;
|
| + new A();
|
| + }
|
| + super();
|
| + }
|
| + }
|
| + w.customElements.define('a-a', A);
|
| + let e = new A();
|
| + assert_true(e.matches(':defined'),
|
| + 'constructing a custom element with new should not throw InvalidStateError ' +
|
| + 'and should return a "custom" element');
|
| +}, 'Already constructed marker, construct with new');
|
| +
|
| +test_with_window((w) => {
|
| + let flag = true;
|
| + class A extends w.HTMLElement {
|
| + constructor() {
|
| + if (flag) {
|
| + flag = false;
|
| + new A();
|
| + }
|
| + super();
|
| + }
|
| + }
|
| + w.customElements.define('a-a', A);
|
| + assert_throws_dom_exception(w, 'INVALID_STATE_ERR', () => {
|
| + w.document.createElement('a-a');
|
| + }, 'Creating an element that is already constructed marker should throw InvalidStateError');
|
| +}, 'Already constructed marker, create element');
|
| +
|
| +test_with_window((w) => {
|
| + let errors = [];
|
| + w.onerror = function (event, source, lineno, colno, error) {
|
| + errors.push(error.name);
|
| + return true;
|
| + };
|
| + let flag = true;
|
| + let e = w.document.createElement('a-a');
|
| + class A extends w.HTMLElement {
|
| + constructor() {
|
| + if (flag) {
|
| + flag = false;
|
| + new A();
|
| + }
|
| + super();
|
| + }
|
| + }
|
| + w.customElements.define('a-a', A);
|
| + w.document.body.appendChild(e);
|
| + assert_array_equals(errors, ['InvalidStateError'], 'Upgrading an element ' +
|
| + 'that is already constructed marker should throw InvalidStateError');
|
| +}, 'Already constructed marker, upgrade element');
|
| </script>
|
|
|