Skip to content

Commit

Permalink
more details for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Feb 3, 2025
1 parent bafa0c7 commit bfc43f9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
20 changes: 10 additions & 10 deletions src/test/java/org/htmlunit/WebDriverTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,22 @@ public abstract class WebDriverTestCase extends WebTestCase {
private static final String LOG_EX_FUNCTION =
" function logEx(e) {\n"
+ " let toStr = null;\n"
+ " if (toStr === null && e instanceof EvalError) { toStr = 'EvalError'; }\n"
+ " if (toStr === null && e instanceof RangeError) { toStr = 'RangeError'; }\n"
+ " if (toStr === null && e instanceof ReferenceError) { toStr = 'ReferenceError'; }\n"
+ " if (toStr === null && e instanceof SyntaxError) { toStr = 'SyntaxError'; }\n"
+ " if (toStr === null && e instanceof TypeError) { toStr = 'TypeError'; }\n"
+ " if (toStr === null && e instanceof URIError) { toStr = 'URIError'; }\n"
+ " if (toStr === null && e instanceof AggregateError) { toStr = 'AggregateError'; }\n"
+ " if (toStr === null && e instanceof EvalError) { toStr = ''; }\n"
+ " if (toStr === null && e instanceof RangeError) { toStr = ''; }\n"
+ " if (toStr === null && e instanceof ReferenceError) { toStr = ''; }\n"
+ " if (toStr === null && e instanceof SyntaxError) { toStr = ''; }\n"
+ " if (toStr === null && e instanceof TypeError) { toStr = ''; }\n"
+ " if (toStr === null && e instanceof URIError) { toStr = ''; }\n"
+ " if (toStr === null && e instanceof AggregateError) { toStr = '/AggregateError'; }\n"
+ " if (toStr === null && typeof InternalError == 'function' "
+ "&& e instanceof InternalError) { toStr = 'InternalError'; }\n"
+ "&& e instanceof InternalError) { toStr = '/InternalError'; }\n"
+ " if (toStr === null) {\n"
+ " let rx = /\\[object (.*)\\]/;\n"
+ " toStr = Object.prototype.toString.call(e);\n"
+ " let match = rx.exec(toStr);\n"
+ " if (match != null) { toStr = match[1]; }\n"
+ " if (match != null) { toStr = '/' + match[1]; }\n"
+ " }"
+ " log(e.name + '/' + toStr);\n"
+ " log(e.name + toStr);\n"
+ "}\n";

/**
Expand Down
38 changes: 19 additions & 19 deletions src/test/java/org/htmlunit/javascript/ErrorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public void error() throws Exception {
*/
@Test
@Alerts(DEFAULT = {"EvalError", "Whoops!", "undefined", "undefined", "undefined",
"undefined", "true", "true", "EvalError/EvalError"},
"undefined", "true", "true", "EvalError"},
FF = {"EvalError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "EvalError/EvalError"},
"true", "true", "EvalError"},
FF_ESR = {"EvalError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "EvalError/EvalError"})
"true", "true", "EvalError"})
public void evalError() throws Exception {
final String html
= "<html>\n"
Expand Down Expand Up @@ -104,11 +104,11 @@ public void evalError() throws Exception {
*/
@Test
@Alerts(DEFAULT = {"RangeError", "Whoops!", "undefined", "undefined", "undefined",
"undefined", "true", "true", "RangeError/RangeError"},
"undefined", "true", "true", "RangeError"},
FF = {"RangeError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "RangeError/RangeError"},
"true", "true", "RangeError"},
FF_ESR = {"RangeError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "RangeError/RangeError"})
"true", "true", "RangeError"})
public void rangeError() throws Exception {
final String html
= "<html>\n"
Expand Down Expand Up @@ -141,11 +141,11 @@ public void rangeError() throws Exception {
*/
@Test
@Alerts(DEFAULT = {"ReferenceError", "Whoops!", "undefined", "undefined", "undefined",
"undefined", "true", "true", "ReferenceError/ReferenceError"},
"undefined", "true", "true", "ReferenceError"},
FF = {"ReferenceError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "ReferenceError/ReferenceError"},
"true", "true", "ReferenceError"},
FF_ESR = {"ReferenceError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "ReferenceError/ReferenceError"})
"true", "true", "ReferenceError"})
public void referenceError() throws Exception {
final String html
= "<html>\n"
Expand Down Expand Up @@ -178,11 +178,11 @@ public void referenceError() throws Exception {
*/
@Test
@Alerts(DEFAULT = {"SyntaxError", "Whoops!", "undefined", "undefined", "undefined",
"undefined", "true", "true", "SyntaxError/SyntaxError"},
"undefined", "true", "true", "SyntaxError"},
FF = {"SyntaxError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "SyntaxError/SyntaxError"},
"true", "true", "SyntaxError"},
FF_ESR = {"SyntaxError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "SyntaxError/SyntaxError"})
"true", "true", "SyntaxError"})
public void syntaxError() throws Exception {
final String html
= "<html>\n"
Expand Down Expand Up @@ -215,11 +215,11 @@ public void syntaxError() throws Exception {
*/
@Test
@Alerts(DEFAULT = {"TypeError", "Whoops!", "undefined", "undefined", "undefined",
"undefined", "true", "true", "TypeError/TypeError"},
"undefined", "true", "true", "TypeError"},
FF = {"TypeError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "TypeError/TypeError"},
"true", "true", "TypeError"},
FF_ESR = {"TypeError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "TypeError/TypeError"})
"true", "true", "TypeError"})
public void typeError() throws Exception {
final String html
= "<html>\n"
Expand Down Expand Up @@ -252,11 +252,11 @@ public void typeError() throws Exception {
*/
@Test
@Alerts(DEFAULT = {"URIError", "Whoops!", "undefined", "undefined", "undefined",
"undefined", "true", "true", "URIError/URIError"},
"undefined", "true", "true", "URIError"},
FF = {"URIError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "URIError/URIError"},
"true", "true", "URIError"},
FF_ESR = {"URIError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "URIError/URIError"})
"true", "true", "URIError"})
public void uriError() throws Exception {
final String html
= "<html>\n"
Expand Down Expand Up @@ -331,7 +331,7 @@ public void aggregateError() throws Exception {
@Test
@Alerts(DEFAULT = {"ReferenceError", "InternalError is not defined",
"undefined", "undefined", "undefined",
"undefined", "true", "false", "ReferenceError/ReferenceError"},
"undefined", "true", "false", "ReferenceError"},
FF = {"InternalError", "Whoops!", "undefined", "11", "undefined", "25",
"true", "true", "InternalError/InternalError"},
FF_ESR = {"InternalError", "Whoops!", "undefined", "11", "undefined", "25",
Expand Down

0 comments on commit bfc43f9

Please sign in to comment.