Opening local pdfs from file:///... fails if PDFs are set to "always ask"
Categories
(Firefox :: PDF Viewer, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox91 | --- | verified |
People
(Reporter: smaug, Assigned: Gijs)
References
Details
Attachments
(2 files, 1 obsolete file)
Download (for example)
http://researcher.watson.ibm.com/researcher/files/us-bacon/Bacon01Concurrent.pdf
Go to the url pointing to the directory where the file was saved
Something like file:///home/<user>/Downloads
Click the pdf.
Dialog opens to let user to choose what to do with the pdf. Select "Open with Nightly".
That doesn't succeed, and an error dialog is shown.
Comment 1•3 years ago
|
||
I can reproduce easily in nightly in selecting "Always ask" for pdf in "Applications" section.
:gijs, maybe you'd have an idea here on what's wrong.
Assignee | ||
Comment 2•3 years ago
|
||
(In reply to Calixte Denizet (:calixte) from comment #1)
I can reproduce easily in nightly in selecting "Always ask" for pdf in "Applications" section.
Thanks for specifying this. The problem does not occur when picking "open in Firefox", which is the default for PDFs.
:gijs, maybe you'd have an idea here on what's wrong.
Not off-hand. I will try to investigate later this week.
Assignee | ||
Comment 3•3 years ago
|
||
So we avoid this if you open the PDF externally or with system principal, because we hit this code:
and allow handling directly with PDF.js
In this case, the triggering principal is a file
principal (because that's where the link is!) and so we don't allow immediate opening with PDF.js . Which means we end up showing the "what do you want to do" dialog.
When the user picks Firefox in the dialog, we hit launchWithFile
in the mime info implementation. This implementation is OS-dependent but either way it checks the "preferred action" (which is "handle internally") which it doesn't know how to do, so it returns NS_ERROR_INVALID_ARG, which causes the failure and dialog:
Windows: https://searchfox.org/mozilla-central/rev/bf8d5de8528036c09590009720bc172882845b80/uriloader/exthandler/win/nsMIMEInfoWin.cpp#88
macOS: https://searchfox.org/mozilla-central/rev/bf8d5de8528036c09590009720bc172882845b80/uriloader/exthandler/mac/nsMIMEInfoMac.mm#29
other: https://searchfox.org/mozilla-central/rev/bf8d5de8528036c09590009720bc172882845b80/uriloader/exthandler/nsMIMEInfoImpl.cpp#280
I'm not sure whether/how we should update them for this case, and if there are any other ways of triggering them besides this quirk of pdf.js-ness. Perhaps with the other file types where we now support handling them internally? But then, why would we ever show the dialog for them when clicking a file:
link for them? Adam, you worked on the other filetypes - do you have any thoughts?
Assignee | ||
Comment 4•3 years ago
|
||
Assignee | ||
Comment 5•3 years ago
|
||
https://phabricator.services.mozilla.com/D116915 fixes this by immediately opening in PDF.js instead of opening the dialog first, but I don't know if the removal of the choice to use an external app in this case is going to upset anyone who somehow relies on using this to open external apps...
Comment 6•3 years ago
|
||
(In reply to :Gijs (out; back Jun 21; he/him) from comment #3)
I'm not sure whether/how we should update them for this case, and if there are any other ways of triggering them besides this quirk of pdf.js-ness. Perhaps with the other file types where we now support handling them internally? But then, why would we ever show the dialog for them when clicking a
file:
link for them? Adam, you worked on the other filetypes - do you have any thoughts?
I don't think the same thing can happen with the other types, though I don't understand fully the PDF issue here. When opening the other types from file:
they always display regardless of whether we're set to always ask or to use a system handler. I tried the download attribute on a link, doesn't seem to work for file:
, I think because same-origin checks are weird with file:
.
Updated•3 years ago
|
Updated•3 years ago
|
Comment 8•3 years ago
|
||
bugherder |
Updated•3 years ago
|
Comment 9•3 years ago
|
||
I've reproduced this issue on mac 11, using an affected Nightly version (2020-12-01), and by following the steps from comment 0.
Hi Gijs! Just to make sure that I understand correctly this fix, the local pdf files will be opened immediately in Firefox, without prompting the dialog to the users, even though the "Always ask" option is checked for pdf. Is that correct? I've verified this on Win 10 x64, macOS 10.11 and Ubuntu 18.04 x64 with Beta 91.0b9.
Assignee | ||
Comment 10•3 years ago
|
||
(In reply to Ciprian Georgiu [:ciprian_georgiu], Release Desktop QA from comment #9)
I've reproduced this issue on mac 11, using an affected Nightly version (2020-12-01), and by following the steps from comment 0.
Hi Gijs! Just to make sure that I understand correctly this fix, the local pdf files will be opened immediately in Firefox, without prompting the dialog to the users, even though the "Always ask" option is checked for pdf. Is that correct? I've verified this on Win 10 x64, macOS 10.11 and Ubuntu 18.04 x64 with Beta 91.0b9.
yep, that's correct!
Comment 11•3 years ago
|
||
Thank you! We can then close this bug as verified fixed, since I encountered that behavior on latest Beta 91, as mentioned in comment 9.
Comment 13•3 years ago
|
||
Comment 14•3 years ago
|
||
Comment on attachment 9251710 [details]
Bug 1680147 - Rename LaunchWithApplication to SetDownloadToLaunch. r=gijs!
Revision D131714 was moved to bug 1740142. Setting attachment 9251710 [details] to obsolete.
Description
•