Backed out 2 changesets (bug 1724319) for causing failures on browser_download_overwrite.js. CLOSED TREE

Backed out changeset 75a253b872d4 (bug 1724319)
Backed out changeset d0926e8e7148 (bug 1724319)
This commit is contained in:
criss 2021-09-14 18:11:00 +03:00
Родитель b0ade3c139
Коммит 23838f8659
6 изменённых файлов: 47 добавлений и 157 удалений

Просмотреть файл

@ -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");

Просмотреть файл

@ -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;
});

Просмотреть файл

@ -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,<a href="${TEST_ROOT}/not-really-a-jpeg.jpeg?convert=webp">Nice image</a>`,
async browser => {

Просмотреть файл

@ -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(

Просмотреть файл

@ -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);

Просмотреть файл

@ -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",