我如何调试firefox扩展,它似乎在无声中崩溃 [英] How do I debug a firefox extension, it seemingly crashes silently

查看:105
本文介绍了我如何调试firefox扩展,它似乎在无声中崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何调试我的简单扩展。脚本(内容脚本)会加载(因为第一个console.log调用会显示在选项卡的控制台中),但随后不会加载任何脚本。

I cannot figure out how to debug my simple extension. Script (a content script) loads (because the first console.log call shows in the tab's console) but then nothing. There's no error what so ever and no second console.log call.

我的问题不是解决我的代码问题(如果只有firefox会告诉我,肯定是一个问题)在哪里),这是关于在Firefox中找到有关该附件的警告/错误的地方(例如 sdfsdf没有对象属性...)

My question is not about solving my code issue (there surely is one, if only firefox would tell me where), it's about finding the place where warnings/errors about the add-on are in firefox (like 'sdfsdf has no object property ...')

关于:调试无济于事,它可以打开的控制台显示一些错误(例如:错误:服务 domainInfo不可用。请确保它出现在模块背景使用的位置的 requiresServices属性中。))与我要执行的操作无关(我可以从错误的来源和性质中看出来)

about:debugging is no help, the console it can open shows some errors (example: 'Error: Service "domainInfo" is not available. Make sure it appears in the "requiresServices" property of the module's background where is it used.') that have nothing to do with what I'm trying to do (I can tell from the source and nature of errors)

// start of file
console.log('I AM LOADING');
// simple DOM manipulation code here...
console.log('I AM LOADED');
// end of file


推荐答案

内容应该使用DevTools实例调试脚本

The content scripts are supposed to be debugged with the DevTools instance attached to the web page.

但是,您注意到,选项卡的Web控制台中未报告内容脚本中的错误由于错误。 (自Firefox 70开始。)

However, as you noticed, the errors in the content script are not reported in the tab's Web Console due to a bug. (As of Firefox 70.)

作为解决方法,您可以:

As a workaround you can:


  • 使用try..catch记录日志,

  • 检查浏览器控制台(确实会在内容脚本中显示错误)

  • 使用调试器的异常暂停选项。

  • use try..catch with logging,
  • check the Browser Console (which does show error in the content script)
  • use the Debugger's "pause on exceptions" option.

这篇关于我如何调试firefox扩展,它似乎在无声中崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆