diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-07 00:42:58 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-07 00:42:58 +0000 |
commit | aba3560d2cef624a8ad395368c7659fee8405989 (patch) | |
tree | cc2a6749f681f09d24b44a0d522358df11ae6822 /chrome/test | |
parent | a97f5bd11084e087ebf9f93c6967dd97b5e2fe17 (diff) | |
download | chromium_src-aba3560d2cef624a8ad395368c7659fee8405989.zip chromium_src-aba3560d2cef624a8ad395368c7659fee8405989.tar.gz chromium_src-aba3560d2cef624a8ad395368c7659fee8405989.tar.bz2 |
Add extension API test for FileSystem API.
BUG=61534
TEST=ExtensionApiTest.FileAPI
Review URL: http://codereview.chromium.org/5392001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68418 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
3 files changed, 70 insertions, 0 deletions
diff --git a/chrome/test/data/extensions/api_test/fileapi/background.html b/chrome/test/data/extensions/api_test/fileapi/background.html new file mode 100644 index 0000000..a26019f --- /dev/null +++ b/chrome/test/data/extensions/api_test/fileapi/background.html @@ -0,0 +1,32 @@ +<script> + var fileSystem = null; + + console.log("Requesting a filesystem..."); + requestFileSystem(window.TEMPORARY, 100, getFileSystem, errorCallback); + + function getFileSystem(fs) { + fileSystem = fs; + console.log("DONE requesting filesystem: " + fileSystem.name); + fileSystem.root.getDirectory('dir', {create:true}, + directoryCallback, errorCallback); + } + + function directoryCallback(directory) { + console.log("DONE creating directory: " + directory.path); + directory.getFile('file', {create:true}, fileCallback, errorCallback); + } + + function fileCallback(file) { + console.log("DONE creating file: " + file.path); + + // See if we get the same filesystem space in the tab. + console.log("Opening tab..."); + chrome.tabs.create({ + url: "tab.html" + }); + } + + function errorCallback(error) { + chrome.test.fail("Got unexpected error: " + error.code); + } +</script> diff --git a/chrome/test/data/extensions/api_test/fileapi/manifest.json b/chrome/test/data/extensions/api_test/fileapi/manifest.json new file mode 100644 index 0000000..ba60f85 --- /dev/null +++ b/chrome/test/data/extensions/api_test/fileapi/manifest.json @@ -0,0 +1,8 @@ +{ + "name": "chrome.fileapi", + "version": "0.1", + "description": "sanity test that fileapi is always enabled for extensions", + "background_page": "background.html", + "permissions": ["tabs", "unlimitedStorage"] +} + diff --git a/chrome/test/data/extensions/api_test/fileapi/tab.html b/chrome/test/data/extensions/api_test/fileapi/tab.html new file mode 100644 index 0000000..3afb2b7 --- /dev/null +++ b/chrome/test/data/extensions/api_test/fileapi/tab.html @@ -0,0 +1,30 @@ +<script> +var fileSystem = null; + +function errorCallback(error) { + chrome.test.fail("Got unexpected error: " + error.code); +} + +function successCallback(entry) { + chrome.test.succeed(); +} + +function successEntryCallback(entry) { + fileSystem.root.getDirectory('dir', {create:false}, + function(directory) { + // Do clean-up. (Assume the tab won't be reloaded in testing.) + directory.removeRecursively(successCallback, errorCallback); + }, errorCallback); +} + +chrome.test.runTests([function tab() { + console.log("Requesting a filesystem..."); + requestFileSystem(window.TEMPORARY, 100, function(fs) { + fileSystem = fs; + // See if we get the same filesystem image. + console.log("DONE requesting filesystem: " + fileSystem.name); + fileSystem.root.getFile('dir/file', {create:false}, + successEntryCallback, errorCallback); + }, errorCallback); +}]); +</script> |