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

Unified Diff: chrome/renderer/resources/extensions/extension_custom_bindings.js

Issue 12210113: Check existence of chrome.runtime APIs using __lookupGetter__ to avoid throwing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extensions/extension_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/extension_custom_bindings.js b/chrome/renderer/resources/extensions/extension_custom_bindings.js
index 4311ee9e386632c86935d8f9627f24b79f60dcfc..60b4f12ad175e1e8aba23357493b61d0f0899db7 100644
--- a/chrome/renderer/resources/extensions/extension_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/extension_custom_bindings.js
@@ -79,13 +79,12 @@ chromeHidden.registerCustomHook('extension',
'onConnect', 'onConnectExternal', 'onMessage', 'onMessageExternal'
];
mayNeedAlias.forEach(function(alias) {
- try {
- // Deliberately accessing runtime[alias] rather than testing its
- // existence, since accessing may throw an exception if this context
- // doesn't have access.
- if (chrome.runtime[alias])
- chrome.extension[alias] = chrome.runtime[alias];
- } catch(e) {}
+ // Checking existence isn't enough since some functions are disabled via
+ // getters that throw exceptions. Assume that any getter is such a function.
+ if (chrome.runtime.hasOwnProperty(alias) &&
+ chrome.runtime.__lookupGetter__(alias) === undefined) {
+ chrome.extension[alias] = chrome.runtime[alias];
+ }
});
apiFunctions.setUpdateArgumentsPreValidate('sendRequest',
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698