mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 06:08:24 +02:00
MozReview-Commit-ID: LvpIb2OK2GS --HG-- rename : testing/web-platform/tests/conformance-checkers/html/elements/keygen/challenge-isvalid.html => testing/web-platform/tests/conformance-checkers/html/elements/keygen/challenge-novalid.html rename : testing/web-platform/tests/conformance-checkers/html/elements/keygen/keytype-isvalid.html => testing/web-platform/tests/conformance-checkers/html/elements/keygen/keytype-novalid.html rename : testing/web-platform/tests/conformance-checkers/html/elements/keygen/model-isvalid.html => testing/web-platform/tests/conformance-checkers/html/elements/keygen/model-also-novalid.html rename : testing/web-platform/tests/conformance-checkers/html/elements/keygen/no-attributes-isvalid.html => testing/web-platform/tests/conformance-checkers/html/elements/keygen/no-attributes-novalid.html rename : testing/web-platform/tests/conformance-checkers/xhtml/elements/keygen/054-isvalid.xhtml => testing/web-platform/tests/conformance-checkers/xhtml/elements/keygen/054-also-novalid.xhtml rename : testing/web-platform/tests/conformance-checkers/xhtml/elements/keygen/055-isvalid.xhtml => testing/web-platform/tests/conformance-checkers/xhtml/elements/keygen/055-also-novalid.xhtml rename : testing/web-platform/tests/conformance-checkers/xhtml/elements/keygen/056-isvalid.xhtml => testing/web-platform/tests/conformance-checkers/xhtml/elements/keygen/056-also-novalid.xhtml rename : testing/web-platform/tests/conformance-checkers/xhtml/elements/keygen/057-isvalid.xhtml => testing/web-platform/tests/conformance-checkers/xhtml/elements/keygen/057-also-novalid.xhtml rename : testing/web-platform/tests/conformance-checkers/xhtml/elements/keygen/058-isvalid.xhtml => testing/web-platform/tests/conformance-checkers/xhtml/elements/keygen/058-also-novalid.xhtml rename : testing/web-platform/tests/html-media-capture/capture_fallback_file_upload.html => testing/web-platform/tests/html-media-capture/capture_fallback_file_upload-manual.html rename : testing/web-platform/tests/html/obsolete/requirements-for-implementations/the-marquee-element-0/marquee-start.html => testing/web-platform/tests/html/obsolete/requirements-for-implementations/the-marquee-element-0/marquee-start-manual.html rename : testing/web-platform/tests/html/obsolete/requirements-for-implementations/the-marquee-element-0/marquee-stop.html => testing/web-platform/tests/html/obsolete/requirements-for-implementations/the-marquee-element-0/marquee-stop-manual.html rename : testing/web-platform/tests/service-workers/cache-storage/serviceworker/credentials.html => testing/web-platform/tests/service-workers/cache-storage/serviceworker/credentials.https.html
75 lines
3.5 KiB
HTML
75 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Custom Elements: HTML parser must construct a custom element instead of upgrading</title>
|
|
<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
|
|
<meta name="assert" content="HTML parser must construct a custom element instead of upgrading">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<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">
|
|
</head>
|
|
<body>
|
|
<div id="log"></div>
|
|
<script>
|
|
|
|
let anotherElementCreatedBeforeSuperCall = undefined;
|
|
let elementCreatedBySuperCall = undefined;
|
|
let shouldCreateElementBeforeSuperCall = true;
|
|
class InstantiatesItselfBeforeSuper extends HTMLElement {
|
|
constructor() {
|
|
if (shouldCreateElementBeforeSuperCall) {
|
|
shouldCreateElementBeforeSuperCall = false;
|
|
anotherElementCreatedBeforeSuperCall = new InstantiatesItselfBeforeSuper();
|
|
}
|
|
super();
|
|
elementCreatedBySuperCall = this;
|
|
}
|
|
};
|
|
customElements.define('instantiates-itself-before-super', InstantiatesItselfBeforeSuper);
|
|
|
|
let shouldCreateAnotherInstance = true;
|
|
let anotherInstance = undefined;
|
|
let firstInstance = undefined;
|
|
class ReturnsAnotherInstance extends HTMLElement {
|
|
constructor() {
|
|
super();
|
|
if (shouldCreateAnotherInstance) {
|
|
shouldCreateAnotherInstance = false;
|
|
firstInstance = this;
|
|
anotherInstance = new ReturnsAnotherInstance;
|
|
return anotherInstance;
|
|
} else
|
|
return this;
|
|
}
|
|
};
|
|
customElements.define('returns-another-instance', ReturnsAnotherInstance);
|
|
|
|
</script>
|
|
<instantiates-itself-before-super></instantiates-itself-before-super>
|
|
<returns-another-instance></returns-another-instance>
|
|
<script>
|
|
|
|
test(function () {
|
|
var instance = document.querySelector('instantiates-itself-before-super');
|
|
|
|
assert_true(instance instanceof InstantiatesItselfBeforeSuper, 'HTML parser must insert the synchronously constructed custom element');
|
|
assert_equals(instance, elementCreatedBySuperCall, 'HTML parser must insert the element returned by the custom element constructor');
|
|
assert_not_equals(instance, anotherElementCreatedBeforeSuperCall, 'HTML parser must not insert another instance of the custom element created before super() call');
|
|
assert_equals(anotherElementCreatedBeforeSuperCall.parentNode, null, 'HTML parser must not insert another instance of the custom element created before super() call');
|
|
|
|
}, 'HTML parser must use the returned value of the custom element constructor instead of the one created before super() call');
|
|
|
|
test(function () {
|
|
var instance = document.querySelector('returns-another-instance');
|
|
|
|
assert_true(instance instanceof ReturnsAnotherInstance, 'HTML parser must insert the synchronously constructed custom element');
|
|
assert_equals(instance, anotherInstance, 'HTML parser must insert the element returned by the custom element constructor');
|
|
assert_not_equals(instance, firstInstance, 'HTML parser must not insert the element created by super() call if the constructor returned another element');
|
|
assert_equals(firstInstance.parentNode, null, 'HTML parser must not insert the element created by super() call if the constructor returned another element');
|
|
|
|
}, 'HTML parser must use the returned value of the custom element constructor instead using the one created in super() call');
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|