WICG / sanitizer-api

https://wicg.github.io/sanitizer-api/
Other
231 stars 31 forks source link

HTML5lib-style test cases for Sanitizer API WPT tests #241

Open otherdaniel opened 2 months ago

otherdaniel commented 2 months ago

This issue is to track progress on using HTML5lib-style test cases for Sanitizer's WPT test cases.

Specififcally, this format: https://github.com/html5lib/html5lib-tests/blob/master/tree-construction/README.md

otherdaniel commented 2 months ago

I have two, hacky versions of how I think it could work:

1, Re-using the logic for webvtt/parsing/cue-text-parsing WPT tests

2, Doing it all in JS.

In the call, Tom pointed out two issues, IMHO both correct:


(I'm happy to convert the source to WPT GitHub-PRs, if that helps.)

annevk commented 2 months ago

Why not do 2, but have the test data in an external file? That makes it easier for others to reuse and does away with the </script> issue.

I wonder if we can handle closed shadow roots by getting references to them during setup, but I also think it would be okay if we have some tests on the side for shadow roots.

josepharhar commented 1 month ago

+1 to not having a python script if it's not a lot of work 😅

I've made small parser tests which don't use any sort of format like this one, but yeah seems good to reuse this format if you want to have more test cases that are easier to iterate on.

annevk commented 1 month ago

I think for the select enhancement in particular we should have https://github.com/html5lib/html5lib-tests coverage instead, but that's a bit off-topic for this issue.

otherdaniel commented 1 month ago

Fleshed out the code a bit more. It can now parse a string, with convenience methods to either get it from a <script> element, or from a Promise of a Response, as fetch() would return. That way, the user can pick whichever source is appropriate.

I intend to land this as a support file for Sanitizer API tests. But it's written so that it should be easy to generalize and make it more generally useful within WPT. Current version here: https://chromium-review.googlesource.com/c/chromium/src/+/5920436