mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Backed out changeset 5fc41ac00d90 (bug 1710941) for causing mochitest failures in browser_download_skips_dialog. CLOSED TREE
This commit is contained in:
parent
b71c0650a5
commit
1ce906a40d
@ -449,11 +449,7 @@ HandlerService.prototype = {
|
||||
if (
|
||||
handlerInfo.preferredAction == Ci.nsIHandlerInfo.saveToDisk ||
|
||||
handlerInfo.preferredAction == Ci.nsIHandlerInfo.useSystemDefault ||
|
||||
handlerInfo.preferredAction == Ci.nsIHandlerInfo.handleInternally ||
|
||||
(handlerInfo.preferredAction == Ci.nsIHandlerInfo.alwaysAsk &&
|
||||
Services.prefs.getBoolPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
))
|
||||
handlerInfo.preferredAction == Ci.nsIHandlerInfo.handleInternally
|
||||
) {
|
||||
storedHandlerInfo.action = handlerInfo.preferredAction;
|
||||
} else {
|
||||
|
@ -1813,19 +1813,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
|
||||
// check mReason and the preferred action to see what we should do.
|
||||
|
||||
bool alwaysAsk = true;
|
||||
|
||||
// Skip showing UnknownContentType dialog, unless it is explicitly
|
||||
// set in preferences.
|
||||
bool skipShowingDialog =
|
||||
Preferences::GetBool("browser.download.useDownloadDir") &&
|
||||
StaticPrefs::browser_download_improvements_to_download_panel();
|
||||
|
||||
if (skipShowingDialog) {
|
||||
alwaysAsk = false;
|
||||
} else {
|
||||
mMimeInfo->GetAlwaysAskBeforeHandling(&alwaysAsk);
|
||||
}
|
||||
|
||||
mMimeInfo->GetAlwaysAskBeforeHandling(&alwaysAsk);
|
||||
if (alwaysAsk) {
|
||||
// But we *don't* ask if this mimeInfo didn't come from
|
||||
// our user configuration datastore and the user has said
|
||||
@ -1872,28 +1860,18 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
|
||||
int32_t action = nsIMIMEInfo::saveToDisk;
|
||||
mMimeInfo->GetPreferredAction(&action);
|
||||
|
||||
bool forcePrompt =
|
||||
mReason == nsIHelperAppLauncherDialog::REASON_TYPESNIFFED ||
|
||||
(mReason == nsIHelperAppLauncherDialog::REASON_SERVERREQUEST &&
|
||||
!skipShowingDialog);
|
||||
|
||||
// OK, now check why we're here
|
||||
if (!alwaysAsk && forcePrompt) {
|
||||
if (!alwaysAsk && mReason != nsIHelperAppLauncherDialog::REASON_CANTHANDLE) {
|
||||
// Force asking if we're not saving. See comment back when we fetched the
|
||||
// alwaysAsk boolean for details.
|
||||
alwaysAsk = (action != nsIMIMEInfo::saveToDisk);
|
||||
}
|
||||
|
||||
bool shouldAutomaticallyHandleInternally =
|
||||
action == nsIMIMEInfo::handleInternally &&
|
||||
StaticPrefs::browser_download_improvements_to_download_panel();
|
||||
|
||||
// If we're not asking, check we actually know what to do:
|
||||
if (!alwaysAsk) {
|
||||
alwaysAsk = action != nsIMIMEInfo::saveToDisk &&
|
||||
action != nsIMIMEInfo::useHelperApp &&
|
||||
action != nsIMIMEInfo::useSystemDefault &&
|
||||
!shouldAutomaticallyHandleInternally;
|
||||
action != nsIMIMEInfo::useSystemDefault;
|
||||
}
|
||||
|
||||
// if we were told that we _must_ save to disk without asking, all the stuff
|
||||
@ -1956,9 +1934,8 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
|
||||
|
||||
#endif
|
||||
if (action == nsIMIMEInfo::useHelperApp ||
|
||||
action == nsIMIMEInfo::useSystemDefault ||
|
||||
shouldAutomaticallyHandleInternally) {
|
||||
rv = LaunchWithApplication(shouldAutomaticallyHandleInternally);
|
||||
action == nsIMIMEInfo::useSystemDefault) {
|
||||
rv = LaunchWithApplication(mHandleInternally);
|
||||
} else {
|
||||
rv = PromptForSaveDestination();
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ support-files =
|
||||
file_xml_attachment_binary_octet_stream.xml^headers^
|
||||
file_xml_attachment_test.xml
|
||||
file_xml_attachment_test.xml^headers^
|
||||
[browser_download_skips_dialog.js]
|
||||
[browser_download_urlescape.js]
|
||||
support-files =
|
||||
file_with@@funny_name.png
|
||||
|
@ -1,51 +0,0 @@
|
||||
const { DownloadIntegration } = ChromeUtils.import(
|
||||
"resource://gre/modules/DownloadIntegration.jsm"
|
||||
);
|
||||
|
||||
const TEST_PATH = getRootDirectory(gTestPath).replace(
|
||||
"chrome://mochitests/content",
|
||||
"https://example.com"
|
||||
);
|
||||
|
||||
// New file is being downloaded and no dialogs are shown in the way.
|
||||
add_task(async function skipDialogAndDownloadFile() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.useDownloadDir", true],
|
||||
],
|
||||
});
|
||||
|
||||
let publicList = await Downloads.getList(Downloads.PUBLIC);
|
||||
registerCleanupFunction(async () => {
|
||||
await publicList.removeFinished();
|
||||
});
|
||||
let downloadFinishedPromise = promiseDownloadFinished(publicList);
|
||||
|
||||
let loadingTab = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
TEST_PATH + "file_pdf_application_pdf.pdf"
|
||||
);
|
||||
// We just open the file to be downloaded... and wait for it to be downloaded!
|
||||
// We see no dialogs to be accepted in the process.
|
||||
let download = await downloadFinishedPromise;
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
BrowserTestUtils.removeTab(loadingTab);
|
||||
|
||||
Assert.ok(
|
||||
await OS.File.exists(download.target.path),
|
||||
"The file should have been downloaded."
|
||||
);
|
||||
|
||||
try {
|
||||
info("removing " + download.target.path);
|
||||
if (Services.appinfo.OS === "WINNT") {
|
||||
// We need to make the file writable to delete it on Windows.
|
||||
await IOUtils.setPermissions(download.target.path, 0o600);
|
||||
}
|
||||
await IOUtils.remove(download.target.path);
|
||||
} catch (ex) {
|
||||
info("The file " + download.target.path + " is not removed, " + ex);
|
||||
}
|
||||
});
|
@ -2,10 +2,6 @@ const { DownloadIntegration } = ChromeUtils.import(
|
||||
"resource://gre/modules/DownloadIntegration.jsm"
|
||||
);
|
||||
|
||||
const { TestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/TestUtils.jsm"
|
||||
);
|
||||
|
||||
const TEST_PATH = getRootDirectory(gTestPath).replace(
|
||||
"chrome://mochitests/content",
|
||||
"https://example.com"
|
||||
@ -15,10 +11,7 @@ const TEST_PATH = getRootDirectory(gTestPath).replace(
|
||||
// is actually saved in default Downloads directory.
|
||||
add_task(async function aDownloadLaunchedWithAppIsSavedInDownloadsFolder() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.useDownloadDir", false],
|
||||
],
|
||||
set: [["browser.download.improvements_to_download_panel", true]],
|
||||
});
|
||||
|
||||
let publicList = await Downloads.getList(Downloads.PUBLIC);
|
||||
|
Loading…
Reference in New Issue
Block a user