My favorites | Sign in
Project Home Downloads Wiki Issues
New issue   Search
for
  Advanced search   Search tips
Issue 110694: chrome.extension.getViews crashes extensions
1 person starred this issue and may be notified of changes. Back to list
 
Reported by contac...@visibotech.com, Jan 18, 2012
Chrome Version       : 18.0.1010.1
OS Version: 6.0 (Windows Vista, Windows Server 2008)
URLs (if applicable) :
Other browsers tested:
Add OK or FAIL after other browsers where you have tested this issue:
Safari 5:
Firefox 4.x:
IE 7/8/9:

What steps will reproduce the problem?
1. Any call to chrome.extension.getViews result error 
2. e.g.  
    var views = chrome.extension.getViews({
        type:'tab'
    });
3.

What is the expected result?
Return views of the extension

What happens instead?

result this error

extensions/schema_generated_bindings.js:703 Uncaught TypeError: Cannot read property 'WINDOW_ID_NONE' of undefined

Please provide any additional information below. Attach a screenshot if
possible.

UserAgentString: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.18 (KHTML, like Gecko) Chrome/18.0.1010.1 Safari/535.18


Comment 1 by mihaip@chromium.org, Jan 19, 2012
I believe this is because extension_custom_bindings.js (http://src.chromium.org/viewvc/chrome/trunk/src/chrome/renderer/resources/extensions/extension_custom_bindings.js?revision=HEAD&view=markup) references chrome.windows.WINDOW_ID_NONE. However,  with http://crrev.com/115252, the chrome.windows namespace is no longer available if the extension doesn't request access to the windows API.

The WINDOW_ID_NONE constant should probably be moved to a place where all bindings can see it, regardless of which APIs the extensions uses.
Status: Assigned
Owner: jstritar@chromium.org
Cc: kal...@chromium.org a...@chromium.org
Labels: -Pri-2 -Area-Undefined -OS-Windows Pri-1 Area-Internals OS-All Mstone-18
Comment 2 by jstritar@chromium.org, Jan 19, 2012
How about we always insert constants into the bindings? Or at least have an option for doing so in the constant definition, like export=true?

Then we'd add this even without access to the windows API:

chrome.windows = {
  WINDOW_ID_NONE: -1,
  WINDOW_ID_CURRENT = -2
}
Comment 3 by kal...@chromium.org, Jan 19, 2012
I'll take this bug since I introduced it with the refactor.

It's more complicated to fix than just adding an "export=true" property to the API json. For a start, the only json that gets passed to schema_generated_bindings in the first place is those which the extension has access to; which "windows" isn't necessarily one of.

So for this approach either:
 - we export all the extension APIs, and schema_generated_bindings.js decides which to inject and which to ignore. It can inspect properties with "export=true" etc etc. This is a gross amount of complexity though, because SGB doesn't have knowledge of this yet, it's complicated enough, there are no tests... etc.
 - just always inject extension APIs and go back to just having the permissions checks on the browser side. This is obviously not an option, since it's the reason for all this in the first place.

Always inserting constants would have a similar problem, but we'd need the additional complexity of having a heuristic to decide which properties are constants. I guess that's why you mention the export=true thing.

But taking a step back, having export=true, I think, defeats the purpose of having these stricter permissions checks and conditional inclusion of APIs. Here are a couple of other ways we could fix this:

 - perhaps, arguably, we should  always be injecting "windows" anyway. We always inject "tabs" because there are functions in tabs that require no permissions, so we have no choice... and since they share the same permission, maybe this means they should both be injected? It would add irritating complexity to the permissions set, but, oh well.
 - just write -1.
 - copy the constant somewhere else and use it there.
Owner: kal...@chromium.org
Cc: jstritar@chromium.org koz@chromium.org
Comment 4 by bugdro...@chromium.org, Jan 20, 2012
The following revision refers to this bug:
    http://src.chromium.org/viewvc/chrome?view=rev&revision=118573

------------------------------------------------------------------------
r118573 | kalman@chromium.org | Fri Jan 20 16:53:25 PST 2012

Changed paths:
 M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/renderer/resources/extensions/extension_custom_bindings.js?r1=118573&r2=118572&pathrev=118573

Fix crash in extension_custom_bindings.js by defining WINDOW_ID_NONE locally
rather than looking up chrome.windows.

BUG=110694
TEST=as in bug

Review URL: https://chromiumcodereview.appspot.com/9138009
------------------------------------------------------------------------
Summary: chrome.extension.getViews crashes extensions
Comment 5 by kal...@chromium.org, Jan 21, 2012
(No comment was entered for this change.)
Status: Fixed
Sign in to add a comment

Powered by Google Project Hosting