Commit c5d4791f authored by Chromium WPT Sync's avatar Chromium WPT Sync Committed by Commit Bot

Import wpt@5cb6c2516290bdd9349d37f21e32c435da41a81b

Using wpt-import in Chromium a3ce2d31.

Build: https://ci.chromium.org/buildbot/chromium.infra.cron/wpt-importer/6949

Note to sheriffs: This CL imports external tests and adds
expectations for those tests; if this CL is large and causes
a few new failures, please fix the failures by adding new
lines to TestExpectations rather than reverting. See:
https://chromium.googlesource.com/chromium/src/+/master/docs/testing/web_platform_tests.md

TBR=qyearsley

No-Export: true
Change-Id: I1855fb7a5a8fdc38751eea78ed990db382a84f5f
Reviewed-on: https://chromium-review.googlesource.com/809188
Commit-Queue: Blink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Reviewed-by: default avatarBlink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521810}
parent 7302da85
This is a testharness.js-based test.
PASS HTML parser must not instantiate custom elements inside template elements
PASS HTML parser must not use the registry of the owner element's document inside an iframe
PASS HTML parser must use the registry of the content document inside an iframe
PASS HTML parser must not instantiate a custom element defined inside an frame in frame element's owner document
PASS HTML parser must use the registry of window.document in a document created by DOMParser
PASS HTML parser must use the registry of window.document in a document created by document.implementation.createXHTMLDocument()
PASS HTML parser must use the registry of window.document in a document created by new Document
PASS HTML parser must use the registry of window.document in a document created by XMLHttpRequest
FAIL document.write() must not instantiate a custom element without a defined insertion point assert_false: expected false got true
FAIL document.writeln() must not instantiate a custom element without a defined insertion point assert_false: expected false got true
Harness: the test ran to completion.
......@@ -8,6 +8,7 @@
<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 src="../resources/custom-elements-helpers.js"></script>
</head>
<body>
<div id="log"></div>
......@@ -122,6 +123,34 @@ promise_test(function () {
});
}, 'HTML parser must use the registry of window.document in a document created by XMLHttpRequest');
test_with_window(function (contentWindow, contentDocument) {
const element = define_custom_element_in_window(contentWindow, 'my-custom-element', []);
// document-open-steps spec doesn't match most browsers; see https://github.com/whatwg/html/issues/1698.
// However, as explained in https://github.com/whatwg/html/issues/1698#issuecomment-298748641
// the custom element registry will be replaced after document-open-steps.
contentDocument.write('<my-custom-element></my-custom-element>');
var instance = contentDocument.querySelector('my-custom-element');
assert_true(instance instanceof contentWindow.HTMLElement);
assert_false(instance instanceof element.class);
}, 'document.write() must not instantiate a custom element without a defined insertion point');
test_with_window(function (contentWindow, contentDocument) {
const element = define_custom_element_in_window(contentWindow, 'my-custom-element', []);
// document-open-steps spec doesn't match most browsers; see https://github.com/whatwg/html/issues/1698.
// However, as explained in https://github.com/whatwg/html/issues/1698#issuecomment-298748641
// the custom element registry will be replaced after document-open-steps.
contentDocument.writeln('<my-custom-element></my-custom-element>');
var instance = contentDocument.querySelector('my-custom-element');
assert_true(instance instanceof contentWindow.HTMLElement);
assert_false(instance instanceof element.class);
}, 'document.writeln() must not instantiate a custom element without a defined insertion point');
</script>
</body>
</html>
......@@ -129,6 +129,12 @@ test_with_window(function (contentWindow, contentDocument) {
}, 'write on Document must enqueue disconnectedCallback when removing a custom element');
test_with_window(function (contentWindow, contentDocument) {
contentWindow.document.open();
// document.open()'s spec doesn't match most browsers; see https://github.com/whatwg/html/issues/1698.
// However, as explained in https://github.com/whatwg/html/issues/1698#issuecomment-298748641
// the custom element registry will be replaced after document.open() call,
// So call customElements.define() after that in order to register defintion
// to correct custom elements registry.
const element = define_custom_element_in_window(contentWindow, 'custom-element', []);
contentWindow.document.write('<custom-element></custom-element>');
assert_array_equals(element.takeLog().types(), ['constructed', 'connected']);
......@@ -144,6 +150,12 @@ test_with_window(function (contentWindow, contentDocument) {
}, 'writeln on Document must enqueue disconnectedCallback when removing a custom element');
test_with_window(function (contentWindow) {
contentWindow.document.open();
// document.open()'s spec doesn't match most browsers; see https://github.com/whatwg/html/issues/1698.
// However, as explained in https://github.com/whatwg/html/issues/1698#issuecomment-298748641
// the custom element registry will be replaced after document.open() call,
// So call customElements.define() after that in order to register defintion
// to correct custom elements registry.
const element = define_custom_element_in_window(contentWindow, 'custom-element', []);
contentWindow.document.writeln('<custom-element></custom-element>');
assert_array_equals(element.takeLog().types(), ['constructed', 'connected']);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment