Closed Bug 1965760 Opened 3 months ago Closed 3 months ago

Document.parseHTMLUnsafe should create an inert/loaded-as-data document

Categories

(Core :: DOM: Core & HTML, task)

task

Tracking

()

RESOLVED FIXED
140 Branch
Tracking Status
firefox140 --- fixed

People

(Reporter: tschuster, Assigned: tschuster)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

I think we should always be parsing the HTML for parseHTMLUnsafe (and parseHTML) as "data" aka. "inert" documents. (This means changing the fourth parameter of NS_NewHTMLDocument)

I am mostly basing this on this note in the specification:

Since document does not have a browsing context, scripting is disabled.

https://html.spec.whatwg.org/#dom-parsehtmlunsafe

Furthermore we probably shouldn't be trying to start loading e.g. images, before the Sanitizer has a chance of running?

I currently only did this for the case when sanitizing (bug 1959727), but there really shouldn't be a difference between using a completely permissive sanitizer or no sanitizer at all. Document.parseHTMLUnsafe was added in D193676.

See also bug 1960845, which is related and about parsing <noscript>.

Flags: needinfo?(hsivonen)
Flags: needinfo?(avandolder)

During our Sanitizer meeting Anne said that he thinks these methods should behave like the DOMParser. We create "loadAsData" documents for the DOMParser as well (aLoadedAsData: true). At this point I think this is just an oversight in the initial implementation of Document.parseHTMLUnsafe.

Assignee: nobody → tschuster
Summary: Document.parseHTMLUnsafe should probably parse as "data" (aka "inert") ? → Document.parseHTMLUnsafe should create an inert/loaded-as-data document
Attachment #9487572 - Attachment description: WIP: Bug 1965760 - Document.parseHTMLUnsafe should create an inert/loaded-as-data document. → Bug 1965760 - Document.parseHTMLUnsafe should create an inert/loaded-as-data document. r?hsivonen,avandolder

As you can see from the Matrix #dom channel I have been trying to write a test that would actually show a difference in behavior, but I have failed so far.

Flags: needinfo?(hsivonen)
Flags: needinfo?(avandolder)
Pushed by tschuster@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d9bc415bac6b Document.parseHTMLUnsafe should create an inert/loaded-as-data document. r=hsivonen
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 140 Branch
QA Whiteboard: [qa-triage-done-c141/b140]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: