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

Side by Side Diff: chrome/test/data/extensions/api_test/file_system/open_existing/test.js

Issue 10663014: Add tests for chrome.fileSystem app API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added licenses to js files Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 chrome.test.runTests([
6 function openFile() {
7 chrome.fileSystem.chooseFile(chrome.test.callbackPass(function(entry) {
8 chrome.test.assertEq('open_existing.txt', entry.name);
9 // Test that the file can be read.
10 entry.file(chrome.test.callback(function(file) {
11 var reader = new FileReader();
12 reader.onloadend = chrome.test.callback(function(e) {
13 chrome.test.assertEq(reader.result.indexOf("Can you see me?"), 0);
14 // Test that we cannot write to the file.
15 entry.createWriter(chrome.test.callback(function(fileWriter) {
16 fileWriter.onwriteend = chrome.test.callback(function(e) {
17 if (fileWriter.error)
18 chrome.test.succeed();
19 else
20 chrome.test.fail("No error while writing without write access");
21 });
22 var blob = new Blob(['HoHoHo!'], {type: 'text/plain'});
23 fileWriter.write(blob);
24 }));
25 });
26 reader.onerror = chrome.test.callback(function(e) {
27 chrome.test.fail("Error reading file contents.");
28 });
29 reader.readAsText(file);
30 }));
31 }));
32 }
33 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698