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

Unified 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: Fixed 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/file_system/open_existing/test.js
diff --git a/chrome/test/data/extensions/api_test/file_system/open_existing/test.js b/chrome/test/data/extensions/api_test/file_system/open_existing/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..5a3c2fb1a4f6cb7151ab7763a3b606cc6e0bebf2
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/file_system/open_existing/test.js
@@ -0,0 +1,30 @@
+chrome.test.runTests([
+ function openFile() {
+ chrome.fileSystem.chooseFile(chrome.test.callbackPass(function(entry) {
+ chrome.test.assertEq('open_existing.txt', entry.name);
+ // Test that the file can be read.
+ entry.file(chrome.test.callback(function(file) {
+ var reader = new FileReader();
+ reader.onloadend = chrome.test.callback(function(e) {
+ chrome.test.assertEq(reader.result.indexOf("Can you see me?"), 0);
+ // Test that we cannot write to the file.
+ entry.createWriter(chrome.test.callback(function(fileWriter) {
+ fileWriter.onwriteend = chrome.test.callback(function(e) {
+ if (fileWriter.error)
+ chrome.test.succeed();
+ else
+ chrome.test.fail("No error while writing without write access");
+ });
+ var bb = new WebKitBlobBuilder();
+ bb.append('HoHoHo!');
+ fileWriter.write(bb.getBlob('text/plain'));
kinuko 2012/06/24 09:55:57 Please use new Blob constructor instead: new Blob
benwells 2012/06/25 19:07:21 Done.
+ }));
+ });
+ reader.onerror = chrome.test.callback(function(e) {
+ chrome.test.fail("Error reading file contents.");
+ });
+ reader.readAsText(file);
+ }));
+ }));
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698