Closed Bug 1419299 Opened 7 years ago Closed 7 years ago

Fix failure WPT test for document.write() on a data document in custom-elements/parser/parser-uses-registry-of-owner-document.html

Categories

(Core :: DOM: Core & HTML, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED

People

(Reporter: jdai, Assigned: edgar)

References

Details

Priority: -- → P2
Assignee: nobody → echen
Per step 3 of https://html.spec.whatwg.org/multipage/custom-elements.html#look-up-a-custom-element-definition, if the document is a data document (e.g. the one created via createDocument()), the document doesn't have an associated browsing context ( https://html.spec.whatwg.org/multipage/browsers.html#concept-document-bc). And nsContentUtils::LookupCustomElementDefinition() should return nullptr for this case.
(In reply to Edgar Chen [:edgar] from comment #2) > And nsContentUtils::LookupCustomElementDefinition() should return nullptr > for this case. We do return nullptr for such case. The test failure is because of the incorrectness in test itself. The test is something like, ``` customElements.define("x-foo", class extends HTMLElement {}); var doc = document.implementation.createHTMLDocument(); doc.open(); doc.write('<x-foo></x-foo>'); doc.close(); var foo = doc.querySelector('x-foo'); assert_true(foo instanceof HTMLElement); assert_false(foo instanceof MyCustomElement); ``` From the spec at step 3 of https://html.spec.whatwg.org/#document-write-steps: "If document is not an active document, then return", so an write() call on a data document should do nothing. And the `foo` should be null in this case. There is a discussion about it, see https://github.com/whatwg/html/issues/2827.
Summary: HTML parser must use the registry of window.document in a document created by document.implementation.createHTMLDocument() → Fix failure WPT test for document.write() on a data document in custom-elements/parser/parser-uses-registry-of-owner-document.html
Priority: P2 → P3
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.