Commit d4ffaa11 authored by sammc@chromium.org's avatar sammc@chromium.org

Reject filesystem root entries as args for chrome.fileSystem functions.

BUG=333600

Review URL: https://codereview.chromium.org/139543005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245468 0039d316-1c4b-4281-b951-d872f2087c98
parent 14bc5d68
...@@ -366,6 +366,11 @@ bool ValidateFileEntryAndGetPath( ...@@ -366,6 +366,11 @@ bool ValidateFileEntryAndGetPath(
const content::RenderViewHost* render_view_host, const content::RenderViewHost* render_view_host,
base::FilePath* file_path, base::FilePath* file_path,
std::string* error) { std::string* error) {
if (filesystem_path.empty()) {
*error = kInvalidParameters;
return false;
}
std::string filesystem_id; std::string filesystem_id;
if (!fileapi::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) { if (!fileapi::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) {
*error = kInvalidParameters; *error = kInvalidParameters;
......
...@@ -553,6 +553,16 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest, ...@@ -553,6 +553,16 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
"api_test/file_system/get_writable_file_entry_with_write")) << message_; "api_test/file_system/get_writable_file_entry_with_write")) << message_;
} }
IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
FileSystemApiGetWritableRootEntryTest) {
base::FilePath test_file = TempFilePath("writable.txt", true);
ASSERT_FALSE(test_file.empty());
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_file);
ASSERT_TRUE(RunPlatformAppTest(
"api_test/file_system/get_writable_root_entry")) << message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiIsWritableTest) { IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiIsWritableTest) {
base::FilePath test_file = TempFilePath("writable.txt", true); base::FilePath test_file = TempFilePath("writable.txt", true);
ASSERT_FALSE(test_file.empty()); ASSERT_FALSE(test_file.empty());
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.app.runtime.onLaunched.addListener(function () {
chrome.app.window.create('test.html');
});
{
"name": "chrome.fileSystem get writable file entry",
"version": "0.1",
"description": "Test for chrome.fileSystem.getWritableFileEntry",
"app": {
"background": {
"scripts": ["background.js"]
}
},
"permissions": [
{
"fileSystem": ["write"]
}
]
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.test.runTests([
function getWritableEntry() {
chrome.fileSystem.chooseEntry(chrome.test.callbackPass(function(entry) {
chrome.test.assertEq('writable.txt', entry.name);
// Test that we cannot get a writable entry for the root entry.
chrome.fileSystem.getWritableEntry(
entry.filesystem.root, chrome.test.callbackFail(
'Invalid parameters'));
}));
}
]);
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