Commit fd26f600 authored by Zhuoyu Qian's avatar Zhuoyu Qian Committed by Commit Bot

Change ChooseFileSystemEntriesType to be lowercase, dash-delimited

Per the spec [1], the ChooseFileSystemEntriesType should be lowercase,
dash-delimited, such as `save-file`.

[1]: https://wicg.github.io/native-file-system/#api-choosefilesystementries

Bug: 1020715
Change-Id: Iafc02db7344c70589cf007a7d66b9cd3f9dda6a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1981515Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Zhuoyu Qian <zhuoyu.qian@samsung.com>
Cr-Commit-Position: refs/heads/master@{#728357}
parent 2e6f7702
......@@ -145,7 +145,7 @@ IN_PROC_BROWSER_TEST_F(NativeFileSystemBrowserTest, SaveFile) {
content::EvalJs(web_contents,
"(async () => {"
" let e = await self.chooseFileSystemEntries("
" {type: 'saveFile'});"
" {type: 'save-file'});"
" self.entry = e;"
" return e.name; })()"));
......@@ -193,7 +193,7 @@ IN_PROC_BROWSER_TEST_F(NativeFileSystemBrowserTest, DISABLED_OpenFile) {
content::EvalJs(web_contents,
"(async () => {"
" let e = await self.chooseFileSystemEntries("
" {type: 'openFile'});"
" {type: 'open-file'});"
" self.entry = e;"
" return e.name; })()"));
......@@ -242,7 +242,7 @@ IN_PROC_BROWSER_TEST_F(NativeFileSystemBrowserTest, FullscreenOpenFile) {
content::EvalJs(web_contents,
"(async () => {"
" let e = await self.chooseFileSystemEntries("
" {type: 'openFile'});"
" {type: 'open-file'});"
" self.entry = e;"
" return e.name; })()"));
......@@ -327,7 +327,7 @@ IN_PROC_BROWSER_TEST_F(NativeFileSystemBrowserTest, DISABLED_SafeBrowsing) {
content::EvalJs(web_contents,
"(async () => {"
" let e = await self.chooseFileSystemEntries("
" {type: 'saveFile'});"
" {type: 'save-file'});"
" const w = await e.createWriter();"
" await w.write(0, 'abc');"
" await w.close();"
......
......@@ -165,7 +165,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest, SaveFile_NonExistingFile) {
EvalJs(shell(),
"(async () => {"
" let e = await self.chooseFileSystemEntries("
" {type: 'saveFile'});"
" {type: 'save-file'});"
" self.entry = e;"
" return e.name; })()"));
EXPECT_EQ(ui::SelectFileDialog::SELECT_SAVEAS_FILE, dialog_params.type);
......@@ -198,7 +198,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest,
EvalJs(shell(),
"(async () => {"
" let e = await self.chooseFileSystemEntries("
" {type: 'saveFile'});"
" {type: 'save-file'});"
" self.entry = e;"
" return e.name; })()"));
EXPECT_EQ(ui::SelectFileDialog::SELECT_SAVEAS_FILE, dialog_params.type);
......@@ -231,7 +231,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest,
ASSERT_TRUE(
NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")));
auto result =
EvalJs(shell(), "self.chooseFileSystemEntries({type: 'saveFile'})");
EvalJs(shell(), "self.chooseFileSystemEntries({type: 'save-file'})");
EXPECT_TRUE(result.error.find("not allowed") != std::string::npos)
<< result.error;
EXPECT_EQ(ui::SelectFileDialog::SELECT_NONE, dialog_params.type);
......@@ -250,7 +250,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest, FullscreenSaveFile) {
EvalJs(shell(),
"(async () => {"
" let e = await self.chooseFileSystemEntries("
" {type: 'saveFile'});"
" {type: 'save-file'});"
" self.entry = e;"
" return e.name; })()"));
EXPECT_FALSE(IsFullscreen());
......@@ -305,7 +305,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest, OpenDirectory) {
EvalJs(shell(),
"(async () => {"
" let e = await self.chooseFileSystemEntries("
" {type: 'openDirectory'});"
" {type: 'open-directory'});"
" self.selected_entry = e;"
" return e.name; })()"));
EXPECT_EQ(ui::SelectFileDialog::SELECT_FOLDER, dialog_params.type);
......@@ -323,7 +323,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest, FullscreenOpenDirectory) {
EvalJs(shell(),
"(async () => {"
" let e = await self.chooseFileSystemEntries("
" {type: 'openDirectory'});"
" {type: 'open-directory'});"
" self.selected_entry = e;"
" return e.name; })()"));
EXPECT_FALSE(IsFullscreen());
......@@ -360,7 +360,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest, OpenDirectory_DenyAccess) {
ASSERT_TRUE(
NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")));
auto result =
EvalJs(shell(), "self.chooseFileSystemEntries({type: 'openDirectory'})");
EvalJs(shell(), "self.chooseFileSystemEntries({type: 'open-directory'})");
EXPECT_TRUE(result.error.find("aborted") != std::string::npos)
<< result.error;
}
......@@ -395,7 +395,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest,
ASSERT_TRUE(
NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")));
auto result =
EvalJs(shell(), "self.chooseFileSystemEntries({type: 'saveFile'})");
EvalJs(shell(), "self.chooseFileSystemEntries({type: 'save-file'})");
EXPECT_TRUE(result.error.find("aborted") != std::string::npos)
<< result.error;
......@@ -443,7 +443,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest,
ASSERT_TRUE(
NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")));
auto result =
EvalJs(shell(), "self.chooseFileSystemEntries({type: 'saveFile'})");
EvalJs(shell(), "self.chooseFileSystemEntries({type: 'save-file'})");
EXPECT_TRUE(result.error.find("aborted") != std::string::npos)
<< result.error;
......
......@@ -72,7 +72,7 @@ class NativeFileSystemFileWriterBrowserTest : public ContentBrowserTest {
EvalJs(
shell(),
"(async () => {"
" let e = await self.chooseFileSystemEntries({type: 'openFile'});"
" let e = await self.chooseFileSystemEntries({type: 'open-file'});"
" self.entry = e;"
" self.writers = [];"
" return e.name; })()"));
......@@ -100,7 +100,7 @@ class NativeFileSystemFileWriterBrowserTest : public ContentBrowserTest {
EvalJs(
shell(),
"(async () => {"
" let e = await self.chooseFileSystemEntries({type: 'openFile'});"
" let e = await self.chooseFileSystemEntries({type: 'open-file'});"
" self.entry = e;"
" self.writers = [];"
" return e.name; })()"));
......
......@@ -3,11 +3,18 @@
// found in the LICENSE file.
// https://wicg.github.io/native-file-system/#enumdef-choosefilesystementriestype
enum ChooseFileSystemEntriesType { "openFile", "saveFile", "openDirectory" };
enum ChooseFileSystemEntriesType {
"open-file",
"openFile",
"save-file",
"saveFile",
"open-directory",
"openDirectory"
};
// https://wicg.github.io/native-file-system/#dictdef-choosefilesystementriesoptions
dictionary ChooseFileSystemEntriesOptions {
ChooseFileSystemEntriesType type = "openFile";
ChooseFileSystemEntriesType type = "open-file";
boolean multiple = false;
sequence<ChooseFileSystemEntriesOptionsAccepts> accepts;
boolean excludeAcceptAllOption = false;
......
......@@ -29,14 +29,14 @@ namespace {
mojom::blink::ChooseFileSystemEntryType ConvertChooserType(const String& input,
bool multiple) {
if (input == "openFile") {
if (input == "open-file" || input == "openFile") {
return multiple
? mojom::blink::ChooseFileSystemEntryType::kOpenMultipleFiles
: mojom::blink::ChooseFileSystemEntryType::kOpenFile;
}
if (input == "saveFile")
if (input == "save-file" || input == "saveFile")
return mojom::blink::ChooseFileSystemEntryType::kSaveFile;
if (input == "openDirectory")
if (input == "open-directory" || input == "openDirectory")
return mojom::blink::ChooseFileSystemEntryType::kOpenDirectory;
NOTREACHED();
return mojom::blink::ChooseFileSystemEntryType::kOpenFile;
......
......@@ -126,7 +126,7 @@ TEST_F(WindowNativeFileSystemTest, UserActivationRequiredOtherwiseDenied) {
FAIL();
}));
GetFrame().GetScriptController().ExecuteScriptInMainWorld(
"window.chooseFileSystemEntries({type: 'openFile'});");
"window.chooseFileSystemEntries({type: 'open-file'});");
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(frame->HasStickyUserActivation());
}
......@@ -160,7 +160,7 @@ TEST_F(WindowNativeFileSystemTest, UserActivationChooseEntriesSuccessful) {
std::move(callback).Run(std::move(error), std::move(entries));
}));
GetFrame().GetScriptController().ExecuteScriptInMainWorld(
"window.chooseFileSystemEntries({type: 'openFile'});");
"window.chooseFileSystemEntries({type: 'open-file'});");
manager_run_loop.Run();
// Mock Manager finished sending data over the mojo pipe.
......@@ -208,7 +208,7 @@ TEST_F(WindowNativeFileSystemTest, UserActivationChooseEntriesErrors) {
},
status));
GetFrame().GetScriptController().ExecuteScriptInMainWorld(
"window.chooseFileSystemEntries({type: 'openFile'});");
"window.chooseFileSystemEntries({type: 'open-file'});");
manager_run_loop.Run();
// Mock Manager finished sending data over the mojo pipe.
......
......@@ -14,7 +14,7 @@ const directory_promise = (async () => {
await window.test_driver.bless(
'show a file picker.<br />Please select an empty directory');
const entries = await self.chooseFileSystemEntries({type: 'openDirectory'});
const entries = await self.chooseFileSystemEntries({type: 'open-directory'});
assert_true(entries instanceof FileSystemHandle);
assert_true(entries instanceof FileSystemDirectoryHandle);
for await (const entry of entries.getEntries()) {
......
......@@ -16,7 +16,7 @@
}
try {
window.chooseFileSystemEntries({ type: 'openDirectory' })
window.chooseFileSystemEntries({ type: 'open-directory' })
.then(() => {
post_message('chooseFileSystemEntries(): FULFILLED');
}).catch(error => {
......
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