Closed Bug 1130816 Opened 10 years ago Closed 10 years ago

Bad argument passed to newChannelFromURI2 in WindowsPreviewPerTab.jsm

Categories

(Firefox :: General, defect)

x86_64
Windows 8.1
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 38
Tracking Status
firefox38 --- fixed

People

(Reporter: Unfocused, Assigned: ckerschb)

References

Details

Attachments

(1 file)

I'm getting this when running tests: JavaScript error: resource:///modules/WindowsPreviewPerTab.jsm, line 77: NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 1 [nsIIOService2.newChannelFromURI2] 3 INFO Console message: [JavaScript Error: "NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 1 [nsIIOService2.newChannelFromURI2]" {file: "resource:///modules/WindowsPreviewPerTab.jsm" line: 77}] JavaScript error: resource:///modules/WindowsPreviewPerTab.jsm, line 77: NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 1 [nsIIOService2.newChannelFromURI2] 4 INFO Console message: [JavaScript Error: "NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 1 [nsIIOService2.newChannelFromURI2]" {file: "resource:///modules/WindowsPreviewPerTab.jsm" line: 77}] I assume this is the result of bug 1087726.
Depends on: 1087726
Christoph, could you take a look at this?
Flags: needinfo?(mozilla)
I think the problem is here: https://hg.mozilla.org/mozilla-central/rev/93c1130d0d47#l3.40 The inner call to _imageFromURI has the wrong number of arguments. Actually this was already broken before Bug 1087726, now it's just more broken.
Blocks: 1087726
No longer depends on: 1087726
(In reply to Philip Chee from comment #2) > I think the problem is here: > https://hg.mozilla.org/mozilla-central/rev/93c1130d0d47#l3.40 > The inner call to _imageFromURI has the wrong number of arguments. Actually > this was already broken before Bug 1087726, now it's just more broken. Eh? It had 3 arguments, now has 4, and that seems to be what's being passed... Seems to me (without having run this) that it's more likely that in tests the contentWindow.document ref is null and so we're passing null as the owning document, which newChannelFromURI2 doesn't like... in any case, it should be easy to test either of these hypotheses with the JS debugger ( --jsdebugger) and a conditional breakpoint in the relevant code.
Either of your hypotheses regarding the incorrect first argument could be correct: * either the doc is null, or * we can not convert a nsIURI into an nsINode. The second one seems more likely to me - the attached patch should fix the problem. Also, even before we changed the arguments of _imageFromURI, the one callsite was missing the 'prviateMode' argument - included that in the patch as well. If that attached patch fixed the problem please flag gijs for review. Otherwise please let me know what testcase you are running so I can reproduce on my end. Thanks for filing the bug!
Flags: needinfo?(bmcbride)
Oh, also clearing my needinfo flag!
Flags: needinfo?(mozilla)
Comment on attachment 8561200 [details] [diff] [review] bug_1130816.patch Review of attachment 8561200 [details] [diff] [review]: ----------------------------------------------------------------- Yea, this seems to fix it - and the fix looks correct to me. ::: browser/modules/WindowsPreviewPerTab.jsm @@ +97,5 @@ > // We failed, so use the default favicon (only if this wasn't the default > // favicon). > let defaultURI = faviconSvc.defaultFavicon; > if (!defaultURI.equals(uri)) > + _imageFromURI(doc, defaultURI, privateMode, callback); This looks like another bug: callback isn't guaranteed to be called.
Attachment #8561200 - Flags: review+
Great, still would like Gijs have a quick look since he reviewed the main patch.
Attachment #8561200 - Flags: review?(gijskruitbosch+bugs)
Flags: needinfo?(bmcbride)
Comment on attachment 8561200 [details] [diff] [review] bug_1130816.patch Review of attachment 8561200 [details] [diff] [review]: ----------------------------------------------------------------- Ugh. Can't believe I missed this. :-(
Attachment #8561200 - Flags: review?(gijskruitbosch+bugs) → review+
(In reply to Blair McBride [:Unfocused] (I don't read bugmail - needinfo? me!) from comment #6) > ::: browser/modules/WindowsPreviewPerTab.jsm > @@ +97,5 @@ > > // We failed, so use the default favicon (only if this wasn't the default > > // favicon). > > let defaultURI = faviconSvc.defaultFavicon; > > if (!defaultURI.equals(uri)) > > + _imageFromURI(doc, defaultURI, privateMode, callback); > > This looks like another bug: callback isn't guaranteed to be called. Only in two cases, though, right, unless I'm missing something else (it's been known to happen!) - 1) the resultcode of the fetch != NS_OK, in which case we just bail and don't call the callback. Considering the callbacks here only update the icon if it's non-empty, leaving it empty seems... OK? 2) if fetching the icon for the default favicon URI failed. Obviously, that shouldn't happen... but if it did, I guess leaving the icon un-set would also probably be the sensible approach, rather than just trying again?
Flags: needinfo?(bmcbride)
(In reply to :Gijs Kruitbosch from comment #9) > (In reply to Blair McBride [:Unfocused] (I don't read bugmail - needinfo? > me!) from comment #6) > > ::: browser/modules/WindowsPreviewPerTab.jsm > > @@ +97,5 @@ > > > // We failed, so use the default favicon (only if this wasn't the default > > > // favicon). > > > let defaultURI = faviconSvc.defaultFavicon; > > > if (!defaultURI.equals(uri)) > > > + _imageFromURI(doc, defaultURI, privateMode, callback); > > > > This looks like another bug: callback isn't guaranteed to be called. > > Only in two cases, though, right, unless I'm missing something else (it's > been known to happen!) - > > 1) the resultcode of the fetch != NS_OK, in which case we just bail and > don't call the callback. Considering the callbacks here only update the icon > if it's non-empty, leaving it empty seems... OK? > 2) if fetching the icon for the default favicon URI failed. Obviously, that > shouldn't happen... but if it did, I guess leaving the icon un-set would > also probably be the sensible approach, rather than just trying again? Thanks Gijs for the explanation and the speedy review, but that's going to be a different bug. I am landing the attached patch as it fixes the problem described in this bug: https://hg.mozilla.org/integration/mozilla-inbound/rev/b7e806aa4fe8
Assignee: nobody → mozilla
Status: NEW → ASSIGNED
(In reply to :Gijs Kruitbosch from comment #9) > 1) the resultcode of the fetch != NS_OK, in which case we just bail and > don't call the callback. Considering the callbacks here only update the icon > if it's non-empty, leaving it empty seems... OK? > 2) if fetching the icon for the default favicon URI failed. Obviously, that > shouldn't happen... but if it did, I guess leaving the icon un-set would > also probably be the sensible approach, rather than just trying again? Yea, I don't think those are particularly bad. I guess there's the question of whether a stale image or no image is a better fail-mode. But what worries me is that the code isn't being intentional about it. That's going to bite us on our collective asses in the future.
Flags: needinfo?(bmcbride)
(In reply to Blair McBride [:Unfocused] (I don't read bugmail - needinfo? me!) from comment #11) > (In reply to :Gijs Kruitbosch from comment #9) > > 1) the resultcode of the fetch != NS_OK, in which case we just bail and > > don't call the callback. Considering the callbacks here only update the icon > > if it's non-empty, leaving it empty seems... OK? > > 2) if fetching the icon for the default favicon URI failed. Obviously, that > > shouldn't happen... but if it did, I guess leaving the icon un-set would > > also probably be the sensible approach, rather than just trying again? > > Yea, I don't think those are particularly bad. I guess there's the question > of whether a stale image or no image is a better fail-mode. > > But what worries me is that the code isn't being intentional about it. > That's going to bite us on our collective asses in the future. Fair. Want to file a followup to ensure we always call it (probably with |null|) and deal with that in the relevant callbacks? :-)
Flags: needinfo?(bmcbride)
And here I was trying my best to be lazy. Filed bug 1131428.
Flags: needinfo?(bmcbride)
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 38
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: