Unable to use Chrome Experimental Devtools API

心不动则不痛 提交于 2019-12-10 20:37:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!