@@ -122,6 +123,34 @@
});
}, '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('');
+
+ 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('');
+
+ 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');
+