diff options
author | koz@chromium.org <koz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-27 05:17:08 +0000 |
---|---|---|
committer | koz@chromium.org <koz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-27 05:17:08 +0000 |
commit | 4fe61bc24f343a6a1381a782dec4fb45b2f6c437 (patch) | |
tree | 8e77431d19888f90a707503ec231d23f7f6b2b56 /chrome/test | |
parent | e946986518a345ef3bc7c31e4af4a043734e74c3 (diff) | |
download | chromium_src-4fe61bc24f343a6a1381a782dec4fb45b2f6c437.zip chromium_src-4fe61bc24f343a6a1381a782dec4fb45b2f6c437.tar.gz chromium_src-4fe61bc24f343a6a1381a782dec4fb45b2f6c437.tar.bz2 |
Track and persist what file entries an extension has access to.
Note this change doesn't re-grant permissions to the extensions at any point.
Subsequent patches will cause chrome to restore access to the file entries an
extension had in the case of an unexpected crash (ie: onRestarted()).
BUG=165832
Review URL: https://chromiumcodereview.appspot.com/11857009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
5 files changed, 52 insertions, 2 deletions
diff --git a/chrome/test/data/extensions/api_test/file_system/open_background/background.js b/chrome/test/data/extensions/api_test/file_system/open_background/background.js index 54a5f36..f742d14 100644 --- a/chrome/test/data/extensions/api_test/file_system/open_background/background.js +++ b/chrome/test/data/extensions/api_test/file_system/open_background/background.js @@ -5,6 +5,7 @@ chrome.test.runTests([ function openFile() { chrome.fileSystem.chooseEntry(chrome.test.callbackFail( - 'Invalid calling page', function(entry) {})); + "Invalid calling page. This function can't be called from a " + + "background page.", function(entry) {})); } ]); diff --git a/chrome/test/data/extensions/api_test/file_system/save_background/background.js b/chrome/test/data/extensions/api_test/file_system/save_background/background.js index c1eaa22..9b6f2a0 100644 --- a/chrome/test/data/extensions/api_test/file_system/save_background/background.js +++ b/chrome/test/data/extensions/api_test/file_system/save_background/background.js @@ -5,6 +5,7 @@ chrome.test.runTests([ function openFile() { chrome.fileSystem.chooseEntry({type: 'saveFile'}, chrome.test.callbackFail( - 'Invalid calling page', function(entry) {})); + "Invalid calling page. This function can't be called from a " + + "background page.", function(entry) {})); } ]); diff --git a/chrome/test/data/extensions/platform_apps/file_access_saved_to_prefs_test/index.html b/chrome/test/data/extensions/platform_apps/file_access_saved_to_prefs_test/index.html new file mode 100644 index 0000000..45b983b --- /dev/null +++ b/chrome/test/data/extensions/platform_apps/file_access_saved_to_prefs_test/index.html @@ -0,0 +1 @@ +hi diff --git a/chrome/test/data/extensions/platform_apps/file_access_saved_to_prefs_test/manifest.json b/chrome/test/data/extensions/platform_apps/file_access_saved_to_prefs_test/manifest.json new file mode 100644 index 0000000..59f5cf3 --- /dev/null +++ b/chrome/test/data/extensions/platform_apps/file_access_saved_to_prefs_test/manifest.json @@ -0,0 +1,11 @@ +{ + "name": "Files Preserved Test", + "version": "1", + "manifest_version": 2, + "app": { + "background": { + "scripts": ["test.js"] + } + }, + "permissions": ["fileSystem", "fileSystem.write"] +} diff --git a/chrome/test/data/extensions/platform_apps/file_access_saved_to_prefs_test/test.js b/chrome/test/data/extensions/platform_apps/file_access_saved_to_prefs_test/test.js new file mode 100644 index 0000000..fe42334 --- /dev/null +++ b/chrome/test/data/extensions/platform_apps/file_access_saved_to_prefs_test/test.js @@ -0,0 +1,36 @@ +// 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. + +var textToWrite = 'def'; + +function truncateAndWriteToFile(writableEntry, callback) { + writableEntry.createWriter(function(fileWriter) { + fileWriter.onerror = function(e) { + console.error("Couldn't write file: " + e.toString()); + }; + fileWriter.onwriteend = function(e) { + fileWriter.onwriteend = function(e) { + callback(); + }; + var blob = new Blob([textToWrite], {type: 'text/plain'}); + fileWriter.write(blob); + }; + fileWriter.truncate(0); + }); +} + +chrome.app.runtime.onLaunched.addListener(function() { + chrome.app.window.create('index.html', {width: 100, height: 100}, + function(win) { + var fs = win.contentWindow.chrome.fileSystem; + fs.chooseEntry({type: 'openFile'}, function(entry) { + fs.getWritableEntry(entry, function(writableEntry) { + truncateAndWriteToFile(writableEntry, function() { + chrome.test.sendMessage('fileWritten'); + win.close(); + }); + }); + }); + }); +}); |