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

Side by Side 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 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var fileSystem = null;
6 var testDirName = "tmp/test_dir_" + Math.floor(Math.random()*10000);
7 var testFileName = "test_file_" + Math.floor(Math.random()*10000);
8
9 // Get local FS, create dir with a file in it.
10 console.log("Requesting local file system...");
11 chrome.fileBrowserPrivate.requestLocalFileSystem(getFileSystem);
12
13 function getFileSystem(fs, error) {
14 if (!fs) {
15 errorCallback(error);
16 return;
17 }
18 fileSystem = fs;
19 console.log("DONE requesting local filesystem: " + fileSystem.name);
20 console.log("Creating directory : " + testDirName);
21 fileSystem.root.getDirectory(testDirName, {create:true},
22 directoryCallback, errorCallback);
23 }
24
25 function directoryCallback(directory) {
26 console.log("DONE creating directory: " + directory.fullPath);
27 directory.getFile(testFileName, {create:true}, fileCallback, errorCallback);
28 }
29
30 function fileCallback(file) {
31 console.log("DONE creating file: " + file.fullPath);
32
33 // See if we can access this filesystem and its elements in the tab.
34 console.log("Opening tab...");
35 chrome.tabs.create({
36 url: "tab.html#" + escape(testDirName + "/" + testFileName)
37 });
38 }
39
40 function errorCallback(e) {
41 var msg = '';
42 switch (e.code) {
43 case FileError.QUOTA_EXCEEDED_ERR:
44 msg = 'QUOTA_EXCEEDED_ERR';
45 break;
46 case FileError.NOT_FOUND_ERR:
47 msg = 'NOT_FOUND_ERR';
48 break;
49 case FileError.SECURITY_ERR:
50 msg = 'SECURITY_ERR';
51 break;
52 case FileError.INVALID_MODIFICATION_ERR:
53 msg = 'INVALID_MODIFICATION_ERR';
54 break;
55 case FileError.INVALID_STATE_ERR:
56 msg = 'INVALID_STATE_ERR';
57 break;
58 default:
59 msg = 'Unknown Error';
60 break;
61 };
62 chrome.test.fail("Got unexpected error: " + msg);
63 console.log('Error: ' + msg);
64 alert('Error: ' + msg);
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698