Skip to content

Commit 42284f8

Browse files
tete17gmta
authored andcommitted
LibWeb: Modify DomParser parseFromString to accept TrustedHTML
We made the internal changes to accept this new type, but we forgot to expose it.
1 parent 901afee commit 42284f8

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

Libraries/LibWeb/HTML/DOMParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void DOMParser::initialize(JS::Realm& realm)
3939
}
4040

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

Libraries/LibWeb/HTML/DOMParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DOMParser final : public Bindings::PlatformObject {
2424

2525
virtual ~DOMParser() override;
2626

27-
WebIDL::ExceptionOr<GC::Root<DOM::Document>> parse_from_string(Utf16String, Bindings::DOMParserSupportedType type);
27+
WebIDL::ExceptionOr<GC::Root<DOM::Document>> parse_from_string(TrustedTypes::TrustedHTMLOrString, Bindings::DOMParserSupportedType type);
2828

2929
private:
3030
explicit DOMParser(JS::Realm&);

Libraries/LibWeb/HTML/DOMParser.idl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#import <DOM/Document.idl>
2+
#import <TrustedTypes/TrustedHTML.idl>
23

34
enum DOMParserSupportedType {
45
"text/html",
@@ -13,5 +14,5 @@ enum DOMParserSupportedType {
1314
interface DOMParser {
1415
constructor();
1516

16-
Document parseFromString(Utf16DOMString string, DOMParserSupportedType type);
17+
Document parseFromString((TrustedHTML or Utf16DOMString) string, DOMParserSupportedType type);
1718
};

Tests/LibWeb/Text/expected/wpt-import/trusted-types/block-string-assignment-to-DOMParser-parseFromString.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ Harness status: OK
22

33
Found 5 tests
44

5-
4 Pass
6-
1 Fail
7-
Fail document.innerText assigned via policy (successful HTML transformation).
5+
5 Pass
6+
Pass document.innerText assigned via policy (successful HTML transformation).
87
Pass `document.innerText = string` throws.
98
Pass 'document.innerText = null' throws
109
Pass 'document.innerText = string' assigned via default policy (successful HTML transformation).

Tests/LibWeb/Text/expected/wpt-import/trusted-types/policy-without-return-value.sub.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ Harness status: OK
22

33
Found 4 tests
44

5-
3 Pass
6-
1 Fail
7-
Fail createHTML with a policy that returns undefined DOMParser
5+
4 Pass
6+
Pass createHTML with a policy that returns undefined DOMParser
87
Pass createHTML with a policy that returns undefined iframe.srcdoc
98
Pass createScript with a policy that returns undefined <div onload>
109
Pass createScriptURL with a policy that returns undefined script.src

0 commit comments

Comments
 (0)