threema-ch / threema-web

The Threema Web application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Firefox: PDFs are opened in same tab

threema-danilo opened this issue · comments

Bug Description

In current versions of Firefox, when clicking on a PDF file, it is not downloaded, but instead opened in the same tab. This affects both current and old version of Threema Web, I suspect this was caused by a behavioral change in newer Firefox versions.

  • Threema Web version: 2.3.19
  • Browser name and version: Firefox 98.0.1
commented

Happens on a lot of pages, so I'm not even sure we should do anything about it. Agree it's annoying though. Maybe there's a bugzilla bug?

A potential workaround is downloading PDF files using the media type application/octet-stream, one of our support staff said that this seems to help. It's a ugly hack for a problem in Firefox, but if it works it might be a valid workaround. Opening PDFs is probably quite a common use case for Threema Web, so this should not break (it logs you out of the current session).

I'll take a closer look this afternoon. We're using a method that should always result in a download, so I suspect that Firefox is doing something wrong here. If I can confirm that, I'll comment on the Bugzilla ticket.

commented

Found another longer discussion we might want to chime in: https://bugzilla.mozilla.org/show_bug.cgi?id=1756980#c5 (sigh, blaming bad UX while not even knowing the use case, like SPA with state in memory... come on)

We're using file-saver which uses target=_blank, so this would be the most fitting bug I guess: https://bugzilla.mozilla.org/show_bug.cgi?id=1759916

Ugh, so they intentionally ignore the download attribute and Content-Disposition: attachment? https://bugzilla.mozilla.org/show_bug.cgi?id=1756980#c7

We're using file-saver which uses target=_blank, so this would be the most fitting bug I guess: https://bugzilla.mozilla.org/show_bug.cgi?id=1759916

file-saver uses a lot of different approaches depending on the browser: https://github.com/eligrey/FileSaver.js/blob/master/src/FileSaver.js In our case (Firefox) an approach with a.href = URL.createObjectURL(blob) followed by click(a) is used.

Fun fact from bugzilla 1756980:

This also happens on WhatsApp web now. PDF files are opened in the same tab, although pressing the back button does re-logins the users. But I think this shows that this behavior is not expected.

For now, I'll add the ugly application/octet-stream workaround hack for Firefox, which does seem to work.

For the record, the change was finally reverted in Firefox 103: https://bugzilla.mozilla.org/show_bug.cgi?id=1756980#c71