Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9561)

Unified Diff: chrome/test/data/extensions/api_test/file_system/open_directory/test.js

Issue 23146016: Add support for directory access to the file system API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@simpler-write-permissions
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/file_system/open_directory/test.js
diff --git a/chrome/test/data/extensions/api_test/file_system/open_directory/test.js b/chrome/test/data/extensions/api_test/file_system/open_directory/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..db4a01e5b2eac5a3ebcf0492952ac6a8559e9608
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/file_system/open_directory/test.js
@@ -0,0 +1,98 @@
+// Copyright 2013 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.
+
+// Testing with directory access, but no write permission.
+chrome.test.runTests([
+ function openFile() {
+ chrome.fileSystem.chooseEntry(
+ {type: 'openDirectory'},
+ chrome.test.callbackPass(function(directoryEntry) {
+ directoryEntry.getFile(
+ 'open_existing.txt', {},
+ chrome.test.callback(function(entry) {
+ checkEntry(entry, 'open_existing.txt', false, false);
+ }));
+ }));
+ },
+ function readDirectory() {
+ chrome.fileSystem.chooseEntry(
+ {type: 'openDirectory'},
+ chrome.test.callbackPass(function(directoryEntry) {
+ var reader = directoryEntry.createReader();
+ reader.readEntries(chrome.test.callback(function(entries) {
+ chrome.test.assertEq(entries.length, 1);
+ var entry = entries[0];
+ checkEntry(entry, 'open_existing.txt', false, false);
+ }));
+ }));
+ },
+ function removeFile() {
+ chrome.fileSystem.chooseEntry(
+ {type: 'openDirectory'},
+ chrome.test.callbackPass(function(directoryEntry) {
+ directoryEntry.getFile(
+ 'open_existing.txt', {}, chrome.test.callback(function(entry) {
+ entry.remove(chrome.test.callback(function() {
+ chrome.test.fail('Could delete a file without permission');
+ }), chrome.test.callback(function() {
+ chrome.test.succeed();
+ }));
+ }));
+ }));
+ },
+ function copyFile() {
+ chrome.fileSystem.chooseEntry(
+ {type: 'openDirectory'},
+ chrome.test.callbackPass(function(directoryEntry) {
+ directoryEntry.getFile(
+ 'open_existing.txt', {}, chrome.test.callback(function(entry) {
+ entry.copyTo(
+ directoryEntry, 'copy.txt', chrome.test.callback(function() {
+ chrome.test.fail('Could copy a file without permission.');
+ }), chrome.test.callback(function() {
+ chrome.test.succeed();
+ }));
+ }));
+ }));
+ },
+ function moveFile() {
+ chrome.fileSystem.chooseEntry(
+ {type: 'openDirectory'},
+ chrome.test.callbackPass(function(directoryEntry) {
+ directoryEntry.getFile(
+ 'open_existing.txt', {}, chrome.test.callback(function(entry) {
+ entry.moveTo(
+ directoryEntry, 'moved.txt', chrome.test.callback(function() {
+ chrome.test.fail('Could move a file without permission.');
+ }), chrome.test.callback(function() {
+ chrome.test.succeed();
+ }));
+ }));
+ }));
+ },
+ function createFile() {
+ chrome.fileSystem.chooseEntry(
+ {type: 'openDirectory'},
+ chrome.test.callbackPass(function(directoryEntry) {
+ directoryEntry.getFile(
+ 'new.txt', {create: true}, chrome.test.callback(function() {
+ chrome.test.fail('Could create a file without permission.');
+ }), chrome.test.callback(function() {
+ chrome.test.succeed();
+ }));
+ }));
+ },
+ function createDirectory() {
+ chrome.fileSystem.chooseEntry(
+ {type: 'openDirectory'},
+ chrome.test.callbackPass(function(directoryEntry) {
+ directoryEntry.getDirectory(
+ 'new', {create: true}, chrome.test.callback(function() {
+ chrome.test.fail('Could create a directory without permission.');
+ }), chrome.test.callback(function() {
+ chrome.test.succeed();
+ }));
+ }));
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698