调试新的 Mozilla WebExtension API
Debugging new Mozilla WebExtension API
我正在尝试使用新的 Mozilla WebExtension API 将 Chrome
扩展移植到 Firefox
。问题是使用 Chrome
我可以分别调试后台页面和弹出窗口。此外,每次打开弹出窗口时,popup.js 脚本都是 运行,而 background.js 可能是使用 Ctrl+R 重新加载...我不知道如何在 Firefox
中执行此操作。我什至不知道这是否可能。据我所知,两个脚本(background.js 和 popup.js)仅在浏览器重新启动时执行(不是吗?)。
任何人都知道如何解决这些问题,或调试使用 WebExtension API
?
编写的 Firefox 扩展的好方法
谢谢!
不幸的是,目前调试 WebExtensions 很痛苦。 A related bug.
此时你唯一能做的就是使用debugger;
语句在代码中设置断点。您需要的调试器是 Browser Toolbox.
打开浏览器工具箱,选中调试器选项卡,等待源代码加载,然后触发您的代码以访问这些语句。照常进行。
至于重新加载,浏览器操作是 supposedly fixed 并且每次您禁用和 re-enable 您的插件时都会执行后台。
但是,Firefox 存在各种问题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。
您尝试过浏览器工具箱吗? https://developer.mozilla.org/en-US/docs/Tools/Browser_Toolbox
一旦您的 Firefox 启用了 "Enable browser chrome and add-on debugging toolboxes" 和 "Enable remote debugging" 选项,您就可以使用 Ctrl + Alt +Shift + I 组合键访问它。
最新版本的 Firefox(例如 49)具有更强大的 WebExtension 调试工具,并且 recent docs on MDN explain how to use them. You'll want the Browser Toolbox, and you may want to set up a custom Firefox profile that enables the Browser Toolbox by default (or has installed the DevPrefs addon)。
我正在尝试使用新的 Mozilla WebExtension API 将 Chrome
扩展移植到 Firefox
。问题是使用 Chrome
我可以分别调试后台页面和弹出窗口。此外,每次打开弹出窗口时,popup.js 脚本都是 运行,而 background.js 可能是使用 Ctrl+R 重新加载...我不知道如何在 Firefox
中执行此操作。我什至不知道这是否可能。据我所知,两个脚本(background.js 和 popup.js)仅在浏览器重新启动时执行(不是吗?)。
任何人都知道如何解决这些问题,或调试使用 WebExtension API
?
谢谢!
不幸的是,目前调试 WebExtensions 很痛苦。 A related bug.
此时你唯一能做的就是使用debugger;
语句在代码中设置断点。您需要的调试器是 Browser Toolbox.
打开浏览器工具箱,选中调试器选项卡,等待源代码加载,然后触发您的代码以访问这些语句。照常进行。
至于重新加载,浏览器操作是 supposedly fixed 并且每次您禁用和 re-enable 您的插件时都会执行后台。
但是,Firefox 存在各种问题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。
您尝试过浏览器工具箱吗? https://developer.mozilla.org/en-US/docs/Tools/Browser_Toolbox
一旦您的 Firefox 启用了 "Enable browser chrome and add-on debugging toolboxes" 和 "Enable remote debugging" 选项,您就可以使用 Ctrl + Alt +Shift + I 组合键访问它。
最新版本的 Firefox(例如 49)具有更强大的 WebExtension 调试工具,并且 recent docs on MDN explain how to use them. You'll want the Browser Toolbox, and you may want to set up a custom Firefox profile that enables the Browser Toolbox by default (or has installed the DevPrefs addon)。