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

Unified Diff: chrome/test/data/extensions/api_test/runtime/get_package_directory/app/window/test.js

Issue 16470003: Add chrome.runtime.getPackageDirectoryEntry. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 6 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/api_test/runtime/get_package_directory/app/window/test.js
diff --git a/chrome/test/data/extensions/api_test/runtime/get_package_directory/app/window/test.js b/chrome/test/data/extensions/api_test/runtime/get_package_directory/app/window/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..b1c741e157a5779b4246b8a55322b8e800a1f5cf
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/runtime/get_package_directory/app/window/test.js
@@ -0,0 +1,56 @@
+// 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': true,
+ 'manifest.json': true,
+ 'window': {
+ 'test.html': true,
+ 'test.js': true
+ }
+};
+
+function checkTree(root, expectedEntries) {
+ var directoryReader = root.createReader();
+ var contents = [];
+ directoryReader.readEntries(chrome.test.callbackPass(
+ function readEntriesCallback(entries) {
+ if (entries.length == 0) {
+ chrome.test.assertEq(Object.keys(expectedEntries).length, 0);
+ } else {
+ for (var i = 0; i < entries.length; i++) {
+ // Ignore files or directories like .svn.
+ if (entries[i].name[0] == '.')
+ continue;
+ chrome.test.assertTrue(expectedEntries[entries[i].name] != null);
+ if (entries[i].isDirectory) {
+ chrome.test.assertEq(typeof expectedEntries[entries[i].name],
+ 'object');
+ checkTree(entries[i], expectedEntries[entries[i].name]);
+ } else {
+ chrome.test.assertEq(expectedEntries[entries[i].name], true);
+ 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'));
+ }
+ delete expectedEntries[entries[i].name];
+ }
+ directoryReader.readEntries(chrome.test.callbackPass(
+ readEntriesCallback));
+ }
+ }));
+}
+
+chrome.test.runTests([
+ function getPackageDirectoryEntry() {
+ chrome.runtime.getPackageDirectoryEntry(chrome.test.callbackPass(
+ function(directoryEntry) {
+ checkTree(directoryEntry, expectedDirectoryEntries);
+ }));
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698