Revert "Use a link, rather than window.open, when opening PDF attachments in Firefox (bug 1661259)"

This reverts commit 1e5d4b6a80, since it unfortunately doesn't work in all situations.

Please note that I did *successfully* test the patch in a local Firefox build, obviously with an ad blocker installed.
However, I've now tested the *latest* Nightly-build with my default profile, and unfortunately I can still reproduce the bug there!?
This commit is contained in:
Jonas Jenwald 2020-08-27 15:50:55 +02:00
parent a6f66891cc
commit de932573dd

View File

@ -118,22 +118,7 @@ class PDFAttachmentViewer extends BaseTreeViewer {
encodeURIComponent(blobUrl + "#" + filename); encodeURIComponent(blobUrl + "#" + filename);
} }
try { try {
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) { window.open(viewerUrl);
window.open(viewerUrl);
} else {
// Since we have a full URL in the MOZCENTRAL-build, use a link rather
// than `window.open` since e.g. ad blockers may otherwise force-close
// the newly opened window and thus break viewing of PDF attachments
// (fixes bug 1661259).
const a = document.createElement("a");
a.hidden = true;
a.href = viewerUrl;
a.target = "_blank";
// <a> must be in the document, otherwise `a.click()` is ignored.
(document.body || document.documentElement).appendChild(a);
a.click();
a.remove();
}
} catch (ex) { } catch (ex) {
console.error(`_bindPdfLink: ${ex}`); console.error(`_bindPdfLink: ${ex}`);
// Release the `blobUrl`, since opening it failed... // Release the `blobUrl`, since opening it failed...