Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

调试框架脚本

这篇翻译不完整。请帮忙从英语翻译这篇文章

浏览器内容工具箱仅在 Firefox Nightly 中可用,并且仅在多进程模式下可用。

你可以使用浏览器内容工具箱来调试框架脚本。浏览器内容工具箱是一个单独的窗口,它包括一些共享的 Firefox 开发者工具,具体来说:控制台JavaScript 调试器,以及代码草稿纸 —— 但它们着重于浏览器的内容进程。这意味着你可以调试你的附加组件中的框架脚本。

打开浏览器内容工具箱

要打开浏览器内容工具箱,你需要:

  • 正在运行 Firefox Nightly
  • 多进程 Firefox 已启用:打开“选项”页面,选择"启用 E10S (多进程)“,然后重新启动。在你运行多进程 Firefox 时,一个虚拟指示符会出现,远程选项卡的标题会有下划线。
  • 在 Firefox 开发者工具的设置中启用 "chrome 和附加组件调试" 和 "远程调试"

你应该已经在 Firefox 菜单中 ”Web 开发者“的子菜单中看到”浏览器内容工具箱“(或者工具菜单,如果你显示了菜单栏,或者在 OS X)。它会打开一个单独的窗口:

If you've used the Firefox Developer Tools before, this should look pretty familiar.

Along the top is a row of tabs that you can use to switch the active tool. Currently we only support the Console, the Debugger, and Scratchpad in the Browser Content Toolbox. At the right of this row are three buttons that activate the split console, open settings, and close the toolbox.

The rest of the toolbox is taken up with the tool you've currently selected.

使用

调试器

The Debugger lists all the scripts that are loaded into the content process. You'll find your frame scripts listed under the chrome:// URL you registered for them:

You can set breakpoints, of course, and do all the other things supported by the debugger.

控制台

The Console logs output from your frame scripts. If you want to use it to evaluate JavaScript in your frame script's scope, there's a trick you need to know:

  • 在你的框架脚本中设置一个断点。
  • When you hit the breakpoint, switch to the Console, or activate the split console by pressing "Escape".

Now the console's scope is your frame script's scope, and you can interact directly with it:

文档标签和贡献者

 此页面的贡献者: yfdyh000
 最后编辑者: yfdyh000,