Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom-elements: Update CustomElementRegistry.html for 'disabledFeatures'. #15516

Merged
merged 1 commit into from
Feb 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion custom-elements/CustomElementRegistry.html
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@
});
customElements.define('element-with-attribute-changed-callback', proxy);
assert_array_equals(prototypeCalls, [1, 'connectedCallback', 2, 'disconnectedCallback', 3, 'adoptedCallback', 4, 'attributeChangedCallback']);
assert_array_equals(constructorCalls, [0, 'prototype', 5, 'observedAttributes']);
assert_array_equals(constructorCalls, [0, 'prototype',
5, 'observedAttributes',
6, 'disabledFeatures']);
}, 'customElements.define must get "observedAttributes" property on the constructor prototype when "attributeChangedCallback" is present');

test(function () {
Expand Down Expand Up @@ -388,6 +390,53 @@
customElements.define('element-without-callback-with-invalid-observed-attributes', constructor);
}, 'customElements.define must not throw even if "observedAttributes" fails to convert if "attributeChangedCallback" is not defined');

test(function () {
var constructor = function () {}
var calls = [];
var proxy = new Proxy(constructor, {
get: function (target, name) {
calls.push(name);
if (name == 'disabledFeatures')
throw {name: 'expectedError'};
return target[name];
}
});
assert_throws({'name': 'expectedError'}, () => customElements.define('element-with-throwing-disabled-features', proxy));
assert_array_equals(calls, ['prototype', 'disabledFeatures'],
'customElements.define must get "prototype" and "disabledFeatures" on the constructor');
}, 'customElements.define must rethrow an exception thrown while getting disabledFeatures on the constructor prototype');

test(function () {
var constructor = function () {}
var calls = [];
var proxy = new Proxy(constructor, {
get: function (target, name) {
calls.push(name);
if (name == 'disabledFeatures')
return 1;
return target[name];
}
});
assert_throws({'name': 'TypeError'}, () => customElements.define('element-with-invalid-disabled-features', proxy));
assert_array_equals(calls, ['prototype', 'disabledFeatures'],
'customElements.define must get "prototype" and "disabledFeatures" on the constructor');
}, 'customElements.define must rethrow an exception thrown while converting the value of disabledFeatures to sequence<DOMString>');

test(function () {
var constructor = function () {}
constructor.disabledFeatures = {[Symbol.iterator]: function *() {
yield 'foo';
throw {name: 'SomeError'};
}};
assert_throws({'name': 'SomeError'}, () => customElements.define('element-with-generator-disabled-features', constructor));
}, 'customElements.define must rethrow an exception thrown while iterating over disabledFeatures to sequence<DOMString>');

test(function () {
var constructor = function () {}
constructor.disabledFeatures = {[Symbol.iterator]: 1};
assert_throws({'name': 'TypeError'}, () => customElements.define('element-with-disabled-features-with-uncallable-iterator', constructor));
}, 'customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on disabledFeatures');

test(function () {
class MyCustomElement extends HTMLElement {};
customElements.define('my-custom-element', MyCustomElement);
Expand Down