gecko-dev/testing/web-platform/tests/custom-elements/parser/parser-custom-element-in-foreign-content.html
Fredrik Söderquist cc85ad830f Bug 1490790 [wpt PR 12977] - Implement step 1 of "look up a custom element definition", a=testonly
Automatic update from web-platform-testsImplement step 1 of "look up a custom element definition"

Per [1], elements with a non-HTML namespace should cause a null
custom element definition to be returned.

Implement this step.

[1] https://html.spec.whatwg.org/multipage/custom-elements.html#look-up-a-custom-element-definition

Bug: 882773
Change-Id: Idc8f4c61b94af848e13acf4ff06da2c5f6842454
Reviewed-on: https://chromium-review.googlesource.com/1221325
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#590949}

--

wpt-commits: f14bf0134dc164203c8dab1d50e0b629bef6345d
wpt-pr: 12977
2018-09-18 13:06:35 +00:00

28 lines
1.2 KiB
HTML

<!DOCTYPE html>
<title>Custom Elements: Custom element in foreign content</title>
<meta name="assert" content="HTML parser should not create non-HTML namespace custom elements">
<link rel="help" href="https://html.spec.whatwg.org/#create-an-element-for-the-token">
<link rel="help" href="https://dom.spec.whatwg.org/#concept-create-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
class ThrowsException extends HTMLElement {
constructor() {
throw 'Bad';
}
};
customElements.define('throws-exception', ThrowsException);
</script>
<svg>
<throws-exception/>
</svg>
<script>
test(function () {
var instance = document.querySelector('throws-exception');
assert_false(instance instanceof ThrowsException,
'The HTML parser must NOT instantiate a custom element in non-HTML namespaces');
assert_false(instance instanceof HTMLUnknownElement, 'The HTML parser should not fallback');
assert_true(instance instanceof SVGElement,
'The element created by the HTML parser must be an instance of SVGElement');
}, 'HTML parser should not create custom elements in non-HTML namespaces');
</script>