Search code examples
firefoxfirefox-addondom-inspector

Editing existing Firefox Add-on


For one of the projects I'm working on, I have to use DOM Inspector to debug a Firefox extension.

The problem with DOM inspector is that it only shows you the browser below the code, there's no way to detach the browser or out the code section or browser side by side.

It didn't work for me because the plugin I was debugging had a large xul overlay, and the problematic area was at the botton, so there's no physical way to see the code for the area as well as the area itself.

So I have decided to modify DOM Inspector itself to place browser to the side of the code editor.

Here are the steps I undertook:

  1. Took the existing xpi file from the profile directory.
  2. Changed it to be a zip.
  3. Went inside and extracted inspector.jar using jar -xf <filename>
  4. Went to inspectorOverlay.xul and changed <vbox id="bxInspectorMain"> to be an hbox. (This should be enough to position those two windows horizontally.)
  5. Then I recreated jar file using jar cf.
  6. Zipped the directory making sure that the name is the same and changed extension back to xpi.

However, when I try to run it, I get the following warnings:

Warning: WARN addons.xpi: Add-on is invalid: [Exception... "Component returned failure code: 0x80520006 (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) [nsIZipReader.getInputStream]"  nsresult: "0x80520006 (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)"  location: "JS frame :: resource://gre/modules/XPIProvider.jsm :: loadManifestFromZipReader :: line 740"  data: no]
Source File: resource://gre/modules/XPIProvider.jsm
Line: 740

Warning: WARN addons.xpi: Could not uninstall invalid item from locked install location
Source File: resource://gre/modules/XPIProvider.jsm
Line: 2042

My question is - what other changes do I generally need to make for the xpi to be properly interpreted?


Solution

  • Zipped the directory making sure that the name is the same and changed extension back to xpi.

    I guess that you did something wrong in this step. Looking at the source code, the message comes from method updateMetadata() - Firefox noticed that the file changed and tries to read in install.rdf again. That file should be at the top level of the XPI file but in your case it cannot be found. Maybe install.rdf is no longer at the top level after you repacked the file. You can test it with the unzip command:

    unzip -l [email protected]
    

    It should show the contents of the XPI file, including install.rdf and chrome.manifest - without any prepended directory name.