[tor-commits] [tor-browser] 52/73: Bug 1778714 - Fix the pdf download link in the All Downloads view. r=Gijs, a=RyanVM

gitolite role git at cupani.torproject.org
Wed Sep 21 20:17:45 UTC 2022


This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch geckoview-102.3.0esr-12.0-1
in repository tor-browser.

commit 5407f0f027aefb483cbc52096d9e8c10775e9f53
Author: Calixte <cdenizet at mozilla.com>
AuthorDate: Mon Aug 8 18:56:24 2022 +0000

    Bug 1778714 - Fix the pdf download link in the All Downloads view. r=Gijs, a=RyanVM
    
    Differential Revision: https://phabricator.services.mozilla.com/D151431
---
 .../components/downloads/content/allDownloadsView.js    | 17 +++++++++++------
 .../pdfjs/test/browser_pdfjs_download_button.js         | 14 ++++++++++++++
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/browser/components/downloads/content/allDownloadsView.js b/browser/components/downloads/content/allDownloadsView.js
index 502faf4bb33ab..55b9f47e4637a 100644
--- a/browser/components/downloads/content/allDownloadsView.js
+++ b/browser/components/downloads/content/allDownloadsView.js
@@ -125,7 +125,9 @@ HistoryDownloadElementShell.prototype = {
     let displayName = DownloadsViewUI.getDisplayName(this.download);
     return (
       displayName.toLowerCase().includes(aTerm) ||
-      this.download.source.url.toLowerCase().includes(aTerm)
+      (this.download.source.originalUrl || this.download.source.url)
+        .toLowerCase()
+        .includes(aTerm)
     );
   },
 
@@ -596,7 +598,10 @@ DownloadsPlacesView.prototype = {
       case "cmd_copy":
         return Array.prototype.some.call(
           this._richlistbox.selectedItems,
-          element => !!element._shell.download.source?.url
+          element => {
+            const { source } = element._shell.download;
+            return !!(source?.originalUrl || source?.url);
+          }
         );
       case "downloadsCmd_openReferrer":
       case "downloadShowMenuItem":
@@ -616,10 +621,10 @@ DownloadsPlacesView.prototype = {
   },
 
   _copySelectedDownloadsToClipboard() {
-    let urls = Array.from(
-      this._richlistbox.selectedItems,
-      element => element._shell.download.source?.url
-    ).filter(Boolean);
+    let urls = Array.from(this._richlistbox.selectedItems, element => {
+      const { source } = element._shell.download;
+      return source?.originalUrl || source?.url;
+    }).filter(Boolean);
 
     Cc["@mozilla.org/widget/clipboardhelper;1"]
       .getService(Ci.nsIClipboardHelper)
diff --git a/toolkit/components/pdfjs/test/browser_pdfjs_download_button.js b/toolkit/components/pdfjs/test/browser_pdfjs_download_button.js
index fa6b6d6c978a9..7b7162c5d1642 100644
--- a/toolkit/components/pdfjs/test/browser_pdfjs_download_button.js
+++ b/toolkit/components/pdfjs/test/browser_pdfjs_download_button.js
@@ -109,6 +109,20 @@ add_task(async function test_downloading_pdf_nonprivate_window() {
         tabCount,
         "No new tab was opened to view the downloaded PDF"
       );
+
+      SpecialPowers.clipboardCopyString("");
+      const downloadsLoaded = BrowserTestUtils.waitForEvent(
+        browser,
+        "InitialDownloadsLoaded",
+        true
+      );
+      BrowserTestUtils.loadURI(browser, "about:downloads");
+      await downloadsLoaded;
+
+      info("Wait for the clipboard to contain the url of the pdf");
+      await SimpleTest.promiseClipboardChange(pdfUrl, () => {
+        goDoCommand("cmd_copy");
+      });
     }
   );
 });

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list