chrome.tabs is undefined

6,203 views
Skip to first unread message

Chris Killpack

unread,
Aug 16, 2012, 12:48:45 AM8/16/12
to chromium-...@chromium.org
I am trying to use the chrome.tabs interface from a content script but despite declaring the "tabs" permission in my manifest the chrome object does not have a tabs property, i.e. chrome.tabs is undefined. The tabs documentation doesn't mention any restrictions on using chrome.tabs from content scripts. I also compared my manifest to the provided samples and the only telling difference is that they only use chrome.tabs from the background page.

I have created a minimal example that reproduces the problem: https://gist.github.com/3366970. I am developing on Mac OS X 21.0.1180.79.
Does anyone have any suggestions?

Chris Killpack

Mihai Parparita

unread,
Aug 16, 2012, 12:55:16 AM8/16/12
to Chris Killpack, chromium-...@chromium.org
The content script documentation does mention that you can't use any APIs (except for chrome.extension.*): https://developer.chrome.com/extensions/content_scripts.html

The usual mechanism for invoking extension APIs from content scripts is to use messaging to ask the background page to make those API calls: https://developer.chrome.com/extensions/messaging.html

Mihai


Chris Killpack

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msg/chromium-extensions/-/IKPnNJldBZEJ.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.

Chris Killpack

unread,
Aug 16, 2012, 1:50:35 PM8/16/12
to chromium-...@chromium.org, Chris Killpack
Mihai - thanks for the pointer. On closer re-reading of that page I saw that it said "They cannot:" instead of "They can:". I'm familiar with the messaging approach you suggested, so I should be good from this point on.

Thanks.

Chris
Mihai

To unsubscribe from this group, send email to chromium-extensions+unsub...@chromium.org.
Reply all
Reply to author
Forward
0 new messages