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

Unified Diff: chrome/test/data/extensions/api_test/local_filesystem/background.js

Issue 8763008: Move yet another block of tests to manifest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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/local_filesystem/background.js
===================================================================
--- chrome/test/data/extensions/api_test/local_filesystem/background.js (revision 0)
+++ chrome/test/data/extensions/api_test/local_filesystem/background.js (revision 0)
@@ -0,0 +1,65 @@
+// Copyright (c) 2011 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.
+
+var fileSystem = null;
+var testDirName = "tmp/test_dir_" + Math.floor(Math.random()*10000);
+var testFileName = "test_file_" + Math.floor(Math.random()*10000);
+
+// Get local FS, create dir with a file in it.
+console.log("Requesting local file system...");
+chrome.fileBrowserPrivate.requestLocalFileSystem(getFileSystem);
+
+function getFileSystem(fs, error) {
+ if (!fs) {
+ errorCallback(error);
+ return;
+ }
+ fileSystem = fs;
+ console.log("DONE requesting local filesystem: " + fileSystem.name);
+ console.log("Creating directory : " + testDirName);
+ fileSystem.root.getDirectory(testDirName, {create:true},
+ directoryCallback, errorCallback);
+}
+
+function directoryCallback(directory) {
+ console.log("DONE creating directory: " + directory.fullPath);
+ directory.getFile(testFileName, {create:true}, fileCallback, errorCallback);
+}
+
+function fileCallback(file) {
+ console.log("DONE creating file: " + file.fullPath);
+
+ // See if we can access this filesystem and its elements in the tab.
+ console.log("Opening tab...");
+ chrome.tabs.create({
+ url: "tab.html#" + escape(testDirName + "/" + testFileName)
+ });
+}
+
+function errorCallback(e) {
+ var msg = '';
+ switch (e.code) {
+ case FileError.QUOTA_EXCEEDED_ERR:
+ msg = 'QUOTA_EXCEEDED_ERR';
+ break;
+ case FileError.NOT_FOUND_ERR:
+ msg = 'NOT_FOUND_ERR';
+ break;
+ case FileError.SECURITY_ERR:
+ msg = 'SECURITY_ERR';
+ break;
+ case FileError.INVALID_MODIFICATION_ERR:
+ msg = 'INVALID_MODIFICATION_ERR';
+ break;
+ case FileError.INVALID_STATE_ERR:
+ msg = 'INVALID_STATE_ERR';
+ break;
+ default:
+ msg = 'Unknown Error';
+ break;
+ };
+ chrome.test.fail("Got unexpected error: " + msg);
+ console.log('Error: ' + msg);
+ alert('Error: ' + msg);
+}

Powered by Google App Engine
This is Rietveld 408576698