Skip to content

Commit

Permalink
DOMParser.parseFromString() throws a TypeError
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Feb 2, 2025
1 parent 1cf107e commit da28a83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

<body>
<release version="4.10.0" date="February xx, 2025" description="Bugfixes">
<action type="fix" dev="rbri">
DOMParser.parseFromString() throws a TypeError.
</action>
<action type="fix" dev="rbri">
Window.postMessage() throws a SyntaxError.
</action>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/htmlunit/javascript/host/dom/DOMParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public Document parseFromString(final String str, final Object type) {
try {
final Document document = parseFromString(this, str, type);
if (document == null) {
throw JavaScriptEngine.reportRuntimeError("Invalid 'type' parameter: " + type);
throw JavaScriptEngine.typeError("Invalid 'type' parameter: " + type);
}
return document;
}
catch (final IOException e) {
throw JavaScriptEngine.reportRuntimeError("Parsing failed" + e.getMessage());
throw JavaScriptEngine.syntaxError("Parsing failed" + e.getMessage());
}
}

Expand All @@ -93,7 +93,7 @@ public Document parseFromString(final String str, final Object type) {
public static Document parseFromString(final HtmlUnitScriptable scriptable, final String str, final Object type)
throws IOException {
if (type == null || JavaScriptEngine.isUndefined(type)) {
throw JavaScriptEngine.reportRuntimeError("Missing 'type' parameter");
throw JavaScriptEngine.typeError("Missing 'type' parameter");
}

if (MimeType.TEXT_XML.equals(type)
Expand Down

0 comments on commit da28a83

Please sign in to comment.