LibWeb: Modify DomParser parseFromString to accept TrustedHTML

We made the internal changes to accept this new type, but we forgot to
expose it.
This commit is contained in:
Tete17 2025-10-31 20:35:07 +01:00 committed by Jelle Raaijmakers
parent 901afee50b
commit 42284f8006
Notes: github-actions[bot] 2025-12-01 08:55:42 +00:00
5 changed files with 8 additions and 9 deletions

View file

@ -39,7 +39,7 @@ void DOMParser::initialize(JS::Realm& realm)
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
WebIDL::ExceptionOr<GC::Root<DOM::Document>> DOMParser::parse_from_string(Utf16String string, Bindings::DOMParserSupportedType type)
WebIDL::ExceptionOr<GC::Root<DOM::Document>> DOMParser::parse_from_string(TrustedTypes::TrustedHTMLOrString string, Bindings::DOMParserSupportedType type)
{
// 1. Let compliantString to the result of invoking the Get Trusted Type compliant string algorithm with
// TrustedHTML, this's relevant global object, string, "DOMParser parseFromString", and "script".

View file

@ -24,7 +24,7 @@ public:
virtual ~DOMParser() override;
WebIDL::ExceptionOr<GC::Root<DOM::Document>> parse_from_string(Utf16String, Bindings::DOMParserSupportedType type);
WebIDL::ExceptionOr<GC::Root<DOM::Document>> parse_from_string(TrustedTypes::TrustedHTMLOrString, Bindings::DOMParserSupportedType type);
private:
explicit DOMParser(JS::Realm&);

View file

@ -1,4 +1,5 @@
#import <DOM/Document.idl>
#import <TrustedTypes/TrustedHTML.idl>
enum DOMParserSupportedType {
"text/html",
@ -13,5 +14,5 @@ enum DOMParserSupportedType {
interface DOMParser {
constructor();
Document parseFromString(Utf16DOMString string, DOMParserSupportedType type);
Document parseFromString((TrustedHTML or Utf16DOMString) string, DOMParserSupportedType type);
};

View file

@ -2,9 +2,8 @@ Harness status: OK
Found 5 tests
4 Pass
1 Fail
Fail document.innerText assigned via policy (successful HTML transformation).
5 Pass
Pass document.innerText assigned via policy (successful HTML transformation).
Pass `document.innerText = string` throws.
Pass 'document.innerText = null' throws
Pass 'document.innerText = string' assigned via default policy (successful HTML transformation).

View file

@ -2,9 +2,8 @@ Harness status: OK
Found 4 tests
3 Pass
1 Fail
Fail createHTML with a policy that returns undefined DOMParser
4 Pass
Pass createHTML with a policy that returns undefined DOMParser
Pass createHTML with a policy that returns undefined iframe.srcdoc
Pass createScript with a policy that returns undefined <div onload>
Pass createScriptURL with a policy that returns undefined script.src