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..0cb41e9dcaa1da57a7c8b69b1af50ba22975289e |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/file_system/open_existing/test.js |
@@ -0,0 +1,33 @@ |
+// Copyright (c) 2012 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. |
+ |
+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 blob = new Blob(['HoHoHo!'], {type: 'text/plain'}); |
+ fileWriter.write(blob); |
+ })); |
+ }); |
+ reader.onerror = chrome.test.callback(function(e) { |
+ chrome.test.fail("Error reading file contents."); |
+ }); |
+ reader.readAsText(file); |
+ })); |
+ })); |
+ } |
+]); |