问题
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:
- Took the existing xpi file from the profile directory.
- Changed it to be a zip.
- Went inside and extracted
inspector.jar
usingjar -xf <filename>
- Went to
inspectorOverlay.xul
and changed<vbox id="bxInspectorMain">
to be an hbox. (This should be enough to position those two windows horizontally.) - Then I recreated jar file using
jar cf
. - 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?
回答1:
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 inspector@mozilla.org.xpi
It should show the contents of the XPI file, including install.rdf
and chrome.manifest
- without any prepended directory name.
回答2:
@Luka, I guess Wladimir Palant is correct. To avoid error during the modification of source code of the existing project, I would suggest you to work in the working environment.
The suggested way to edit your source code:
- Install Eclipse
- Install Xul booster (project / docs)
- Extract your sour code from FF profile.
- Check the name of the main folder and subfolder as exactly given in you extracted .Zippy file (FF extension).
- Create a new project in Eclipse under XUL booster environment: please use the same name of your FF extension main folder and sub folder.
- Then, copy paster your extracted files to the XUL project in Eclipse.
- Modify your code & extract as .XPi file and Install in you FF browser.
This way you can avoid any kind of errors because everything will be classified automatically (Chrome folder, manifest, install.rdf, did dies etc).
Note: There is an advanced way of modifying source code and FF browser wil detect the modification of your source code automatically by setting the environment in your FF extension profile folder.
- Create a bat file and locate your project folder path and type your extension id inside the FF extension profile folder. (guide)
来源:https://stackoverflow.com/questions/7438855/editing-existing-firefox-add-on