Closed Bug 705797 Opened 13 years ago Closed 12 years ago

Get weird stack trace when browser returns undefined

Categories

(Remote Protocol :: Marionette, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wlach, Unassigned)

References

Details

Attachments

(1 file)

The following script ...

m = marionette.Marionette(host='localhost', port=2828)
m.start_session()
m.execute_script("return undefined;")

... yields this stacktrace:

Traceback (most recent call last):
  File "t.py", line 8, in <module>
    m.execute_script("return undefined;")
  File "/home/wlach/src/marionette_client/marionette/marionette.py", line 254, in execute_script
    response = self._send_message('executeScript', 'value', value=script, args=script_args)
  File "/home/wlach/src/marionette_client/marionette/marionette.py", line 143, in _send_message
    self._handle_error(response)
  File "/home/wlach/src/marionette_client/marionette/marionette.py", line 172, in _handle_error
    raise MarionetteException(message=response, status=500)
marionette.errors.MarionetteException: error: {u'from': u'conn12.marionette1'}
stacktrace: None
It would be great if we got a more sensible exception/error instead.
We also get an unhelpful error if we try to start a session with a machine/port that we can't connect to.
When I run the command, I'm getting something slightly different:

>>> from marionette import Marionette
>>> marionette = Marionette('localhost', 2828)
>>> marionette.start_session()
u'session-b2g'
>>> marionette.execute_script("return undefined;")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "marionette.py", line 275, in execute_script
    response = self._send_message('executeScript', 'value', value=script, args=args)
  File "marionette.py", line 145, in _send_message
    self._handle_error(response)
  File "marionette.py", line 174, in _handle_error
    raise MarionetteException(message=response, status=500)
errors.MarionetteException
(In reply to John Hammink from comment #3)
> When I run the command, I'm getting something slightly different:
> 
> >>> from marionette import Marionette
> >>> marionette = Marionette('localhost', 2828)
> >>> marionette.start_session()
> u'session-b2g'
> >>> marionette.execute_script("return undefined;")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "marionette.py", line 275, in execute_script
>     response = self._send_message('executeScript', 'value', value=script,
> args=args)
>   File "marionette.py", line 145, in _send_message
>     self._handle_error(response)
>   File "marionette.py", line 174, in _handle_error
>     raise MarionetteException(message=response, status=500)
> errors.MarionetteException

If you use the existing unittests as a template, you don't need to create a Marionette instance or call start_session...those things are done for you.  You can use 'self.marionette' in the test code to access the Marionette instance.

Additionally, scripts are not allowed to return 'undefined'; we currently force them to return a value, otherwise we error out.  I'm not sure we definitely want to do this, though; I think it makes sense to allow scripts to returned undefined.
Attached patch patchSplinter Review
This seems like an easy fix.  A couple of tests will also have to change.
Attachment #588563 - Flags: review?(mdas)
Comment on attachment 588563 [details] [diff] [review]
patch

Review of attachment 588563 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, thanks for getting this done! Depending on what I get done today, I may push these changes out. I will update the bug if so. Otherwise, feel free to push them on Tuesday and I'll merge my impending changes with this.
Attachment #588563 - Flags: review?(mdas) → review+
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: