Implement Trusted types document write sinks (#36824)

Implements the Document.write algorithm covering
Trusted HTML.

Part of #36258

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This commit is contained in:
Tim van der Lippe 2025-05-04 13:50:33 +02:00 committed by GitHub
parent 43edab336a
commit c00e0aae61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 142 additions and 107 deletions

View file

@ -818553,7 +818553,7 @@
]
],
"block-string-assignment-to-Document-write.html": [
"0b16a9c4910070b2bcf829d15b1aba8b7be9d060",
"c774dca4390955b3b91f1648adb18ad22bd6e355",
[
null,
{}

View file

@ -1,3 +0,0 @@
[Document-write-exception-order.xhtml]
[`document.write(string)` throws TypeError]
expected: FAIL

View file

@ -1,42 +0,0 @@
[block-string-assignment-to-Document-write.html]
[`document.write(string)` throws]
expected: FAIL
[`document.write(string, string)` throws]
expected: FAIL
[`document.write(string, TrustedHTML)` throws]
expected: FAIL
[`document.writeln(string)` throws]
expected: FAIL
[`document.writeln(string, string)` throws]
expected: FAIL
[`document.writeln(string, TrustedHTML)` throws]
expected: FAIL
[`document.write(null)` throws]
expected: FAIL
[`document.writeln(null)` throws]
expected: FAIL
[`document.write(string)` observes default policy]
expected: FAIL
[`document.write(string, string)` observes default policy]
expected: FAIL
[`document.write(string, TrustedHTML)` observes default policy]
expected: FAIL
[`document.writeln(string)` observes default policy]
expected: FAIL
[`document.writeln(string, string)` observes default policy]
expected: FAIL
[`document.writeln(string, TrustedHTML)` observes default policy]
expected: FAIL

View file

@ -1,6 +0,0 @@
[trusted-types-reporting-for-Document-write.html]
[Violation report for plain string for write() with at least one plain string argument.]
expected: FAIL
[Violation report for plain string for writeln() with at least one plain string argument.]
expected: FAIL

View file

@ -124,6 +124,9 @@
assert_equals(sink, "Document write");
} else if (html === "assertSinkEqualsDocumentWriteLn") {
assert_equals(sink, "Document writeln");
} else if (html === "assertSinkEqualsDocumentWriteLn\n") {
// Ensure that new line characters aren't incorrectly added prior to processing
assert_unreached(`Should not process any other HTML, but got "${html}"`);
}
return html.replace("Hi", "Quack")