Closed Bug 873591 Opened 7 years ago Closed 6 years ago

Add line numbers/filenames to JS scripts we evaluate

Categories

(Testing :: Marionette, defect)

defect
Not set

Tracking

(firefox24 fixed, b2g18 fixed, b2g18-v1.0.0 wontfix, b2g18-v1.0.1 wontfix, b2g-v1.1hd fixed)

RESOLVED FIXED
mozilla24
Tracking Status
firefox24 --- fixed
b2g18 --- fixed
b2g18-v1.0.0 --- wontfix
b2g18-v1.0.1 --- wontfix
b2g-v1.1hd --- fixed

People

(Reporter: mdas, Assigned: jgriffin)

References

Details

Attachments

(1 file, 1 obsolete file)

For clearer error reporting when we're executing JS code, we might be able to take advantage of the optional arguments to evalInSandbox(https://developer.mozilla.org/en-US/docs/Components.utils.evalInSandbox#Optional_Arguments), so we can pinpoint the line that's causing the JS exception.

Source for evalInSandbox if necessary:
http://mxr.mozilla.org/mozilla-central/source/js/xpconnect/src/XPCComponents.cpp#3833
Any chance of this landing sometime soon?
I'll take care of it in the next day or two.
Assignee: nobody → jgriffin
ok, I have a patch for this.  If you have code like this:

self.marionette.execute_script("""
let a = 1;
return foo;
""")

You'll get an error like this:

TEST-UNEXPECTED-FAIL | test_foo.py TestFoo.test_foo | JavascriptException: ReferenceError: foo is not defined
	stacktrace:
	execute_script @test_foo.py, line 10
	inline javascript, line 2
	src: "return foo;"
Pushed to try: https://tbpl.mozilla.org/?tree=Try&rev=5c7c8b495762.  Will flag for review if those goes green.
Attachment #765104 - Flags: review?(mdas)
Add missing changes to marionette.py, document parameters to createStackMessage.  I don't really like that this has a copy of createStackMessage in both -listeners.js and -server.js, but we don't have a good place to share code between the two right now.  I guess we could create a marionette-common.js that gets loaded by both, what do you think?
Attachment #765578 - Flags: review?(mdas)
Attachment #765104 - Attachment is obsolete: true
Attachment #765104 - Flags: review?(mdas)
Attachment #765578 - Flags: review?(mdas) → review+
(In reply to Jonathan Griffin (:jgriffin) from comment #5)
>  I guess we could create a marionette-common.js that gets loaded by both, what do you think?

Oh sorry, I missed this. Sounds like it would useful enough for this case alone, so we don't need to maintain it in two files.
https://hg.mozilla.org/integration/mozilla-inbound/rev/086b4d0b6cc6

I'm going to ticket marionette-common.js separately.
Target Milestone: --- → mozilla24
https://hg.mozilla.org/mozilla-central/rev/086b4d0b6cc6
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.