Unit tests expect to have chrome privileges. Normally I use enablePrivilege to get enhanced privileges, but for various reasons my test wasn't working correctly. So that's why I wanted to be able to use a chrome:// url to have enhanced privileges 'automatically'.
Normally, I rip an extension apart and put the file in question in the content directory of the extension, but this time I wanted an easier way.
According to this xulplanet, I could add a chrome.manifest file to my profile's chrome/ directory.
My profile directory is: C:\Documents and Settings\mw\Application Data\Mozilla\Firefox\Profiles\uulmz982.Default User
So I thought that adding the chrome.manifest file to C:\Documents and Settings\mw\Application Data\Mozilla\Firefox\Profiles\uulmz982.Default User\chrome would work. Apparently, that doesn't work and isn't supposed to work, so I heard.
My chrome.manifest file consists of this:
content tests file:///C:/testfiles/
So that means I can put content in C:/testfiles/ and can access them with chrome privileges from a certain chrome:// url.
Thanks to Mossop on #extdev, I heard what the 'correct' way is of doing this.
I did the following (finally, after a lot of tries)
- Create a folder named test@test at C:\Documents and Settings\mw\Application Data\Mozilla\Firefox\Profiles\uulmz982.Default User\extensions
- Create 2 files:
-- chrome.manifest, it consists of this:
content tests file:///C:/testfiles/
-- install.rdf, it consists of this: (Mossop gave me this link: http://pastebin.mozilla.org/1839
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>test@test</em:id>
<em:version>1</em:version>
<!-- Firefox compatibility -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>1.0</em:minVersion>
<em:maxVersion>4.0a1</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Test Extension</em:name>
</Description>
</RDF>- Put those 2 files in the above mentioned test@test folder
- Now you should be able to access for instance a 'test.xul' file from 'chrome://tests/content/test.xul', if you have test.xul file:///C:/testfiles/
If it doesn't work, move the test@test folder out of the extensions folder, close Firefox, start it up again, close it again, then move the test@test folder back into the extensions folder and start Firefox up again.
Note, you should now also see the Test Extension in Tools->Add-ons. So basically, I've made a (very simple) extension by doing this.
No comments:
Post a Comment