Menu

#1924 window.onerror does not provide a valid error object

2.27
closed
RBRi
None
1
2017-10-10
2017-10-09
No

Presently, window.onerror does not report the actual exception object which was thrown from JS - instead an error is emitted if you try to use it:

ERROR 17:28:20,432 com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter: runtimeError: message=[Invalid JavaScript value of type com.gargoylesoftware.htmlunit.ScriptException] sourceName=[script in http://localhost:12345/ from (3, 9) to (7, 10)] line=[5] lineSource=[null] lineOffset=[0]

and another if you try to assign properties to it:

ERROR 17:31:07,814 com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter: runtimeError: message=[Java class "com.gargoylesoftware.htmlunit.ScriptException" has no public instance field or method named "property".] sourceName=[script in http://localhost:12345/ from (3, 9) to (8, 10)] line=[5] lineSource=[null] lineOffset=[0]

Proposed patch and tests attached.

1 Attachments

Discussion

  • RBRi

    RBRi - 2017-10-10
    • status: open --> closed
    • assigned_to: RBRi
     
  • RBRi

    RBRi - 2017-10-10

    Fixed in svn, many thanks for finding this issue and the patch.

     
  • Colin Alworth

    Colin Alworth - 2017-10-10

    Thanks for the quick response.

    For others using an older HtmlUnit, this patch is fairly easy to backport if needed, or JavaScriptEngine can be subclassed and handleJavaScriptException overridden with the updated contents.

     
  • RBRi

    RBRi - 2017-10-10

    There is a new snapshot build available.

     

Log in to post a comment.

MongoDB Logo MongoDB