OLD | NEW |
(Empty) | |
| 1 chrome.test.runTests([ |
| 2 function openFile() { |
| 3 chrome.fileSystem.chooseFile(chrome.test.callbackPass(function(entry) { |
| 4 chrome.test.assertEq('open_existing.txt', entry.name); |
| 5 // Test that the file can be read. |
| 6 entry.file(chrome.test.callback(function(file) { |
| 7 var reader = new FileReader(); |
| 8 reader.onloadend = chrome.test.callback(function(e) { |
| 9 chrome.test.assertEq(reader.result.indexOf("Can you see me?"), 0); |
| 10 // Test that we cannot write to the file. |
| 11 entry.createWriter(chrome.test.callback(function(fileWriter) { |
| 12 fileWriter.onwriteend = chrome.test.callback(function(e) { |
| 13 if (fileWriter.error) |
| 14 chrome.test.succeed(); |
| 15 else |
| 16 chrome.test.fail("No error while writing without write access"); |
| 17 }); |
| 18 var blob = new Blob(['HoHoHo!'], {type: 'text/plain'}); |
| 19 fileWriter.write(blob); |
| 20 })); |
| 21 }); |
| 22 reader.onerror = chrome.test.callback(function(e) { |
| 23 chrome.test.fail("Error reading file contents."); |
| 24 }); |
| 25 reader.readAsText(file); |
| 26 })); |
| 27 })); |
| 28 } |
| 29 ]); |
OLD | NEW |