diff --git a/browser/components/downloads/test/browser/browser_download_overwrite.js b/browser/components/downloads/test/browser/browser_download_overwrite.js index 1e79c34cd355..71eb715315ff 100644 --- a/browser/components/downloads/test/browser/browser_download_overwrite.js +++ b/browser/components/downloads/test/browser/browser_download_overwrite.js @@ -23,10 +23,7 @@ add_task(async function setup() { ok(gTestTargetFile.exists(), "We created a test file."); await SpecialPowers.pushPrefEnv({ - set: [ - ["browser.download.improvements_to_download_panel", true], - ["browser.download.useDownloadDir", false], - ], + set: [["browser.download.useDownloadDir", false]], }); // Set up the file picker. let destDir = gTestTargetFile.parent; @@ -34,7 +31,6 @@ add_task(async function setup() { MockFilePicker.displayDirectory = destDir; MockFilePicker.showCallback = function(fp) { MockFilePicker.setFiles([gTestTargetFile]); - return MockFilePicker.returnOK; }; registerCleanupFunction(function() { MockFilePicker.cleanup(); @@ -61,26 +57,18 @@ add_task(async function test_overwrite_does_not_delete_first() { }); let dialogPromise = BrowserTestUtils.domWindowOpenedAndLoaded(); - // Now try and download a thing to the file: await BrowserTestUtils.withNewTab(TEST_ROOT + "foo.txt", async function() { - if ( - !Services.prefs.getBoolPref( - "browser.download.improvements_to_download_panel" - ) - ) { - let dialog = await dialogPromise; - info("Got dialog."); - let saveEl = dialog.document.getElementById("save"); - dialog.document.getElementById("mode").selectedItem = saveEl; - // Allow accepting the dialog (to avoid the delay helper): - dialog.document - .getElementById("unknownContentType") - .getButton("accept").disabled = false; - // Then accept it: - dialog.document.querySelector("dialog").acceptDialog(); - } - + let dialog = await dialogPromise; + info("Got dialog."); + let saveEl = dialog.document.getElementById("save"); + dialog.document.getElementById("mode").selectedItem = saveEl; + // Allow accepting the dialog (to avoid the delay helper): + dialog.document + .getElementById("unknownContentType") + .getButton("accept").disabled = false; + // Then accept it: + dialog.document.querySelector("dialog").acceptDialog(); ok(await transferCompletePromise, "download should succeed"); ok( gTestTargetFile.exists(), @@ -99,39 +87,32 @@ add_task(async function test_overwrite_does_not_delete_first() { add_task(async function test_overwrite_works() { let dialogPromise = BrowserTestUtils.domWindowOpenedAndLoaded(); let publicDownloads = await Downloads.getList(Downloads.PUBLIC); - // First ensure we catch the download finishing. - let downloadFinishedPromise = new Promise(resolve => { - publicDownloads.addView({ - onDownloadChanged(download) { - info("Download changed!"); - if (download.succeeded || download.error) { - info("Download succeeded or errored"); - publicDownloads.removeView(this); - publicDownloads.removeFinished(); - resolve(download); - } - }, - }); - }); // Now try and download a thing to the file: await BrowserTestUtils.withNewTab(TEST_ROOT + "foo.txt", async function() { - if ( - !Services.prefs.getBoolPref( - "browser.download.improvements_to_download_panel" - ) - ) { - let dialog = await dialogPromise; - info("Got dialog."); - let saveEl = dialog.document.getElementById("save"); - dialog.document.getElementById("mode").selectedItem = saveEl; - // Allow accepting the dialog (to avoid the delay helper): - dialog.document - .getElementById("unknownContentType") - .getButton("accept").disabled = false; - // Then accept it: - dialog.document.querySelector("dialog").acceptDialog(); - } - + let dialog = await dialogPromise; + info("Got dialog."); + // First ensure we catch the download finishing. + let downloadFinishedPromise = new Promise(resolve => { + publicDownloads.addView({ + onDownloadChanged(download) { + info("Download changed!"); + if (download.succeeded || download.error) { + info("Download succeeded or errored"); + publicDownloads.removeView(this); + publicDownloads.removeFinished(); + resolve(download); + } + }, + }); + }); + let saveEl = dialog.document.getElementById("save"); + dialog.document.getElementById("mode").selectedItem = saveEl; + // Allow accepting the dialog (to avoid the delay helper): + dialog.document + .getElementById("unknownContentType") + .getButton("accept").disabled = false; + // Then accept it: + dialog.document.querySelector("dialog").acceptDialog(); info("wait for download to finish"); let download = await downloadFinishedPromise; ok(download.succeeded, "Download should succeed"); diff --git a/browser/components/downloads/test/browser/browser_first_download_panel.js b/browser/components/downloads/test/browser/browser_first_download_panel.js index 488f98ecc06a..cbffcc35bd61 100644 --- a/browser/components/downloads/test/browser/browser_first_download_panel.js +++ b/browser/components/downloads/test/browser/browser_first_download_panel.js @@ -49,26 +49,17 @@ add_task(async function test_first_download_panel() { "Should have recorded that the panel was opened on a download." ); - // If browser.download.improvements_to_download_panel is enabled, this will fail - // because we always open a downloads panel as long as there is no other simulatenous - // download. So, first ensure that this pref is already false. - if ( - !SpecialPowers.getBoolPref( - "browser.download.improvements_to_download_panel" - ) - ) { - // Next, make sure that if we start another download, we don't open the - // panel automatically. - let originalOnPopupShown = DownloadsPanel.onPopupShown; - DownloadsPanel.onPopupShown = function() { - originalOnPopupShown.apply(this, arguments); - ok(false, "Should not have opened the downloads panel."); - }; + // Next, make sure that if we start another download, we don't open the + // panel automatically. + let originalOnPopupShown = DownloadsPanel.onPopupShown; + DownloadsPanel.onPopupShown = function() { + originalOnPopupShown.apply(this, arguments); + ok(false, "Should not have opened the downloads panel."); + }; - DownloadsCommon.getData(window)._notifyDownloadEvent("start"); + DownloadsCommon.getData(window)._notifyDownloadEvent("start"); - // Wait 2 seconds to ensure that the panel does not open. - await new Promise(resolve => setTimeout(resolve, 2000)); - DownloadsPanel.onPopupShown = originalOnPopupShown; - } + // Wait 2 seconds to ensure that the panel does not open. + await new Promise(resolve => setTimeout(resolve, 2000)); + DownloadsPanel.onPopupShown = originalOnPopupShown; }); diff --git a/browser/components/downloads/test/browser/browser_image_mimetype_issues.js b/browser/components/downloads/test/browser/browser_image_mimetype_issues.js index f1fb8ea1aef3..096d81120f49 100644 --- a/browser/components/downloads/test/browser/browser_image_mimetype_issues.js +++ b/browser/components/downloads/test/browser/browser_image_mimetype_issues.js @@ -56,12 +56,6 @@ add_task(async function test_save_image_webp_with_jpeg_extension() { * Test with the "save link as" context menu. */ add_task(async function test_save_link_webp_with_jpeg_extension() { - await SpecialPowers.pushPrefEnv({ - set: [ - ["browser.download.improvements_to_download_panel", true], - ["browser.download.useDownloadDir", false], - ], - }); await BrowserTestUtils.withNewTab( `data:text/html,Nice image`, async browser => { diff --git a/toolkit/mozapps/downloads/tests/browser/browser_unknownContentType_delayedbutton.js b/toolkit/mozapps/downloads/tests/browser/browser_unknownContentType_delayedbutton.js index 5dfb2512621b..092be50cdd18 100644 --- a/toolkit/mozapps/downloads/tests/browser/browser_unknownContentType_delayedbutton.js +++ b/toolkit/mozapps/downloads/tests/browser/browser_unknownContentType_delayedbutton.js @@ -51,30 +51,6 @@ function waitDelay(delay) { } add_task(async function test_unknownContentType_delayedbutton() { - info("Starting browser_unknownContentType_delayedbutton.js..."); - - // If browser.download.improvements_to_download_panel pref is enabled, - // the unknownContentType will not appear by default. - // So wait an amount of time to ensure it hasn't opened. - let windowOpenDelay = waitDelay(1000); - let uctWindow = await Promise.race([ - windowOpenDelay, - UCTObserver.opened.promise, - ]); - const prefEnabled = Services.prefs.getBoolPref( - "browser.download.improvements_to_download_panel", - false - ); - - if (prefEnabled) { - SimpleTest.is( - !uctWindow, - true, - "UnknownContentType window shouldn't open." - ); - return; - } - Services.ww.registerNotification(UCTObserver); await BrowserTestUtils.withNewTab( diff --git a/toolkit/mozapps/downloads/tests/browser/browser_unknownContentType_dialog_layout.js b/toolkit/mozapps/downloads/tests/browser/browser_unknownContentType_dialog_layout.js index 77e534e5174c..bb41d61c7f69 100644 --- a/toolkit/mozapps/downloads/tests/browser/browser_unknownContentType_dialog_layout.js +++ b/toolkit/mozapps/downloads/tests/browser/browser_unknownContentType_dialog_layout.js @@ -31,13 +31,6 @@ let tests = [ }, ]; -function waitDelay(delay) { - return new Promise((resolve, reject) => { - /* eslint-disable mozilla/no-arbitrary-setTimeout */ - window.setTimeout(resolve, delay); - }); -} - add_task(async function test_unknownContentType_dialog_layout() { for (let test of tests) { let UCTObserver = { @@ -79,26 +72,7 @@ add_task(async function test_unknownContentType_dialog_layout() { waitForStateStop: true, }, async function() { - // If browser.download.improvements_to_download_panel pref is enabled, - // the unknownContentType will not appear by default. - // So wait an amount of time to ensure it hasn't opened. - let windowOpenDelay = waitDelay(1000); - let uctWindow = await Promise.race([ - windowOpenDelay, - UCTObserver.opened.promise, - ]); - const prefEnabled = Services.prefs.getBoolPref( - "browser.download.improvements_to_download_panel" - ); - - if (prefEnabled) { - SimpleTest.is( - !uctWindow, - true, - "UnknownContentType window shouldn't open." - ); - return; - } + let uctWindow = await UCTObserver.opened.promise; for (let [id, props] of Object.entries(test.elements)) { let elem = uctWindow.dialog.dialogElement(id); diff --git a/toolkit/mozapps/downloads/tests/browser/browser_unknownContentType_extension.js b/toolkit/mozapps/downloads/tests/browser/browser_unknownContentType_extension.js index c058299bfc84..849461d496fc 100644 --- a/toolkit/mozapps/downloads/tests/browser/browser_unknownContentType_extension.js +++ b/toolkit/mozapps/downloads/tests/browser/browser_unknownContentType_extension.js @@ -8,38 +8,12 @@ const TEST_PATH = getRootDirectory(gTestPath).replace( "http://example.com" ); -function waitDelay(delay) { - return new Promise((resolve, reject) => { - /* eslint-disable mozilla/no-arbitrary-setTimeout */ - window.setTimeout(resolve, delay); - }); -} - /** * Check that case-sensitivity doesn't cause us to duplicate * file name extensions. */ add_task(async function test_download_filename_extension() { let windowObserver = BrowserTestUtils.domWindowOpenedAndLoaded(); - - // If browser.download.improvements_to_download_panel pref is enabled, - // the unknownContentType will not appear by default. - // So wait an amount of time to ensure it hasn't opened. - let windowOpenDelay = waitDelay(1000); - let uctWindow = await Promise.race([windowOpenDelay, windowObserver.promise]); - const prefEnabled = Services.prefs.getBoolPref( - "browser.download.improvements_to_download_panel" - ); - - if (prefEnabled) { - SimpleTest.is( - !uctWindow, - true, - "UnknownContentType window shouldn't open." - ); - return; - } - let tab = await BrowserTestUtils.openNewForegroundTab({ gBrowser, opening: TEST_PATH + "unknownContentType.EXE",