Skip to content

Integrate fragment parser options with trusted types - #12583

Merged
zcorpan merged 5 commits into
mainfrom
noamr/cpo
Oct 7, 2026
Merged

zcorpan merged 5 commits into
mainfrom
noamr/cpo

Conversation

@noamr

@noamr noamr commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

In the places where Trusted Types' createHTML is called, we now also check for createParserOptions and call that if it's available, by calling "get trusted type compliant input" instead of "get trusted type compliant string".

This now allows a default policy to supply a sanitizer or change script-running behavior for the legacy markup insertion methods (innerHTML, outerHTML, insertAdjacentHTML(), createContextualFragment()), and to alter the sanitizer/script behavior of modern calls like setHTMLUnsafe() and parseHTMLUnsafe().

The exceptions to this are srcdoc, document.write(), DOMParser.parseFromString(), and the insertHTML execCommand. We can resolve separately whether these should also be sanitized with createParserOptions.

Structural changes

  • The safe boolean and scriptingMode parameters of "set and filter HTML" / "fragment parsing algorithm steps" are replaced by a single fragment parser mode enum: Safe (setHTML(), parseHTML()), Unsafe (setHTMLUnsafe(), parseHTMLUnsafe()), and Legacy (innerHTML, outerHTML, insertAdjacentHTML(), createContextualFragment()). Safe and Unsafe always use the HTML parser and allow declarative shadow roots; Legacy keeps today's behavior (XML parser in XML documents, no declarative shadow roots).

  • Since all markup insertion methods can now include a sanitizer, most of the steps from "set and filter HTML" are folded into the "fragment parsing algorithm steps" (which moved next to innerHTML), with handling of a null sanitizer when appropriate.

  • "get trusted type compliant input" takes an optionsFromAuthor boolean. It is true for author-supplied options (setHTMLUnsafe(), parseHTMLUnsafe()) and false when the sink constructs the options itself (the legacy sinks, including createContextualFragment(), which sets runScripts to true). This lets Trusted Types throw when TrustedHTML is combined with unvetted author options that need vetting (runScripts: true or a non-empty sanitizer), while not throwing for sink-constructed options.

Observable changes beyond the Trusted Types integration

  • The = {} defaults are removed from SetHTMLUnsafeOptions.sanitizer and ParseHTMLUnsafeOptions.sanitizer so that a default policy can distinguish an omitted sanitizer member from an explicit configuration.

  • A Sanitizer object passed to setHTML()/parseHTML() is no longer mutated: the sink now works on a fresh copy of its configuration, so sanitizer.get() is unchanged after use. Previously the "remove unsafe" step mutated the author's object in place.

  • "configure a sanitizer" clones its input configuration before canonicalizing, fixing an issue where the built-in safe default configuration singleton was mutated in place on first use.

  • createContextualFragment() now creates its fallback body context element in the range's start node's node document (previously "this's node document", but a Range has no node document).

  • A default policy is only allowed to provide a sanitizer for HTML documents. In XML documents the createParserOptions shortcut does not apply, so createHTML (or a TrustedHTML) is still required, exactly as today. (setHTMLUnsafe() in an XHTML document still uses the HTML parser and therefore does honor createParserOptions.)

Together with w3c/trusted-types#606, which must land first (this PR links to anchors defined there); more details on the Trusted Types side are described there.

(See WHATWG Working Mode: Changes for more details.)


/dom.html ( diff )
/dynamic-markup-insertion.html ( diff )
/iframe-embed-object.html ( diff )
/infrastructure.html ( diff )
/parsing.html ( diff )
/scripting.html ( diff )

@noamr noamr changed the title Integrate createParserOptions (draft) Integrate createParserOptions Jul 13, 2026
@noamr noamr changed the title Integrate createParserOptions Integrate fragment parser options with trusted types Jul 13, 2026
@noamr noamr closed this Jul 13, 2026
@noamr noamr reopened this Jul 13, 2026
@noamr
noamr marked this pull request as ready for review July 13, 2026 19:43
@noamr
noamr requested review from annevk, lukewarlow and zcorpan July 13, 2026 19:46
@noamr noamr added the agenda+ To be discussed at a triage meeting label Jul 15, 2026
@lukewarlow

Copy link
Copy Markdown
Member

Two things for the top comment, I don't think you do fold set and filter html anymore?

Also this also doesn't touch execCommand with the insertHTML command. (This is probably the right move because that isnt specced correctly to start with. But worth calling out probably).

Comment thread source Resolved
@noamr

noamr commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Two things for the top comment, I don't think you do fold set and filter html anymore?

Also this also doesn't touch execCommand with the insertHTML command. (This is probably the right move because that isnt specced correctly to start with. But worth calling out probably).

Thanks, OP updated.

@lukewarlow

Copy link
Copy Markdown
Member

Did we decide it was okay to not enforce the sanitizing if the document was XML?

@noamr

noamr commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Did we decide it was okay to not enforce the sanitizing if the document was XML?

That's what I understood but @mozfreddyb, @evilpie or @otherdaniel would know more. Sanitization is not specified for the XML parser.
Note that this is the status quo that is not changed here - what this does is allows you to sanitize when setting HTML with one of the old methods (and soon with streaming).

@otherdaniel

Copy link
Copy Markdown
Contributor

Did we decide it was okay to not enforce the sanitizing if the document was XML?

That's what I understood but @mozfreddyb, @evilpie or @otherdaniel would know more. Sanitization is not specified for the XML parser. Note that this is the status quo that is not changed here - what this does is allows you to sanitize when setting HTML with one of the old methods (and soon with streaming).

What I remember is that we specified Sanitizer API only for methods that would inherently only support HTML syntax. setHTML, setHTMLUnsafe, parseHTML, and parseHTMLUnsafe were all new methods, that simply don't support XML syntax. It's right there in the names. We didn't say what to do for XML syntax because we didn't have to.

This is probably best articulated in the hopelessly outdated explainer

Nearly all interesting bits are specified in terms of DOM & DOM operations, so I'd expect this to be easy to adapt to XML. But IMHO, application to XML-parser parse trees requires a second look, since it invalidates one of the assumptions we had when specifying any of this.


A silly example, but the only one I can think of: CDataSection in https://wicg.github.io/sanitizer-api/#sanitize-core step 1.1. That shouldn't be difficult to fix; but at least for now Sanitizer would assert-fail on (some) XML parse trees. In our implementation, there's a runtime assert there.

@lukewarlow

Copy link
Copy Markdown
Member

I guess my main concern is people defining a trusted types policy with this new function thinking it protects them and then it doesn't because they're in XHTML or something?

Assuming I'm reading this right you'd end up with a default policy explicitly setup to remove unsafe and then it actually no-ops when it's called by a legacy sync in XML.

@noamr

noamr commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

I guess my main concern is people defining a trusted types policy with this new function thinking it protects them and then it doesn't because they're in XHTML or something?
Assuming I'm reading this right you'd end up with a default policy explicitly setup to remove unsafe and then it actually no-ops when it's called by a legacy sync in XML.

You mean sink?

Yea it's limited in that way. But createHTML is still there... until we have some solution for this people should probably still use both in their policy or protect XML in other means.

@noamr

noamr commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

I guess my main concern is people defining a trusted types policy with this new function thinking it protects them and then it doesn't because they're in XHTML or something?
Assuming I'm reading this right you'd end up with a default policy explicitly setup to remove unsafe and then it actually no-ops when it's called by a legacy sync in XML.

You mean sink?

Yea it's limited in that way. But createHTML is still there... until we have some solution for this people should probably still use both in their policy or protect XML in other means.

I think that the specific guidance to developers to be to check the type of document when they create the default policy, use createHTML with the appropriate userland sanitizer if either this is an XML document or TrustedParserOptions is not supported, and createParserOptions otherwise

@lukewarlow

Copy link
Copy Markdown
Member

Non-authoratative LGTM. I'm still slightly unsure about the XML case mentioned above but if the consensus is that it's fine then I buy that.

@noamr noamr closed this Jul 23, 2026
@noamr noamr reopened this Jul 23, 2026
@noamr noamr removed the agenda+ To be discussed at a triage meeting label Jul 23, 2026
@noamr noamr closed this Aug 4, 2026
@noamr noamr reopened this Aug 4, 2026
@noamr

noamr commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

AI review
Line numbers are source at 8cfede2.

  • source:126248-126252, 126265-126269, 126292-126296 (domintro): the TypeError sentence is wrong. setHTMLUnsafe("<b>", {}) under enforcement with a default policy that only has createHTML doesn't throw. The options don't need vetting, so it falls through to createHTML. It only throws when neither path vets the input, or when author options need vetting and nothing vets them. It also misses the cases where createParserOptions throws or returns null.
  • source:126566, 126571 (wording): the mode definitions phrase the declarative shadow roots flag inconsistently ("while … flag is true" vs "and declarative shadow roots are allowed (the … flag is true)"). This also carries into html#12758.
  • The script note added near source:67740: it says scripts inserted via innerHTML/outerHTML/insertAdjacentHTML run if a default policy enables runScripts. The text is accurate, but this behavior plus the fact that createParserOptions bypasses createHTML (index.bs:1461-1462) would be worth a line in the Security Considerations. A default policy that does createParserOptions: o => o alongside a DOMPurify-based createHTML silently stops sanitizing innerHTML.

The this's → node's node document fix in createContextualFragment is good: Range has no node document.

Fixed all of the above

noamr and others added 4 commits October 6, 2026 13:39
createParserOptions

TrustedParseOptions in IDL

Still wrap things in set and filter HTML

Add clarification about XMLL vs HTML

Some fixes from ChatGPT

Throw when applying sanitizer to XML document in a legacy method

Rebaseline to new TT changes

Handle default sanitizer correctly when safe is false, and fix TT throwIfMissing polarity

Revert "Handle default sanitizer correctly when safe is false, and fix TT throwIfMissing polarity"

This reverts commit 7898aca.

Handle null in TrustedParserOptions

Fix ccf

Add some null checks

Address review comments for PR 12583 (TrustedParserOptions & sanitizer options)

Address Opus review notes

Improve scripting mode switchh

nit

Fix unclosed li tags in script preparation and fragment parsing

Use <span> in IDL

Fix <span> in WebIDL

Remove <code> in WebIDL

Fix WebIDL type xref and line wrapping in parseHTMLUnsafe and fragment parsing

Editorial: fix phrasing, line wrapping, and formatting in sanitizer options

Editorial: fix phrasing, line wrapping, and formatting in sanitizer options

nits

Address review comments on TrustedParserOptions & sanitizer options

specfmt

Export 'canonicalize the configuration' and 'built-in safe default configuration'

Editorial: Remove unused ParseHTMLUnsafeOptions from fragment parsing algorithm steps signature

Editorial: address review comments on CPO PR

Editorial: address style and markup reviews on CPO

Editorial: address review comments on CPO PR (B4, B9, N5, N6, N8)

Address review comments on parser options and trusted types

More explicit naming

Pass node document's type to get trusted type compliant input

Editorial: address review comments on TT and XML handling

Remove comment

Editorial: Remove inaccurate domintro sentences about XML TypeError

Editorial: note that sanitization is not supported for XML documents

TrustedParserOptions->TrustedHTMLParserOptions

Editorial: Rename sanitizerSpec to sanitizerInput in get a sanitizer instance from options

Address review feedback on fragment parser options and trusted types
This lets Trusted Types reject author-supplied `runScripts` without breaking `createContextualFragment`. See w3c/trusted-types#616.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
beckysiegel pushed a commit to chromium/chromium that referenced this pull request Oct 6, 2026
This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <[email protected]>
Commit-Queue: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1712499}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 6, 2026
This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <[email protected]>
Commit-Queue: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1712499}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 6, 2026
This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <[email protected]>
Commit-Queue: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1712499}
@annevk

annevk commented Oct 7, 2026

Copy link
Copy Markdown
Member
AI feedback

Reviewed at 6bedeb5. Lint and build pass. Checked and fine: the shallow map clone in "configure a sanitizer" is enough, because canonicalize rebuilds every nested list. Dropping sanitizer = {} changes nothing, because {} with permissive defaults removes nothing. Re-configuring a passed Sanitizer is idempotent.

Suggestions

  • Safe-mode script check: the exported "fragment parsing algorithm steps" can now return null, but its introduction doesn't say so, and only "set and filter HTML" handles that. Consider moving the script-context check back into "set and filter HTML" (guarded by "mode is Safe") so the exported algorithm always returns a fragment.
  • domintro for setHTMLUnsafe(), ShadowRoot's, and parseHTMLUnsafe(): this restates the Trusted Types algorithm in one long sentence. The first sentence also parses ambiguously ("a SetHTMLUnsafeOptions dictionary containing a sanitizer member or a TrustedHTMLParserOptions object with …"). The thing authors most need is missing: a default policy's createParserOptions replaces their sanitizer and runScripts. Consider saying that and dropping the exception enumeration.
  • TrustedHTMLParserOptions sanitizer configuration: it is already canonicalized on the Trusted Types side but goes through "configure a sanitizer" again. Either build the Sanitizer from it directly or add a note on why the second pass is harmless.

Nits

  • innerHTML, outerHTML, and insertAdjacentHTML() say "a new SetHTMLUnsafeOptions dictionary", while createContextualFragment() adds "whose other members are set to their default values". Pick one wording.
  • Fragment scripting mode: it lists only Element's setHTMLUnsafe(), and still says createContextualFragment() uses this mode without noting that a default policy can now turn it off.
  • Trusted Types terms list: the three new definitions sit after the pre-navigation check entry rather than with the other new entries.
  • Drive-by editorial changes (re-indenting the fragment serializing algorithm and outerHTML steps, <code> → <span> in IDL, "a the", missing </p></li>) make the diff harder to review. They're fine, but could be a separate editorial commit.

@noamr

noamr commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

AI feedback
Reviewed at 6bedeb5. Lint and build pass. Checked and fine: the shallow map clone in "configure a sanitizer" is enough, because canonicalize rebuilds every nested list. Dropping sanitizer = {} changes nothing, because {} with permissive defaults removes nothing. Re-configuring a passed Sanitizer is idempotent.

Suggestions

  • Safe-mode script check: the exported "fragment parsing algorithm steps" can now return null, but its introduction doesn't say so, and only "set and filter HTML" handles that. Consider moving the script-context check back into "set and filter HTML" (guarded by "mode is Safe") so the exported algorithm always returns a fragment.

Applied.

I don't think the other suggestions are necessary... People should look up trusted types for that level of detail.

@zcorpan zcorpan removed the do not merge yet Pull request must not be merged per rationale in comment label Oct 7, 2026
@zcorpan
zcorpan merged commit c60d337 into main Oct 7, 2026
2 checks passed
@zcorpan
zcorpan deleted the noamr/cpo branch October 7, 2026 10:52
zcorpan pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 7, 2026
@annevk annevk mentioned this pull request Oct 9, 2026
6 tasks done
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Oct 10, 2026
…erOptions, a=testonly

Automatic update from web-platform-tests
Apply latest spec changes for createParserOptions

This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <[email protected]>
Commit-Queue: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1712499}

--

wpt-commits: b5daf96de870b547d88d1a157a0be7b631db1f04
wpt-pr: 63321
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Oct 10, 2026
…tive, a=testonly

Automatic update from web-platform-tests
Mark createParserOptions tests non-tentative

Together with whatwg/html#12583
--

wpt-commits: 2e954fa1b216ce1332a74ec9901fa6e8cde6addf
wpt-pr: 61260
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 13, 2026
…erOptions, a=testonly

Automatic update from web-platform-tests
Apply latest spec changes for createParserOptions

This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <vogelheimchromium.org>
Commit-Queue: Noam Rosenthal <nrosenthalgoogle.com>
Cr-Commit-Position: refs/heads/main{#1712499}

--

wpt-commits: b5daf96de870b547d88d1a157a0be7b631db1f04
wpt-pr: 63321

UltraBlame original commit: a158e7688437ddc49df990c7863dd38fbf1ffd0d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 13, 2026
…tive, a=testonly

Automatic update from web-platform-tests
Mark createParserOptions tests non-tentative

Together with whatwg/html#12583
--

wpt-commits: 2e954fa1b216ce1332a74ec9901fa6e8cde6addf
wpt-pr: 61260

UltraBlame original commit: ce4b03d5bd246b0cfb0617db36575630701a3600
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 13, 2026
…erOptions, a=testonly

Automatic update from web-platform-tests
Apply latest spec changes for createParserOptions

This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <vogelheimchromium.org>
Commit-Queue: Noam Rosenthal <nrosenthalgoogle.com>
Cr-Commit-Position: refs/heads/main{#1712499}

--

wpt-commits: b5daf96de870b547d88d1a157a0be7b631db1f04
wpt-pr: 63321

UltraBlame original commit: a158e7688437ddc49df990c7863dd38fbf1ffd0d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 13, 2026
…tive, a=testonly

Automatic update from web-platform-tests
Mark createParserOptions tests non-tentative

Together with whatwg/html#12583
--

wpt-commits: 2e954fa1b216ce1332a74ec9901fa6e8cde6addf
wpt-pr: 61260

UltraBlame original commit: ce4b03d5bd246b0cfb0617db36575630701a3600
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 13, 2026
…erOptions, a=testonly

Automatic update from web-platform-tests
Apply latest spec changes for createParserOptions

This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <vogelheimchromium.org>
Commit-Queue: Noam Rosenthal <nrosenthalgoogle.com>
Cr-Commit-Position: refs/heads/main{#1712499}

--

wpt-commits: b5daf96de870b547d88d1a157a0be7b631db1f04
wpt-pr: 63321

UltraBlame original commit: a158e7688437ddc49df990c7863dd38fbf1ffd0d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 13, 2026
…tive, a=testonly

Automatic update from web-platform-tests
Mark createParserOptions tests non-tentative

Together with whatwg/html#12583
--

wpt-commits: 2e954fa1b216ce1332a74ec9901fa6e8cde6addf
wpt-pr: 61260

UltraBlame original commit: ce4b03d5bd246b0cfb0617db36575630701a3600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

7 participants