Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/runtime/get_package_directory/app/test.js |
| diff --git a/chrome/test/data/extensions/api_test/runtime/get_package_directory/app/test.js b/chrome/test/data/extensions/api_test/runtime/get_package_directory/app/test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..70c86c006363b93fc08cf3de81621c0568c405c7 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/runtime/get_package_directory/app/test.js |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2013 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. |
| + |
| +expectedDirectoryEntries = [ |
| + 'background.js', |
| + 'manifest.json', |
| + 'test.html', |
| + 'test.js' |
| +]; |
| + |
| +chrome.test.runTests([ |
| + function getPackageDirectoryEntry() { |
| + chrome.runtime.getPackageDirectoryEntry(chrome.test.callbackPass( |
| + function(directoryEntry) { |
| + var directoryReader = directoryEntry.createReader(); |
| + var directoryContents = []; |
|
benwells
2013/06/11 03:14:51
This test is quite strange. Why do you call readEn
Sam McNally
2013/06/11 06:00:29
readEntries might not return all entries in a sing
|
| + directoryReader.readEntries(chrome.test.callbackPass( |
| + function readEntriesCallback(entries) { |
| + if (entries.length == 0) { |
| + directoryContents.sort(); |
| + chrome.test.assertEq(expectedDirectoryEntries, directoryContents); |
| + } else { |
| + for (var i = 0; i < entries.length; i++) { |
| + directoryContents.push(entries[i].name); |
| + chrome.fileSystem.isWritableEntry( |
| + entries[i], chrome.test.callbackPass(function(isWritable) { |
| + chrome.test.assertFalse(isWritable); |
| + })); |
| + chrome.fileSystem.getWritableEntry( |
| + entries[i], chrome.test.callbackFail( |
| + 'Cannot write to file in a restricted location')); |
| + } |
| + directoryReader.readEntries(readEntriesCallback); |
| + } |
| + })); |
| + })); |
| + } |
| +]); |