Closed
Bug 1128760
Opened 11 years ago
Closed 11 years ago
Content javascript exceptions cause Marionette JavascriptException during chrome context execute_script
Categories
(Remote Protocol :: Marionette, defect)
Remote Protocol
Marionette
Tracking
(firefox38 fixed)
RESOLVED
FIXED
mozilla38
| Tracking | Status | |
|---|---|---|
| firefox38 | --- | fixed |
People
(Reporter: erahm, Assigned: erahm)
Details
(Keywords: pi-marionette-server)
Attachments
(3 files, 1 obsolete file)
|
1.05 KB,
text/x-python
|
Details | |
|
2.62 KB,
patch
|
jgriffin
:
review+
automatedtester
:
feedback+
|
Details | Diff | Splinter Review |
|
4.65 KB,
patch
|
jgriffin
:
review+
|
Details | Diff | Splinter Review |
When executing a script via |self.marionette.execute_async_script| [1] in the chrome context I'm getting a JavascriptException for an unrelated javascript (in this case it's reporting an exception in one of the loaded pages).
Example code:
> gc_script = """
> const Cu = Components.utils;
> const Cc = Components.classes;
> const Ci = Components.interfaces;
>
> Cu.import("resource://gre/modules/Services.jsm");
> Services.obs.notifyObservers(null, "child-mmu-request", null);
> let memMgrSvc = Cc["@mozilla.org/memory-reporter-manager;1"].getService(Ci.nsIMemoryReporterManager);
> memMgrSvc.minimizeMemoryUsage(() => marionetteScriptFinished("gc done!"));
> """
> result = None
> try:
> result = self.marionette.execute_async_script(gc_script, script_timeout=180000);
> except JavascriptException, e:
> self.logger.error("GC JavaScript error: %s" % e)
And the exception that gets logged:
>18:29.92 LOG: MainThread ERROR GC JavaScript error: JavascriptException: TypeError: Argument 1 of Window.getComputedStyle is not an object. at: http://localhost:8095/tp5/aljazeera.net/widgets.twimg.com/j/2/widget.js line: 53
[1] https://github.com/EricRahm/areweslimyet/blob/marionette/benchtester/test_memory_usage.py#L191
| Assignee | ||
Comment 1•11 years ago
|
||
Simple marionette test case that reproduces the issue.
Comment 2•11 years ago
|
||
This behavior is by design. Basically, when we invoke an async script, we have to register a window.onerror handler, and we can't tell whether any errors that occur originated with the script being executed or something else (like the current page), since they occur in the same context.
We've talked in the past about the possibility of adding an option to _not_ register this handler, but we haven't (AFAICT) implemented it.
| Assignee | ||
Comment 3•11 years ago
|
||
(In reply to Jonathan Griffin (:jgriffin) from comment #2)
> This behavior is by design. Basically, when we invoke an async script, we
> have to register a window.onerror handler, and we can't tell whether any
> errors that occur originated with the script being executed or something
> else (like the current page), since they occur in the same context.
>
> We've talked in the past about the possibility of adding an option to _not_
> register this handler, but we haven't (AFAICT) implemented it.
It's surprising that errors from the content context are getting mixed in w/ errors in the chrome context.
Unfortunately this blocks AWSY's switch to marionette, so some sort of option to at least disable this behavior would be useful.
Comment 4•11 years ago
|
||
Hmm good point, I missed the chrome/content distinction in the original description. For chrome context, it seems like we should register the onerror handler for the browser window, rather than the contentWindow, as we do now.
Updated•11 years ago
|
Keywords: ateam-marionette-server
| Assignee | ||
Comment 5•11 years ago
|
||
(In reply to Jonathan Griffin (:jgriffin) from comment #4)
> Hmm good point, I missed the chrome/content distinction in the original
> description. For chrome context, it seems like we should register the
> onerror handler for the browser window, rather than the contentWindow, as we
> do now.
I'm happy to test a fix for this. It looks like you're referring to code in marionette-server.js [1], in this context is the "browser window" curBrowser?
[1] https://hg.mozilla.org/mozilla-central/annotate/7c87286ce969/testing/marionette/marionette-server.js#l1094
Flags: needinfo?(jgriffin)
| Assignee | ||
Comment 7•11 years ago
|
||
WIP - attempted to use curBrowser, but this doesn't seem to be what we want
(the errors from the content are still propagated).
Attachment #8558811 -
Flags: feedback?(jgriffin)
| Assignee | ||
Updated•11 years ago
|
Assignee: nobody → erahm
Status: NEW → ASSIGNED
Comment 8•11 years ago
|
||
Comment on attachment 8558811 [details] [diff] [review]
WIP: Content javascript exceptions cause Marionette JavascriptException during chrome context execute_script
Review of attachment 8558811 [details] [diff] [review]:
-----------------------------------------------------------------
lgtm! Does it pass a try run?
Attachment #8558811 -
Flags: feedback?(jgriffin) → feedback+
| Assignee | ||
Comment 9•11 years ago
|
||
(In reply to Jonathan Griffin (:jgriffin) from comment #8)
> Comment on attachment 8558811 [details] [diff] [review]
> WIP: Content javascript exceptions cause Marionette JavascriptException
> during chrome context execute_script
>
> Review of attachment 8558811 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> lgtm! Does it pass a try run?
I should have been clearer, this doesn't work. We still get exceptions from the content script. I was hoping you might have another suggestion.
Flags: needinfo?(jgriffin)
Comment 10•11 years ago
|
||
I played around with this a bit. You're right, the content errors get bubbled up to the browser's onerror handler. Also interesting is that JS errors that occur in chrome context are not caught by this handler.
I think we should probably just disable the onerror stuff for chrome, since the current implementation doesn't make sense. We can look at adding it back later if we can figure out how to trap chrome-space async errors.
Flags: needinfo?(jgriffin)
| Assignee | ||
Comment 11•11 years ago
|
||
Attachment #8560915 -
Flags: review?(jgriffin)
| Assignee | ||
Updated•11 years ago
|
Attachment #8558811 -
Attachment is obsolete: true
| Assignee | ||
Comment 12•11 years ago
|
||
Attachment #8560916 -
Flags: review?(jgriffin)
| Assignee | ||
Comment 13•11 years ago
|
||
Comment 14•11 years ago
|
||
Comment on attachment 8560915 [details] [diff] [review]
Part 1: Disable onerror hooking in chrome context
Review of attachment 8560915 [details] [diff] [review]:
-----------------------------------------------------------------
lgtm. David, are you ok with this approach?
Attachment #8560915 -
Flags: review?(jgriffin)
Attachment #8560915 -
Flags: review+
Attachment #8560915 -
Flags: feedback?(dburns)
Updated•11 years ago
|
Attachment #8560916 -
Flags: review?(jgriffin) → review+
Comment 15•11 years ago
|
||
Comment on attachment 8560915 [details] [diff] [review]
Part 1: Disable onerror hooking in chrome context
yea, that looks good
Attachment #8560915 -
Flags: feedback?(dburns) → feedback+
| Assignee | ||
Comment 16•11 years ago
|
||
Comment 17•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/a19cb997c026
https://hg.mozilla.org/mozilla-central/rev/075d31f8da0e
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
status-firefox38:
--- → fixed
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Updated•3 years ago
|
Product: Testing → Remote Protocol
You need to log in
before you can comment on or make changes to this bug.
Description
•