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

Unified Diff: chrome/test/data/extensions/api_test/stubs/content_script.js

Issue 14494013: Allow API functions and events to have entries in _api_features.json (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bug in searching for unprivileged 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
« no previous file with comments | « chrome/test/data/extensions/api_test/content_scripts/extension_iframe/iframe.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/stubs/content_script.js
diff --git a/chrome/test/data/extensions/api_test/stubs/content_script.js b/chrome/test/data/extensions/api_test/stubs/content_script.js
index 6139d446b61706fec4ec2369194c30a4010d0439..c72215ae6bf4babc71904f456b551be3fe676bac 100644
--- a/chrome/test/data/extensions/api_test/stubs/content_script.js
+++ b/chrome/test/data/extensions/api_test/stubs/content_script.js
@@ -14,6 +14,14 @@ function logToConsoleAndStdout(msg) {
// responds we start the test.
console.log("asking for api ...");
chrome.extension.sendRequest("getApi", function(apis) {
+ var apiFeatures = chrome.test.getApiFeatures();
+ function isAvailableToContentScripts(namespace, path) {
+ if (apiFeatures.hasOwnProperty(path))
+ return apiFeatures[path]['contexts'].indexOf('content_script') != -1
+ return apiFeatures.hasOwnProperty(namespace) &&
+ apiFeatures[namespace]['contexts'].indexOf('content_script') != -1;
+ }
+
console.log("got api response");
var privilegedPaths = [];
var unprivilegedPaths = [];
@@ -31,11 +39,8 @@ chrome.extension.sendRequest("getApi", function(apis) {
}
var path = namespace + "." + entry.name;
- // TODO(cduvall): Make this inspect _api_features.json.
- // http://crbug.com/232247
- // Manually add chrome.app to the unprivileged APIs since it uses the
- // feature system now.
- if (module.unprivileged || entry.unprivileged || namespace == 'app') {
+ if (module.unprivileged || entry.unprivileged ||
+ isAvailableToContentScripts(namespace, path)) {
unprivilegedPaths.push(path);
} else {
privilegedPaths.push(path);
@@ -46,7 +51,8 @@ chrome.extension.sendRequest("getApi", function(apis) {
if (module.properties) {
for (var propName in module.properties) {
var path = namespace + "." + propName;
- if (module.unprivileged || module.properties[propName].unprivileged) {
+ if (module.unprivileged || module.properties[propName].unprivileged ||
+ isAvailableToContentScripts(namespace, path)) {
unprivilegedPaths.push(path);
} else {
privilegedPaths.push(path);
@@ -84,11 +90,13 @@ function testPath(path, expectError) {
try {
if (typeof(module[parts[i]]) == "undefined" &&
path != "extension.lastError" &&
- path != "runtime.lastError" &&
- path != "runtime.id") {
- logToConsoleAndStdout(" fail (undefined and not throwing error): " +
- path);
- return false;
+ path != "runtime.lastError") {
+ if (expectError) {
+ return true;
+ } else {
+ logToConsoleAndStdout(" fail (should not be undefined): " + path);
+ return false;
+ }
} else if (!expectError) {
return true;
}
« no previous file with comments | « chrome/test/data/extensions/api_test/content_scripts/extension_iframe/iframe.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698