Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Discord CDN PDF links hang. Discord serves them with
Content-Type: application/pdfandContent-Disposition: attachment. Inline PDFs open in pdf.js, and non-PDF attachments download, so neither of those is affected.Root cause
browser.download.open_pdf_attachments_inline=true(geckoview-prefs.js). An attachment PDF is therefore rendered internally instead of being handed toonExternalResponse.DocumentLoadListenerGetWhereToOpenretargets an internally rendered attachment into a new tab (browser.link.open_newwindow=3).onLoadRequestwithuri="",target=TARGET_WINDOW_NEWand no user gesture.BrowserControllerdenies it, and the original load never finishes. I confirmed this sequence by logging on the emulator:uri=[] redirect=false direct=false target=2, thendecision=Deny.Fix
Set
browser.download.open_pdf_attachments_inline=falsein the existing Gecko startup prefs file. Attachment PDFs then go throughonExternalResponseand download like other attachments, which matches what theContent-Dispositionheader asks for. Inline PDFs still open in pdf.js.Testing
Tested on an emulator (API 35, debug build, GeckoView 157), although there were some extra patches applied:
PageStart, then the empty new-window request is denied, and the page stays pending indefinitely.PageStartthenPageStop. The download notification shows "Download complete", and/sdcard/Download/<redaced>.pdfis 5,596,553 bytes, which matches the server'scontent-length.GeckoHistoryCacheConfigInstrumentedTestto expect the new pref.The alternative fix is to accept the retarget and open the PDF in a new Candy tab with pdf.js, which is what Firefox does. That needs the popup and new-session path to accept an empty-URI, gesture-less window, which I suspect is a much larger change.