Skip to content

Commit

Permalink
CSSStyleSheet - several fixes to throw the correct error
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Feb 3, 2025
1 parent 6241a93 commit 266e078
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 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">
CSSStyleSheet - several fixes to throw the correct error.
</action>
<action type="fix" dev="rbri">
XPath.evaluate() throws a TypeError.
</action>
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/org/htmlunit/javascript/host/css/CSSStyleSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,18 @@ public int insertRule(final String rule, final int position) {
return position;
}
catch (final DOMException ex) {
throw JavaScriptEngine.throwAsScriptRuntimeEx(ex);
throw JavaScriptEngine.asJavaScriptException(
getWindow(),
new org.htmlunit.javascript.host.dom.DOMException(
ex.getMessage(),
ex.code));
}
}
throw JavaScriptEngine.throwAsScriptRuntimeEx(e);
throw JavaScriptEngine.asJavaScriptException(
getWindow(),
new org.htmlunit.javascript.host.dom.DOMException(
e.getMessage(),
e.code));
}
}

Expand Down Expand Up @@ -247,7 +255,11 @@ public void deleteRule(final int position) {
refreshCssRules();
}
catch (final DOMException e) {
throw JavaScriptEngine.throwAsScriptRuntimeEx(e);
throw JavaScriptEngine.asJavaScriptException(
getWindow(),
new org.htmlunit.javascript.host.dom.DOMException(
e.getMessage(),
e.code));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ public void ctorChangeableHasNoEffectForSealed() throws Exception {
*/
@Test
@Alerts("true")
@HtmlUnitNYI(CHROME = "exception",
EDGE = "exception",
FF = "exception",
FF_ESR = "exception")
@HtmlUnitNYI(CHROME = "TypeError",
EDGE = "TypeError",
FF = "TypeError",
FF_ESR = "TypeError")
public void ctorChangeableHasNoEffectForSealedStrict() throws Exception {
final String html = "<html><body>\n"
+ "<script>\n"
Expand Down

0 comments on commit 266e078

Please sign in to comment.