blob: e4b1c0e2d355f27354552083ea78175fccfdc4b6 [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
'use strict';
// The embedder may define its own elements via the CustomElementRegistry
// whose names are not valid custom element names. Ensure that script does
// not have access to such names.
var embedderName = 'embeddercustomelement';
test(() => {
assert_throws('SyntaxError', () => {
embedderName, class extends HTMLElement {});
}, 'customElements.define embedder element name');
test(() => {
assert_throws('NotSupportedError', () => {
'valid-name', class extends HTMLElement {}, {extends: embedderName});
}, 'customElements.define extending embedder element name');
promise_test((t) => {
var whenDefinedPromise = window.customElements.whenDefined(embedderName);
// With the correct behaviour, |whenDefinedPromise| will reject immediately
// and so the following will reject.
// With the incorrect behaviour, |whenDefinedPromise| will be forever
// pending. Rather than waiting for the test harness to time out, we'll
// have this resolve once we know that |whenDefinedPromise| hasn't rejected.
var rejectImmediatelyOrResolve =
Promise.race([whenDefinedPromise, Promise.resolve()]);
return promise_rejects(t, 'SyntaxError', rejectImmediatelyOrResolve);
}, 'customElements.whenDefined embedder element name');