javascript - 如何从 chrome 调试 API 中捕获时间线数据

标签 javascript google-chrome debugging google-chrome-extension google-chrome-devtools

任务:目标是获取所有由安装的扩展程序触发的功能。

预期输出:Javascript 函数调用,类似于时间轴面板中显示的内容。

描述: 如上所述,我想从 chrome 获取时间线数据。为此,我正在使用 chrome remote debugging protocol 的时间轴功能使用 chrome javascript debugger API 获取时间线数据.我正在使用以下代码启动调试器:

chrome.debugger.attach({ tabId: tabid }, version, onAttach.bind(null,tabid); chrome.debugger.sendCommand({ tabId: tabid }, "Tracing.start");

然而,当我运行这段代码时,我收到一条错误消息,指出时间轴已被弃用,请使用跟踪。尽管官方文档没有提到时间轴已被弃用。我也尝试过跟踪以消除错误,但仍然没有捕获到任何事件。是否有标志问题?


阅读 Chrome Apps & Extensions Developer Tool 的代码后,我发现 chrome.activityLogPrivate API 可以通过不同的扩展记录所有事件。但是,我无法通过在我的扩展中调用来运行它,它仍然未定义。我也找不到此扩展的文档。

最佳答案

稳定 1.1 Debugging protocol没有“跟踪”,但是,"tip of the tree" docs准确地说:

Timeline domain is deprecated. Please use Tracing instead.

它应该只是一个警告,因为:

As of Google Chrome 31, we commit to supporting v1.1. All subsequent 1.* versions of the protocol are going to be backwards compatible with 1.1. Our protocol backwards compatibility commitment is:

  • No commands or events are removed from the protocol.
  • No required parameters are added to the commands.
  • No required parameters are removed from command responses or events.

因此您的命令应该正常工作。


chrome.activityLogPrivate API 就是它在 jar 头上所说的 - private。它仅针对 Chrome 代码中列入白名单的特定扩展程序启用,并且未公开记录。

所以不,除非你使用 hack,否则你不能使用它 like this one ,不能保证有效。

关于javascript - 如何从 chrome 调试 API 中捕获时间线数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31108164/

相关文章:

javascript - chrome 扩展的浏览器 Action 、后台脚本和内容脚本之间通信的上下文和方法?

html - 如何注册来自不同域的 Service Worker

windows - 使用 vmware 机器进行内核调试

Android Studio调试清除应用程序数据但再次运行应用程序时数据没有被删除?

javascript - 使用 jQuery 在页面重定向后显示 DIV

javascript - $ ("a").href 始终返回绝对 URL,即使 href 属性是相对的

javascript - 如果未安装 Google Earth 插件,请切换到 Google map

javascript - 如何监听CKEditor中的基本事件?

css - 在 Chrome 中清除焦点上的 HTML5 占位符属性文本

debugging - gdb + nasm调试信息未创建