Commit ede0a7b8 authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Change default filter in "Save as" dialog to "All files"

Currently when saving a file, the file picker defaults to only showing
files with the same filetype as the one being saved. This can be
confusing, so change the default to showing all files instead.

Does not affect the file picker when opening or uploading files - that
still defaults to being filtered to acceptable filetypes.

Bug: 758674
Change-Id: I64a6413eb46740353af8aaf0fa0d9f2807e81f05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1527944
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642324}
parent aaa90e06
...@@ -864,7 +864,9 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P( ...@@ -864,7 +864,9 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
.WithBrowser() .WithBrowser()
.Offline() .Offline()
.EnableDriveFs(), .EnableDriveFs(),
TestCase("saveFileDialogDriveOfflinePinned").WithBrowser().Offline())); TestCase("saveFileDialogDriveOfflinePinned").WithBrowser().Offline(),
TestCase("openFileDialogDefaultFilter").WithBrowser(),
TestCase("saveFileDialogDefaultFilter").WithBrowser()));
WRAPPED_INSTANTIATE_TEST_SUITE_P( WRAPPED_INSTANTIATE_TEST_SUITE_P(
CopyBetweenWindows, /* copy_between_windows.js */ CopyBetweenWindows, /* copy_between_windows.js */
......
...@@ -182,6 +182,9 @@ DialogFooter.prototype.initFileTypeFilter = function( ...@@ -182,6 +182,9 @@ DialogFooter.prototype.initFileTypeFilter = function(
const option = document.createElement('option'); const option = document.createElement('option');
option.innerText = str('ALL_FILES_FILTER'); option.innerText = str('ALL_FILES_FILTER');
option.value = 0; option.value = 0;
if (this.dialogType_ === DialogType.SELECT_SAVEAS_FILE) {
option.selected = true;
}
this.fileTypeSelector.appendChild(option); this.fileTypeSelector.appendChild(option);
} }
......
...@@ -370,3 +370,42 @@ testcase.openFileDialogUnload = async () => { ...@@ -370,3 +370,42 @@ testcase.openFileDialogUnload = async () => {
const dialog = await remoteCall.waitForWindow('dialog#'); const dialog = await remoteCall.waitForWindow('dialog#');
await unloadOpenFileDialog(dialog); await unloadOpenFileDialog(dialog);
}; };
/**
* Tests that the open file dialog's filetype filter does not default to all
* types.
*/
testcase.openFileDialogDefaultFilter = async () => {
const params = {
type: 'openFile',
accepts: [{extensions: ['jpg']}],
acceptsAllTypes: true,
};
chrome.fileSystem.chooseEntry(params, (entry) => {});
const dialog = await remoteCall.waitForWindow('dialog#');
// Check: 'JPEG image' should be selected.
const selectedFilter =
await remoteCall.waitForElement(dialog, '.file-type option:checked');
chrome.test.assertEq('1', selectedFilter.value);
chrome.test.assertEq('JPEG image', selectedFilter.text);
};
/**
* Tests that the save file dialog's filetype filter defaults to all types.
*/
testcase.saveFileDialogDefaultFilter = async () => {
const params = {
type: 'saveFile',
accepts: [{extensions: ['jpg']}],
acceptsAllTypes: true,
};
chrome.fileSystem.chooseEntry(params, (entry) => {});
const dialog = await remoteCall.waitForWindow('dialog#');
// Check: 'All files' should be selected.
const selectedFilter =
await remoteCall.waitForElement(dialog, '.file-type option:checked');
chrome.test.assertEq('0', selectedFilter.value);
chrome.test.assertEq('All files', selectedFilter.text);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment