问题
I'm trying to use the Chrome Experimental Devtools API.
I've tried running Chrome with: --enable-experimental-extension-apis as suggested here: http://developer.chrome.com/extensions/experimental.html and enabled the "Experimental Extension APIs" in the flags settings.
When I open the Console in Chrome (or Canary), I get the following:
- chrome.devtools: undefined
- chrome.experimental: undefined
I'm running Chrome 21.0.1180.77 beta-m. I've also tried Canary.
What am I missing?
回答1:
As explained here: http://developer.chrome.com/extensions/devtools.html, the chrome.devtools APIs are only available in your devtools HTML page.
First, you need to create an HTML file and then add it to your extension's manifest under the "devtools_page" key. When you load your extension into Chrome and open the DevTools, you should see your new tab.
In that tab is the only place chrome.devtools will work.
chrome.experimental is different and will be available in all of your background pages and content scripts.
回答2:
You need to run it only in Canary. Plus when you run chrome add this flag to the command line:
path_to_chrome.exe --enable-experimental-extension-apis
来源:https://stackoverflow.com/questions/11932096/unable-to-use-chrome-experimental-devtools-api