简体   繁体   中英

Failure installing the debug extension of your Crossrider Extension - Firefox

FF25.0, Fedora 18.

This just keeps going round in circles. The staging extension installs, and parts of it are active as the extension modifies a bit of the dom (I think even the background script is running too as the local storage is initialized). Not all of the extension works, such as the sidebar and other dom injection that should run on page load. But the debug mode page in crossrider fails to recognise the running extension.

I suspect this is due to a bug in my code but there appears to be no way to debug it. When I commented out the sidebar, it still showed briefly after another install, which makes me suspect a proxy/cache is getting in the way but adding an extra GET argument on the extension URL didn't help. I've tried adding debugger to extension.js . The console is empty. No errors are reported by firebug. The extension works fine in chrome, and I really don't want to go back to a blank extension and try adding bit by bit till it fails. There must be a simpler way such as making firefox just say, "here's your problem, right on line number X" . Any ideas?

[ EDIT ]
After turning on some debug options, I've got errors in the console, but clicking on the offending file/line number just opens the "Source of:..." window. In google chrome I get the file in the debugger, can hit break points, refresh and catch the error as it happens. Better yet, how about a "break-on-exceptions" option that both works but also actually works.

[ EDIT ]
I finally got the Browser Debugger working. The first error is a NS_ERROR_XPC_BAD_OP_ON_WN_PROTO .

Well, to start actually getting messages you need to set some flags in " about:config " listed here: Setting_up_extension_development_environment

I'll copy a few...

  • javascript.options.showInConsole = true (this was already on for me)
  • browser.dom.window.dump.enabled = true
  • javascript.options.strict = true (there's also a debug version I turned on too)
  • devtools.chrome.enabled = true (nothing to do with google chrome)
  • devtools.debugger.remote-enabled = true ( the important one , allowing Firefox->Web Developer->Browser Debugger , make sure to allow the remote debugger otherwise it undoes the config change)
  • devtools.errorconsole.enabled = true
  • extensions.logging.enabled = true

It looks like quite a few options have been removed too. This has at least got me started.

[ EDIT ]
This answer also mentions the "Web Developer->Browser Debugger" (which is currently blank - "no sources" - I have no idea) and "Web Developer->Browser Console" windows (just seems to have the same output as the in-window console).

  1. Throw a giant try/catch around ALL your extension code. At least this allows the crossrider "staging" extension to install and be recognised.

  2. Print the exception (I assume all the stupid about:config stuff has to be set for this to work)

     appAPI.ready(function($) { try { ...rest of extension code } catch (e) { console.log("#################", e); } } 
  3. Locate the error in the console, and click on the [object exception] . Note the line number (it won't be correct as other code is injected). Also note we've managed to print an exception and firefox failed to break on it . FFFFFFFFFFFFFFFFFFFF

  4. Add some newlines approximately in the middle of the code.

  5. Reload. Note the line number. If it's changed the error is after the newlines. If not the error is before.

  6. Repeat from step 4 until the error is found.

  7. Take a moment to reflect on the stupidity of this process. (this isn't exactly a comment directed at crossrider, more at the severe lack of simple web development tools and APIs currently available)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM