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

Unified Diff: chrome/test/data/extensions/platform_apps/file_access_restored_test/test.js

Issue 14607023: Add support for persistent file access in apps. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 7 years, 7 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/platform_apps/file_access_restored_test/test.js
diff --git a/chrome/test/data/extensions/platform_apps/file_access_restored_test/test.js b/chrome/test/data/extensions/platform_apps/file_access_restored_test/test.js
index 07ebb0b4ca415d1ab22cda6790ed6a88d7403d0c..32a744a8350509e8d6dd79562e5d0d065613f2d8 100644
--- a/chrome/test/data/extensions/platform_apps/file_access_restored_test/test.js
+++ b/chrome/test/data/extensions/platform_apps/file_access_restored_test/test.js
@@ -26,7 +26,7 @@ chrome.app.runtime.onLaunched.addListener(function() {
var fs = win.contentWindow.chrome.fileSystem;
fs.chooseEntry({type: 'openFile'}, function(entry) {
fs.getWritableEntry(entry, function(writableEntry) {
- var id = fs.getEntryId(entry);
+ var id = fs.retainEntry(entry);
chrome.storage.local.set({id:id}, function() {
truncateAndWriteToFile(writableEntry, function() {
chrome.test.sendMessage('fileWritten');
@@ -40,35 +40,36 @@ chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.runtime.onRestarted.addListener(function() {
chrome.storage.local.get(null, function(data) {
- var entry = chrome.fileSystem.getEntryById(data.id);
- if (!entry) {
- console.error("couldn't get file entry " + data.id);
- return;
- }
- entry.file(function(file) {
- var fr = new FileReader();
- fr.onload = function(e) {
- if (e.target.result != expectedText) {
- console.error(
- "expected '" + expectedText + "', got '" + e.target.result + "'");
- return;
- }
- entry.createWriter(function(fileWriter) {
- fileWriter.onwriteend = function(e) {
- chrome.test.sendMessage('restartedFileAccessOK');
- win.close();
- };
- fileWriter.onerror = function(e) {
- console.error('Write failed: ' + e.toString());
- };
- var blob = new Blob(["doesn't matter"], {type: 'text/plain'});
- fileWriter.write(blob);
- });
- };
- fr.onerror = function(e) {
- chrome.test.fail("error reading file");
- };
- fr.readAsText(file);
+ chrome.fileSystem.restoreEntry(data.id, function(entry) {
+ if (!entry) {
+ console.error("couldn't get file entry " + data.id);
+ return;
+ }
+ entry.file(function(file) {
+ var fr = new FileReader();
+ fr.onload = function(e) {
+ if (e.target.result != expectedText) {
+ console.error("expected '" + expectedText + "', got '" +
+ e.target.result + "'");
+ return;
+ }
+ entry.createWriter(function(fileWriter) {
+ fileWriter.onwriteend = function(e) {
+ chrome.test.sendMessage('restartedFileAccessOK');
+ win.close();
+ };
+ fileWriter.onerror = function(e) {
+ console.error('Write failed: ' + e.toString());
+ };
+ var blob = new Blob(["doesn't matter"], {type: 'text/plain'});
+ fileWriter.write(blob);
+ });
+ };
+ fr.onerror = function(e) {
+ chrome.test.fail("error reading file");
+ };
+ fr.readAsText(file);
+ });
});
});
});

Powered by Google App Engine
This is Rietveld 408576698