5

我正在尝试将Chrome扩展移植到Firefox使用新的 Mozilla WebExtension API。问题是使用Chrome我可以分别调试背景页面和弹出窗口。此外,每次打开弹出窗口时都会运行popup.js脚本,并且可以使用 ... 重新加载background.jsCtrl+R,我不知道如何在Firefox. 我什至不知道这是否可能。据我所知,这两个脚本(background.jspopup.js)仅在浏览器重新启动时才执行(不是吗?)。

任何人都知道如何解决这些问题,或者调试用 ? 编写的 Firefox 扩展的好方法WebExtension API

谢谢!

4

3 回答 3

2

最新版本的 Firefox(例如 49)拥有更强大的 WebExtension 调试工具,MDN 上的最新文档解释了如何使用它们。您将需要浏览器工具箱,并且您可能希望设置一个自定义 Firefox 配置文件以默认启用浏览器工具箱(或已安装DevPrefs 插件)。

于 2016-09-20T20:40:30.227 回答
1

Unfortunately debugging WebExtensions is a pain at the moment. A related bug.

The only thing you can do at this time is use debugger; statements to set the breakpoints in the code. The debugger you need is Browser Toolbox.

Open the Browser Toolbox, focus the debugger tab, wait for the sources to load and then trigger your code to reach those statements. Proceed as usual.

As for reloading things, browser action was supposedly fixed and the background is executed every time you disable and re-enable your addon.

However, Firefox suffers from various code cache issues since forever so disabling and re-enabling your addon might not pick up any changes. Your best bet is restarting the browser every time. There is also a discussion to support live reload.

于 2016-01-04T12:16:55.320 回答
1

Did you tryed with the Browser Toolbox? https://developer.mozilla.org/en-US/docs/Tools/Browser_Toolbox

Once your Firefox has the "Enable browser chrome and add-on debugging toolboxes" and "Enable remote debugging" options enabled, you can access it with Ctrl + Alt +Shift + I key combination.

于 2016-01-05T00:53:03.977 回答