Closed
Bug 1247192
Opened 10 years ago
Closed 10 years ago
Using Services in TabSources breaks worker debugging
Categories
(DevTools :: Debugger, defect)
DevTools
Debugger
Tracking
(firefox47 fixed)
RESOLVED
FIXED
Firefox 47
| Tracking | Status | |
|---|---|---|
| firefox47 | --- | fixed |
People
(Reporter: ejpbruel, Assigned: ejpbruel)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
|
7.39 KB,
patch
|
fitzgen
:
review+
jryans
:
review+
|
Details | Diff | Splinter Review |
Apparently, we introduced multiple uses of the Services object in TabSources at some point. Since TabSources is used by the worker debugging, the latter currently doesn't work at all.
Most uses of the Services object in TabSources seem to be for URL handling. There is no hard reason for us to use C++ API's for this, so we should be able to come up with a replacement API in JS.
One thing that's strange is that this wasn't caught by the test. We currently don't have that many tests for worker debugging, but we have at least one that actually uses source actors (and therefore TabSources).
| Assignee | ||
Comment 1•10 years ago
|
||
This patch replaces all uses of Services.io.newURI in TabSources with new URI. As I explained above, TabSources is used in worker debugging, where Services is not available. Currently, the URI object is not available to the worker debugger either, but unlike Services (which uses Components.utils under the hood), the URI object is exposed to ordinary workers. So in theory, we can simply expose the URI object to the worker debugger after this patch lands.
The URL object doesn't match the API of Services.io exactly, so I tried to make it match as closely as possible. The debugger tests all pass locally, so it looks like everything works as it should. That said, URL parsing is always tricky business, so there may be some corner cases I missed. Let me know if you find any.
Flagging jryans for the loader changes by his request.
Attachment #8717921 -
Flags: review?(nfitzgerald)
Attachment #8717921 -
Flags: review?(jryans)
Comment on attachment 8717921 [details] [diff] [review]
Replace Services.io.newURI with new URL
Review of attachment 8717921 [details] [diff] [review]:
-----------------------------------------------------------------
Loader parts look good to me.
Attachment #8717921 -
Flags: review?(jryans) → review+
Comment 3•10 years ago
|
||
Comment on attachment 8717921 [details] [diff] [review]
Replace Services.io.newURI with new URL
Review of attachment 8717921 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks! Couple comments below, one is kinda style nit picky (new vs . associativity) so if you disagree with me then ignore my comment, other one I feel more strongly about (large blanket catch) and am willing to argue with you if you disagree.
::: devtools/server/actors/utils/TabSources.js
@@ +305,5 @@
> + if (url.indexOf("javascript:") === 0 || url === 'debugger eval code') {
> + spec.contentType = "text/javascript";
> + } else {
> + try {
> + let pathname = new URL(url).pathname;
Maybe it's just me, but I always forget the associativity of new vs . and so this line makes me stop reading the intent of the code and forces me to go off into the sticks about if this is parsed as `(new URL(url)).pathname` vs `new (URL(url).pathname)`.
Personally, I think this would be easier if we split this line in two so that this issue went away.
@@ +318,5 @@
> + }
> + else if (extension === "js") {
> + spec.contentType = "text/javascript";
> + }
> + } catch (e) {}
Blanket catches are v scary, especially surrounding large blocks of code. Any way to (a) narrow this down around the particular thing that may throw, (b) DTU.reportException here, (c) add some comments about what could go wrong and why it is ok to silently ignore it, hopefully combined with (a).
As a reader of this code, the impression I get is that we have no idea what could or couldn't go wrong right now.
@@ +479,5 @@
> : base;
> },
>
> _dirname: function (aPath) {
> + let href = new URL(aPath).href;
ditto about new vs .
Attachment #8717921 -
Flags: review?(nfitzgerald) → review+
| Assignee | ||
Comment 4•10 years ago
|
||
(In reply to Nick Fitzgerald [:fitzgen] [⏰PST; UTC-8] from comment #3)
> Comment on attachment 8717921 [details] [diff] [review]
> Replace Services.io.newURI with new URL
>
> Review of attachment 8717921 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Thanks! Couple comments below, one is kinda style nit picky (new vs .
> associativity) so if you disagree with me then ignore my comment, other one
> I feel more strongly about (large blanket catch) and am willing to argue
> with you if you disagree.
>
> ::: devtools/server/actors/utils/TabSources.js
> @@ +305,5 @@
> > + if (url.indexOf("javascript:") === 0 || url === 'debugger eval code') {
> > + spec.contentType = "text/javascript";
> > + } else {
> > + try {
> > + let pathname = new URL(url).pathname;
>
> Maybe it's just me, but I always forget the associativity of new vs . and so
> this line makes me stop reading the intent of the code and forces me to go
> off into the sticks about if this is parsed as `(new URL(url)).pathname` vs
> `new (URL(url).pathname)`.
>
> Personally, I think this would be easier if we split this line in two so
> that this issue went away.
>
> @@ +318,5 @@
> > + }
> > + else if (extension === "js") {
> > + spec.contentType = "text/javascript";
> > + }
> > + } catch (e) {}
>
> Blanket catches are v scary, especially surrounding large blocks of code.
> Any way to (a) narrow this down around the particular thing that may throw,
> (b) DTU.reportException here, (c) add some comments about what could go
> wrong and why it is ok to silently ignore it, hopefully combined with (a).
>
> As a reader of this code, the impression I get is that we have no idea what
> could or couldn't go wrong right now.
>
> @@ +479,5 @@
> > : base;
> > },
> >
> > _dirname: function (aPath) {
> > + let href = new URL(aPath).href;
>
> ditto about new vs .
That blanket catch shouldn't have been there in the first place imo, but its still required because the URL constructor is not exposed to workers yet, and we've come to rely on it failing silently :-(
The good news is that we can remove the catch once we expose the URL constructor to the worker debugger, which is the next thing I'm planning to do. I will add a comment to that effect.
Agreed on your other comment as well, will update the patch accordingly before landing.
| Assignee | ||
Comment 5•10 years ago
|
||
Try push for this patch, with comments by fitzgen addressed:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=c581bbadcab9
Comment 7•10 years ago
|
||
| bugherder | ||
Status: NEW → RESOLVED
Closed: 10 years ago
status-firefox47:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 47
Updated•8 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•