--- title: 调试框架脚本 slug: Mozilla/Firefox/Multiprocess_Firefox/Debugging_frame_scripts translation_of: Mozilla/Firefox/Multiprocess_Firefox/Debugging_frame_scripts ---
{{FirefoxSidebar}}

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

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

打开浏览器内容工具箱

{{EmbedYouTube("Cg6X_zIu7Xk")}}

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

你应该已经在 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.

使用

{{EmbedYouTube("XF0ULNnNOxg")}}

调试器

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:

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