Support key modifiers to open downloaded PDFs in a new window, background tab
Categories
(Firefox :: Downloads Panel, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox78 | --- | fixed |
People
(Reporter: sfoster, Assigned: sfoster)
References
(Depends on 2 open bugs)
Details
(Whiteboard: [fxgrowth] )
Attachments
(2 files)
It should be possible to hold click/shift/meta keys when opening a downloaded PDF and if that results in opening the file in the browser, we should follow the normal conventions and open it as appropriate:
- (default):
open in a new tab ("current")open in current tab - ctrl/metaKey: open in new tab ("tab")
- shiftKey: open in new browser window ("window")
- ctrl/metaKey + shiftKey: open in background tab ("tabshifted")
Assignee | ||
Comment 1•5 years ago
|
||
Do you have suggestions for how to get at the event to check .shiftKey/.ctrlKey/.metaKey
when handling the OPEN_DOWNLOAD_FILE
action in DownloadManager.jsm for the download cards about:newtab? In the other downloads views for this bug I'm calling BrowserWindowTracker.getTopWindow().whereToOpenLink(event, false, true)
to allow use of key modifiers to direct where to open the download if we load it into the browser as a file: URI (e.g. new window, background tab).
Assignee | ||
Comment 2•5 years ago
|
||
Comment 3•5 years ago
|
||
Probably similar pattern for OPEN_LINK passing a fake event along with the action to determine where to open the link:
https://searchfox.org/mozilla-central/rev/9193635dca8cfdcb68f114306194ffc860456044/browser/components/newtab/content-src/components/Card/Card.jsx#149,152-154
https://searchfox.org/mozilla-central/rev/9193635dca8cfdcb68f114306194ffc860456044/browser/components/newtab/lib/PlacesFeed.jsm#283,307
Assignee | ||
Comment 4•5 years ago
|
||
(In reply to Ed Lee :Mardak from comment #3)
Probably similar pattern for OPEN_LINK passing a fake event along with the action to determine where to open the link:
https://searchfox.org/mozilla-central/rev/9193635dca8cfdcb68f114306194ffc860456044/browser/components/newtab/content-src/components/Card/Card.jsx#149,152-154
https://searchfox.org/mozilla-central/rev/9193635dca8cfdcb68f114306194ffc860456044/browser/components/newtab/lib/PlacesFeed.jsm#283,307
That makes sense, but its not so clear how to accomplish the same for the options menu where the OpenFile
option currently lives. I'm getting lost trying to figure out where the event exists and how to pass modifier key data down to the option's action at https://searchfox.org/mozilla-central/source/browser/components/newtab/content-src/lib/link-menu-options.js#153 (ReactJs noob here)
Before I spend more time on this, the other question that may be relevant here is why SHOW_DOWNLOAD_FILE
(which opens the download directory in the OS' filesystem viewer) the default action for the download cards, when elsewhere in the UI we tend to open/launch the file itself - ie OPEN_DOWNLOAD_FILE
. Was there a decision made the showing the containing directory is a better fit somehow for this context? If not, maybe I can change the default to OPEN_DOWNLOAD_FILE at which point the tips in comment #3 should be most of what I need.
Comment 5•5 years ago
|
||
(In reply to Sam Foster [:sfoster] (he/him) from comment #4)
Was there a decision made the showing the containing directory is a better fit somehow for this context?
It looks like the original UX desire was to open the file:
https://github.com/mozilla/activity-stream/issues/3535#issuecomment-344707481
I believe there was a security concern of having a (special) content page sending a message to the main process to "open <arbitrary file>" although I suppose that surface could be reduced to "open <downloaded file index 1>" or some other downloads-specific identifier to then figure out which file it should open.
Comment 6•5 years ago
|
||
(In reply to Sam Foster [:sfoster] (he/him) from comment #4)
I'm getting lost trying to figure out where the event exists and how to pass modifier key data down to the option's action
Ah there's a bunch of indirection going on here… The context menu is controlled by an array of strings where those strings key into the link-menu-options that then dynamically create onClick handlers on the rendered items:
https://searchfox.org/mozilla-central/rev/61fceb7c0729773f544a9656f474e36cd636e5ea/browser/components/newtab/content-src/components/LinkMenu/LinkMenu.jsx#41,53-54
It looks like no menu items have ever needed to use the event object or anything dynamic. I suppose maybe you can define the action
of a link menu option to be a function that LinkMenu.jsx decides to call the function to get an action object or just plain pass on the statically declared action object.
Assignee | ||
Comment 7•5 years ago
|
||
(In reply to Ed Lee :Mardak from comment #5)
I believe there was a security concern of having a (special) content page sending a message to the main process to "open <arbitrary file>" although I suppose that surface could be reduced to "open <downloaded file index 1>" or some other downloads-specific identifier to then figure out which file it should open.
As we ended up implementing this (we send a OPEN_DOWNLOAD_FILE message to the parent process and DownloadManager.jsm calls into DownloadsCommon/DownloadIntegration etc to do the file opening) , but under the options menu, I assume this security concern is resolved, or at least orthogonal to this bug.
Assignee | ||
Comment 8•5 years ago
|
||
Depends on D75870
Comment 10•5 years ago
|
||
Backed out for perma failures on browser_pdfjs_preview.js and browser_download_open_with_internal_handler.js
Failure logs:
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=304050461&repo=autoland&lineNumber=2047
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=304050458&repo=autoland&lineNumber=5164
Backout: https://hg.mozilla.org/integration/autoland/rev/6927efcab2958a77515d245a0dd88677b20775b2
Updated•5 years ago
|
Assignee | ||
Comment 11•5 years ago
•
|
||
To fix the browser_download_open_with_internal_handler.js failure, I set the default "openWhere" option to DownloadUIHelper.loadFileIn to "tab". All the views will pass "current" by default but it looks like for the URI-loader use-case, "tab" does the right thing.
I found at least part of the issue with the private download / about:downloads test: Bug 1329912. With a workaround in place for that, I can't reproduce this locally on linux anymore. But it looks like https://treeherder.mozilla.org/#/jobs?repo=try&revision=2ea1517cc36a34c3a52f36d72ea4be650ef65a62 still has some failures.
Comment 12•5 years ago
|
||
Comment 13•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/c5e87e5b6f9f
https://hg.mozilla.org/mozilla-central/rev/8d8372333cb9
Comment 14•5 years ago
|
||
The support key modifiers to open downloaded PDFs works as described in comment 0 on Fx 79.0a1 (2020-06-24) and Fx 78.0 across platforms (Windows 10, Ubuntu 18.04 and macOS 10.15), with the mention that the default behavior was verified in bug 1642431.
One question here, when attempting to open several times the downloaded file using a different key combination, for example I click the downloaded file 1 time and a new tab opens to the right, then using Ctrl + Shift +click the new tab is displayed to the left of the previously opened tab. Shouldn't it be opened to the right as well? Is this behavior expected?
Assignee | ||
Comment 15•5 years ago
|
||
(In reply to Anca Soncutean [:Anca], Desktop Release QA from comment #14)
One question here, when attempting to open several times the downloaded file using a different key combination, for example I click the downloaded file 1 time and a new tab opens to the right, then using Ctrl + Shift +click the new tab is displayed to the left of the previously opened tab. Shouldn't it be opened to the right as well? Is this behavior expected?
I'm not able to reproduce this as described. Yes, the default behavior (equivalent to ctrl+click) should open the PDF at the end (right in LTR) of the tab strip and switch to it. And Ctrl+shift+click should open another tab right of that one. This is true for clicks on items representing downloads in the browser UI - not necessarily for clicking links in content. If you can confirm STR to get the behavior you describe in comment 14 can you open a new bug for that?
Updated•5 years ago
|
Description
•