Skip to content

Commit

Permalink
HTML: test upgrade custom element failure due to disabledFeatures
Browse files Browse the repository at this point in the history
Specification PR: whatwg/html#4673.
  • Loading branch information
tkent-google authored and annevk committed Jun 11, 2019
1 parent 3436929 commit a3dcc65
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions custom-elements/upgrading.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<body>
<div id="log"></div>
<script>
setup({allow_uncaught_exception:true});

class PredefinedCustomElement extends HTMLElement {}
customElements.define('predefined-custom-element', PredefinedCustomElement);
Expand Down Expand Up @@ -185,6 +186,23 @@

});

test(() => {
class ShadowDisabledElement extends HTMLElement {
static get disabledFeatures() { return ['shadow']; }
}
let error = null;
window.addEventListener('error', e => { error = e.error; }, {once: true});
let element = document.createElement('shadow-disabled');
element.attachShadow({mode: 'open'});
customElements.define('shadow-disabled', ShadowDisabledElement);
customElements.upgrade(element);
assert_false(element instanceof ShadowDisabledElement,
'Upgrading should fail.');
assert_true(error instanceof DOMException);
assert_equals(error.name, 'NotSupportedError');
}, 'If definition\'s disable shadow is true and element\'s shadow root is ' +
'non-null, then throw a "NotSupportedError" DOMException.');

</script>
</body>
</html>

0 comments on commit a3dcc65

Please sign in to comment.