Skip to content

Mark createParserOptions tests non-tentative - #61260

Merged
zcorpan merged 2 commits into
masterfrom
untent-cpo
Oct 7, 2026
Merged

zcorpan merged 2 commits into
masterfrom
untent-cpo

Conversation

@noamr

@noamr noamr commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Together with whatwg/html#12583

@noamr noamr changed the title Mark createParserOption tests non-tentative Mark createParserOptions tests non-tentative Sep 28, 2026
@zcorpan

zcorpan commented Oct 7, 2026

Copy link
Copy Markdown
Member
AI review

Reviewed at ee8897b, against whatwg/html c60d337 and w3c/trusted-types fbe9462. I checked the tests against the spec text (but didn't run them). The rest of the files match the merged algorithms, including the XML document type handling, optionsFromAuthor, and the report-only ordering.

Blockers

  • sanitizer-api/sethtml-with-trustedtypes-createParserOptions-null.html:16-39: Enable createParserOptions, passing a sanitizer to trusted types w3c/trusted-types#606 added a step to create a trusted type: if a named policy's createParserOptions returns null, throw a TypeError. So noSanitizerPolicy.createParserOptions({}) throws, and both tests fail in a browser that follows the spec. Nothing else in the PR tests that TypeError. Consider changing the first test to assert_throws_js(TypeError, ...) for null and undefined. The second test can go, since sethtml-with-trustedtypes-createParserOptions.html:61 already covers parser options without a sanitizer.
  • sanitizer-api/trustedhtml-unvetted-parser-options-report-only.html:61: the spec builds the sample from the sink and the first 40 characters of the source only. clipSampleIfNeeded() clips the whole string, so the test expects Element setHTMLUnsafe|<div id=wrapper><s instead of Element setHTMLUnsafe|<div id=wrapper><span id=inner></span></. Consider ${sink.sample}|${clipSampleIfNeeded(markup)}, which is how trusted-types/trusted-types-reporting.html:80 does it.

Suggestions

  • sanitizer-api/sethtml-with-trustedtypes.html:174-199: get_root() only passes options on for parseHTMLUnsafe. So for setHTMLUnsafe, "can override a sanitizer config" and "can remove a sanitizer" never send the caller's sanitizer, and the legacy sinks can't take one at all. Also, line 197 asserts #forbidden is null, but the markup doesn't contain it. Consider passing options to setHTMLUnsafe and running these two tests only for setHTMLUnsafe and parseHTMLUnsafe.
  • sanitizer-api/sethtml-xml-document-sanitizer.html:348-353: parseFromString() with a plain string already goes through the default createHTML, so createHTMLCalled is true before innerHTML runs. Consider passing testPolicy.createHTML(...) as at line 143, or resetting the flag after parsing.

Nits

  • sanitizer-api/sethtml-with-trustedtypes.html:338-348: setHTML() isn't a Trusted Types sink, and allowElements isn't a SanitizerConfig member, so this test passes whatever the Trusted Types integration does.
  • sanitizer-api/sethtml-with-trustedtypes.html:20-29 and sanitizer-api/sethtml-with-trustedtypes-createParserOptions.html:22-36: cleanupPolicy and cleanup() are never used.

@noamr

noamr commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

AI review

All points addressed.

@annevk
annevk requested a review from zcorpan October 7, 2026 12:35
@zcorpan
zcorpan merged commit 2e954fa into master Oct 7, 2026
28 checks passed
@zcorpan
zcorpan deleted the untent-cpo branch October 7, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants