From 19e937dabb7b587cfadf4d90f27d15907dd28c73 Mon Sep 17 00:00:00 2001 From: Dorel Luca Date: Thu, 29 Oct 2020 18:37:39 +0200 Subject: [PATCH] Backed out changeset 5ea7a34f266c (bug 1660969) for Browser-chrome failures in browser_test_mixed_content_download.js. CLOSED TREE --- .../components/downloads/DownloadsCommon.jsm | 1 - .../components/downloads/DownloadsViewUI.jsm | 2 +- .../browser/downloads/downloads.properties | 5 ++-- .../browser_test_mixed_content_download.js | 24 +++---------------- toolkit/components/downloads/DownloadCore.jsm | 17 ------------- .../components/downloads/DownloadLegacy.jsm | 8 ------- 6 files changed, 6 insertions(+), 51 deletions(-) diff --git a/browser/components/downloads/DownloadsCommon.jsm b/browser/components/downloads/DownloadsCommon.jsm index 49b767bc8a62..9cbf57b5c998 100644 --- a/browser/components/downloads/DownloadsCommon.jsm +++ b/browser/components/downloads/DownloadsCommon.jsm @@ -1383,7 +1383,6 @@ DownloadsIndicatorDataCtor.prototype = { switch (download.error.reputationCheckVerdict) { case Downloads.Error.BLOCK_VERDICT_UNCOMMON: // fall-through case Downloads.Error.BLOCK_VERDICT_POTENTIALLY_UNWANTED: - case Downloads.Error.BLOCK_VERDICT_INSECURE: // Existing higher level attention indication trumps ATTENTION_WARNING. if (this._attention != DownloadsCommon.ATTENTION_SEVERE) { this.attention = DownloadsCommon.ATTENTION_WARNING; diff --git a/browser/components/downloads/DownloadsViewUI.jsm b/browser/components/downloads/DownloadsViewUI.jsm index 26ad0ddfd357..6631e6f03ada 100644 --- a/browser/components/downloads/DownloadsViewUI.jsm +++ b/browser/components/downloads/DownloadsViewUI.jsm @@ -628,7 +628,7 @@ DownloadsViewUI.DownloadElementShell.prototype = { case Downloads.Error.BLOCK_VERDICT_UNCOMMON: return [s.blockedUncommon2, [s.unblockTypeUncommon2, s.unblockTip2]]; case Downloads.Error.BLOCK_VERDICT_INSECURE: - return [s.blockedInsecure, [s.unblockInsecure, s.unblockTip2]]; + return [s.blockedInsecure, [s.blockedInsecure, s.unblockTip2]]; case Downloads.Error.BLOCK_VERDICT_POTENTIALLY_UNWANTED: return [ s.blockedPotentiallyUnwanted, diff --git a/browser/locales/en-US/chrome/browser/downloads/downloads.properties b/browser/locales/en-US/chrome/browser/downloads/downloads.properties index d58c20838762..25d8e80b0fde 100644 --- a/browser/locales/en-US/chrome/browser/downloads/downloads.properties +++ b/browser/locales/en-US/chrome/browser/downloads/downloads.properties @@ -32,7 +32,7 @@ stateBlockedParentalControls=Blocked by Parental Controls # be longer than the other existing status strings. blockedMalware=This file contains a virus or malware. blockedPotentiallyUnwanted=This file may harm your computer. -blockedInsecure=File not downloaded: Potential security risk. +blockedInsecure = This file could not be downloaded securely. blockedUncommon2=This file is not commonly downloaded. # LOCALIZATION NOTE (fileMovedOrMissing): @@ -42,7 +42,7 @@ fileMovedOrMissing=File moved or missing # LOCALIZATION NOTE (unblockHeaderUnblock, unblockHeaderOpen, # unblockTypeMalware, unblockTypePotentiallyUnwanted2, # unblockTypeUncommon2, unblockTip2, unblockButtonOpen, -# unblockButtonUnblock, unblockButtonConfirmBlock, unblockInsecure): +# unblockButtonUnblock, unblockButtonConfirmBlock): # These strings are displayed in the dialog shown when the user asks a blocked # download to be unblocked. The severity of the threat is expressed in # descending order by the unblockType strings, it is higher for files detected @@ -52,7 +52,6 @@ unblockHeaderOpen=Are you sure you want to open this file? unblockTypeMalware=This file contains a virus or other malware that will harm your computer. unblockTypePotentiallyUnwanted2=This file is disguised as a helpful download, but it can make unexpected changes to your programs and settings. unblockTypeUncommon2=This file is not commonly downloaded and may not be safe to open. It may contain a virus or make unexpected changes to your programs and settings. -unblockInsecure=The file uses an insecure connection. It may be corrupted or tampered with during the download process. unblockTip2=You can search for an alternate download source or try again later. unblockButtonOpen=Open unblockButtonUnblock=Allow download diff --git a/dom/security/test/mixedcontentblocker/browser_test_mixed_content_download.js b/dom/security/test/mixedcontentblocker/browser_test_mixed_content_download.js index b6b28db79170..2e2c84ff38f0 100644 --- a/dom/security/test/mixedcontentblocker/browser_test_mixed_content_download.js +++ b/dom/security/test/mixedcontentblocker/browser_test_mixed_content_download.js @@ -67,9 +67,8 @@ async function resetDownloads() { async function shouldNotifyDownloadUI() { // Waits until a Blocked download was added to the Download List - // -> returns the blocked Download let list = await Downloads.getList(Downloads.ALL); - return new Promise(res => { + await new Promise(res => { const view = { onDownloadAdded: aDownload => { let { error } = aDownload; @@ -77,7 +76,7 @@ async function shouldNotifyDownloadUI() { error.becauseBlockedByReputationCheck && error.reputationCheckVerdict == Downloads.Error.BLOCK_VERDICT_INSECURE ) { - res(aDownload); + res(true); list.removeView(view); } }, @@ -113,7 +112,7 @@ async function runTest(url, link, checkFunction, decscription) { await SpecialPowers.popPrefEnv(); } -// Test Blocking + add_task(async function() { await runTest( INSECURE_BASE_URL, @@ -140,20 +139,3 @@ add_task(async function() { "Secure -> Secure should Download" ); }); - -// Test Manual Unblocking -add_task(async function() { - await runTest( - SECURE_BASE_URL, - "insecure", - async () => { - let download = await shouldNotifyDownloadUI(); - await download.unblock(); - ok(download.error == null, "There should be no error after unblocking"); - - await download._succeed(); - ok(download.succeeded, "Download should succeed to download"); - }, - "A Blocked Download Should succeeded to Download after a Manual unblock" - ); -}); diff --git a/toolkit/components/downloads/DownloadCore.jsm b/toolkit/components/downloads/DownloadCore.jsm index 146909546294..6f11d765a554 100644 --- a/toolkit/components/downloads/DownloadCore.jsm +++ b/toolkit/components/downloads/DownloadCore.jsm @@ -643,23 +643,6 @@ Download.prototype = { ); } - if ( - this.error?.reputationCheckVerdict == DownloadError.BLOCK_VERDICT_INSECURE - ) { - // In this Error case, the download was actually canceled before it was - // passed to the Download UI. So we need to start the download here. - this.error = null; - this.succeeded = false; - this.hasBlockedData = false; - this.start().catch(e => { - this.error = e; - this._notifyChange(); - }); - this._notifyChange(); - this._promiseUnblock = DownloadIntegration.downloadDone(this); - return this._promiseUnblock; - } - if (!this.hasBlockedData) { return Promise.reject( new Error("unblock may only be called on Downloads with blocked data.") diff --git a/toolkit/components/downloads/DownloadLegacy.jsm b/toolkit/components/downloads/DownloadLegacy.jsm index ddf2ddee0aa1..4cd1a627c49c 100644 --- a/toolkit/components/downloads/DownloadLegacy.jsm +++ b/toolkit/components/downloads/DownloadLegacy.jsm @@ -389,14 +389,6 @@ DownloadLegacyTransfer.prototype = { becauseBlockedByReputationCheck: true, reputationCheckVerdict: DownloadError.BLOCK_VERDICT_INSECURE, }; - // hasBlockedData needs to be true - // because the unblock UI is hidden if there is - // no data to be unblocked. - serialisedDownload.hasBlockedData = true; - // We cannot use the legacy saver here, as the original channel - // is already closed. A copy saver would create a new channel once - // start() is called. - serialisedDownload.saver = "copy"; } Downloads.createDownload(serialisedDownload)