зеркало из https://github.com/mozilla/gecko-dev.git
Bug 553169: XPCShell tests for the new extension manager API. r=robstrong
This commit is contained in:
Родитель
e447154804
Коммит
ac0cce8224
|
@ -41,7 +41,7 @@ srcdir = @srcdir@
|
|||
VPATH = @srcdir@
|
||||
ADDONSRC = $(srcdir)/addons
|
||||
TESTROOT = $(CURDIR)/$(DEPTH)/_tests/xpcshell/$(MODULE)
|
||||
TESTXPI = $(TESTROOT)/unit/addons
|
||||
TESTXPI = $(TESTROOT)/xpcshell/addons
|
||||
relativesrcdir = toolkit/mozapps/extensions/test
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
@ -53,7 +53,7 @@ DIRS = \
|
|||
$(NULL)
|
||||
|
||||
XPCSHELL_TESTS = \
|
||||
unit \
|
||||
xpcshell \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function enable() {
|
||||
Services.prefs.setIntPref("bootstraptest.version", 1);
|
||||
}
|
||||
|
||||
function disable() {
|
||||
Services.prefs.setIntPref("bootstraptest.version", 0);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?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>bootstrap1@tests.mozilla.org</em:id>
|
||||
<em:version>1.0</em:version>
|
||||
<em:type>64</em:type>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Test Bootstrap 1</em:name>
|
||||
<em:description>Test Description</em:description>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
|
@ -0,0 +1,9 @@
|
|||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function enable() {
|
||||
Services.prefs.setIntPref("bootstraptest.version", 2);
|
||||
}
|
||||
|
||||
function disable() {
|
||||
Services.prefs.setIntPref("bootstraptest.version", 0);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?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>bootstrap1@tests.mozilla.org</em:id>
|
||||
<em:version>2.0</em:version>
|
||||
<em:type>64</em:type>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Test Bootstrap 1</em:name>
|
||||
<em:description>Test Description</em:description>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- An extension that is compatible with the XPCShell test suite -->
|
||||
<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>addon1@tests.mozilla.org</em:id>
|
||||
<em:version>1.0</em:version>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Test 1</em:name>
|
||||
<em:description>Test Description</em:description>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- An extension that is compatible with the XPCShell test suite -->
|
||||
<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>addon2@tests.mozilla.org</em:id>
|
||||
<em:version>2.0</em:version>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Real Test 2</em:name>
|
||||
<em:description>Test Description</em:description>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- An extension that is compatible with the XPCShell test suite -->
|
||||
<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>addon2@tests.mozilla.org</em:id>
|
||||
<em:version>3.0</em:version>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Real Test 3</em:name>
|
||||
<em:description>Test Description</em:description>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- An extension that is incompatible with the XPCShell test suite until
|
||||
a compatibility update check is performed -->
|
||||
<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>addon3@tests.mozilla.org</em:id>
|
||||
<em:version>1.0</em:version>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Real Test 4</em:name>
|
||||
<em:description>Test Description</em:description>
|
||||
|
||||
<em:updateURL>http://localhost:4444/data/test_install.rdf</em:updateURL>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>0</em:minVersion>
|
||||
<em:maxVersion>0</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
|
@ -0,0 +1,24 @@
|
|||
<?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>theme1@tests.mozilla.org</em:id>
|
||||
<em:version>1.0</em:version>
|
||||
<em:internalName>theme1/1.0</em:internalName>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Test Theme 1</em:name>
|
||||
<em:description>Test Description</em:description>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
|
@ -0,0 +1,23 @@
|
|||
<?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>addon1@tests.mozilla.org</em:id>
|
||||
<em:version>2.0</em:version>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Test 1</em:name>
|
||||
<em:description>Test Description</em:description>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<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:extension:addon3@tests.mozilla.org">
|
||||
<em:updates>
|
||||
<Seq>
|
||||
<li>
|
||||
<Description>
|
||||
<em:version>1.0</em:version>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>0</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</li>
|
||||
</Seq>
|
||||
</em:updates>
|
||||
</Description>
|
||||
|
||||
</RDF>
|
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- This is a copy of extensions.rdf from Firefox 3.5 including four
|
||||
test extensions. Addon1 was enabled, addon2 was disabled, addon3 was pending
|
||||
disable at the next restart and addon4 was pending enable at the next
|
||||
restart. -->
|
||||
|
||||
<RDF:RDF xmlns:NS1="http://www.mozilla.org/2004/em-rdf#"
|
||||
xmlns:NC="http://home.netscape.com/NC-rdf#"
|
||||
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
<RDF:Description RDF:about="rdf:#$w8dNC1"
|
||||
NS1:id="xpcshell@tests.mozilla.org"
|
||||
NS1:minVersion="1"
|
||||
NS1:maxVersion="1" />
|
||||
<RDF:Description RDF:about="rdf:#$oadNC1"
|
||||
NS1:id="xpcshell@tests.mozilla.org"
|
||||
NS1:minVersion="1"
|
||||
NS1:maxVersion="1" />
|
||||
<RDF:Description RDF:about="urn:mozilla:item:addon1@tests.mozilla.org"
|
||||
NS1:installLocation="app-profile"
|
||||
NS1:version="1.0"
|
||||
NS1:name="Test 1">
|
||||
<NS1:type NC:parseType="Integer">2</NS1:type>
|
||||
<NS1:targetApplication RDF:resource="rdf:#$oadNC1"/>
|
||||
</RDF:Description>
|
||||
<RDF:Description RDF:about="urn:mozilla:item:addon2@tests.mozilla.org"
|
||||
NS1:installLocation="app-profile"
|
||||
NS1:version="2.0"
|
||||
NS1:name="Test 2"
|
||||
NS1:userDisabled="true">
|
||||
<NS1:type NC:parseType="Integer">2</NS1:type>
|
||||
<NS1:targetApplication RDF:resource="rdf:#$w8dNC1"/>
|
||||
</RDF:Description>
|
||||
<RDF:Description RDF:about="urn:mozilla:item:addon3@tests.mozilla.org"
|
||||
NS1:installLocation="app-profile"
|
||||
NS1:version="2.0"
|
||||
NS1:name="Test 3"
|
||||
NS1:userDisabled="needs-disable">
|
||||
<NS1:type NC:parseType="Integer">2</NS1:type>
|
||||
<NS1:targetApplication RDF:resource="rdf:#$w8dNC1"/>
|
||||
</RDF:Description>
|
||||
<RDF:Description RDF:about="urn:mozilla:item:addon4@tests.mozilla.org"
|
||||
NS1:installLocation="app-profile"
|
||||
NS1:version="2.0"
|
||||
NS1:name="Test 4"
|
||||
NS1:userDisabled="needs-enable">
|
||||
<NS1:type NC:parseType="Integer">2</NS1:type>
|
||||
<NS1:targetApplication RDF:resource="rdf:#$w8dNC1"/>
|
||||
</RDF:Description>
|
||||
<RDF:Seq RDF:about="urn:mozilla:item:root">
|
||||
<RDF:li RDF:resource="urn:mozilla:item:addon1@tests.mozilla.org"/>
|
||||
<RDF:li RDF:resource="urn:mozilla:item:addon2@tests.mozilla.org"/>
|
||||
<RDF:li RDF:resource="urn:mozilla:item:addon3@tests.mozilla.org"/>
|
||||
<RDF:li RDF:resource="urn:mozilla:item:addon4@tests.mozilla.org"/>
|
||||
</RDF:Seq>
|
||||
</RDF:RDF>
|
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<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:extension:addon1@tests.mozilla.org">
|
||||
<em:updates>
|
||||
<Seq>
|
||||
<li>
|
||||
<Description>
|
||||
<em:version>1.0</em:version>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</li>
|
||||
<li>
|
||||
<Description>
|
||||
<em:version>2.0</em:version>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
<em:updateLink>http://localhost:4444/addons/test_update.xpi</em:updateLink>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</li>
|
||||
</Seq>
|
||||
</em:updates>
|
||||
</Description>
|
||||
|
||||
<Description about="urn:mozilla:extension:addon2@tests.mozilla.org">
|
||||
<em:updates>
|
||||
<Seq>
|
||||
<li>
|
||||
<Description>
|
||||
<em:version>1.0</em:version>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>0</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</li>
|
||||
</Seq>
|
||||
</em:updates>
|
||||
</Description>
|
||||
</RDF>
|
|
@ -0,0 +1,292 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
|
||||
<Description about="urn:mozilla:extension:updatecheck1@tests.mozilla.org">
|
||||
<em:updates>
|
||||
<Seq>
|
||||
<li>
|
||||
<Description>
|
||||
<em:version>1.0</em:version>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
<em:updateLink>https://localhost:4444/addons/test1.xpi</em:updateLink>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</li>
|
||||
<!-- This update is incompatible and so should not be considered a valid
|
||||
update -->
|
||||
<li>
|
||||
<Description>
|
||||
<em:version>2.0</em:version>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>2</em:minVersion>
|
||||
<em:maxVersion>2</em:maxVersion>
|
||||
<em:updateLink>https://localhost:4444/addons/test2.xpi</em:updateLink>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</li>
|
||||
<li>
|
||||
<Description>
|
||||
<em:version>3.0</em:version>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
<em:updateLink>https://localhost:4444/addons/test3.xpi</em:updateLink>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</li>
|
||||
<li>
|
||||
<Description>
|
||||
<em:version>2.0</em:version>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>2</em:maxVersion>
|
||||
<em:updateLink>https://localhost:4444/addons/test2.xpi</em:updateLink>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</li>
|
||||
<!-- This update is incompatible and so should not be considered a valid
|
||||
update -->
|
||||
<li>
|
||||
<Description>
|
||||
<em:version>4.0</em:version>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>2</em:minVersion>
|
||||
<em:maxVersion>2</em:maxVersion>
|
||||
<em:updateLink>https://localhost:4444/addons/test4.xpi</em:updateLink>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</li>
|
||||
</Seq>
|
||||
</em:updates>
|
||||
</Description>
|
||||
|
||||
<!-- An update with no signature which will fail if retrieved with an update
|
||||
key. The updateLink will also be ignored since it is not secure and there
|
||||
is no updateHash. -->
|
||||
<RDF:Description about="urn:mozilla:extension:test_bug378216_5@tests.mozilla.org">
|
||||
<em:updates>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<RDF:Description>
|
||||
<em:version>2.0</em:version>
|
||||
<em:targetApplication>
|
||||
<RDF:Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
<em:updateLink>http://localhost:4444/broken.xpi</em:updateLink>
|
||||
</RDF:Description>
|
||||
</em:targetApplication>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</em:updates>
|
||||
</RDF:Description>
|
||||
|
||||
<!-- An update with a broken signature which will fail if retrieved with an
|
||||
update key. The updateLink will also be ignored since it is not secure
|
||||
and there is no updateHash. -->
|
||||
<RDF:Description about="urn:mozilla:extension:test_bug378216_7@tests.mozilla.org">
|
||||
<em:updates>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<RDF:Description>
|
||||
<em:version>2.0</em:version>
|
||||
<em:targetApplication>
|
||||
<RDF:Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>2</em:maxVersion>
|
||||
<em:updateLink>http://localhost:4444/broken.xpi</em:updateLink>
|
||||
</RDF:Description>
|
||||
</em:targetApplication>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</em:updates>
|
||||
<em:signature>MIGTMA0GCSqGSIb3DQEBBQUAA4GBAMO1O2gwSCCth1GwYMgscfaNakpN40PJfOWt
|
||||
ub2HVdg8+OXMciF8d/9eVWm8eH/IxuxyZlmRZTs3O5tv9eWAY5uBCtqDf1WgTsGk
|
||||
jrgZow1fITkZI7w0//C8eKdMLAtGueGfNs2IlTd5P/0KH/hf1rPc1wUqEqKCd4+L
|
||||
BcVq13ad</em:signature>
|
||||
</RDF:Description>
|
||||
|
||||
<!-- An update with a valid signature. The updateLink will be ignored since it
|
||||
is not secure and there is no updateHash. -->
|
||||
<RDF:Description about="urn:mozilla:extension:test_bug378216_8@tests.mozilla.org">
|
||||
<em:updates>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<RDF:Description>
|
||||
<em:version>2.0</em:version>
|
||||
<em:targetApplication>
|
||||
<RDF:Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
<em:updateLink>http://localhost:4444/broken.xpi</em:updateLink>
|
||||
</RDF:Description>
|
||||
</em:targetApplication>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</em:updates>
|
||||
<em:signature>MIGTMA0GCSqGSIb3DQEBBQUAA4GBAMH/33P/bn148mVkAB8i5X8c4LhY52E+MPUT
|
||||
yKHGpowZnRLgL2O0dfpm+rljOBfKi51322PFrsc6VIFml6x4Lrb5foxSyB0Vs9pb
|
||||
SEDFWUKquOQvceQ9iEx5Pe0VzrmUZgcQxd8ksSunWL4wJaBZ/evE5amFC6sw3pv/
|
||||
fjt8p3GN</em:signature>
|
||||
</RDF:Description>
|
||||
|
||||
<!-- An update with a valid signature. The updateLink will used since there is
|
||||
an updateHash to verify it. -->
|
||||
<RDF:Description about="urn:mozilla:extension:test_bug378216_9@tests.mozilla.org">
|
||||
<em:updates>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<RDF:Description>
|
||||
<em:version>2.0</em:version>
|
||||
<em:targetApplication>
|
||||
<RDF:Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
<em:updateLink>http://localhost:4444/broken.xpi</em:updateLink>
|
||||
<em:updateHash>sha1:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6</em:updateHash>
|
||||
</RDF:Description>
|
||||
</em:targetApplication>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</em:updates>
|
||||
<em:signature>MIGTMA0GCSqGSIb3DQEBBQUAA4GBAJ5Dv3Zd7/j5dLchCw9iO/cxPq8oOhOYD2M+
|
||||
jUKvmHCyTBRIEaJrE4N7yVbRYk++ERIfyVepLivsVi4pBmF7JTdw0NaKUA0LiOoT
|
||||
mRL8I7s5NPjCiiNcdqbncWyiZwIj1w1nkbWGTlH/gEjRW/LbvT4JAuec8yNFDa4S
|
||||
X8mOMf7k</em:signature>
|
||||
</RDF:Description>
|
||||
|
||||
<!-- An update with a valid signature. The updateLink will used since it is
|
||||
a secure URL. -->
|
||||
<RDF:Description about="urn:mozilla:extension:test_bug378216_10@tests.mozilla.org">
|
||||
<em:updates>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<RDF:Description>
|
||||
<em:version>2.0</em:version>
|
||||
<em:targetApplication>
|
||||
<RDF:Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
<em:updateLink>https://localhost:4444/broken.xpi</em:updateLink>
|
||||
</RDF:Description>
|
||||
</em:targetApplication>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</em:updates>
|
||||
<em:signature>MIGTMA0GCSqGSIb3DQEBBQUAA4GBAGvf7XqqoTl5WofrNq55E7W+UttOEDXLB3Oi
|
||||
XDiXe0i6njlozilseaUo1hgfQhhzN9gkyetP5tGBVcLRrVyliKpJmD6ABCVGW1lS
|
||||
qS+SEw7gDHyHkvwKMyWKedpRGChqLYnnf+Y+CX3MWLZLkwPXMKdTYgN3Rx0lEnJk
|
||||
37LSEMKE</em:signature>
|
||||
</RDF:Description>
|
||||
|
||||
<!-- An update with a valid signature. The updateLink will used since it is
|
||||
a secure URL. -->
|
||||
<RDF:Description about="urn:mozilla:extension:test_bug378216_11@tests.mozilla.org">
|
||||
<em:updates>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<RDF:Description>
|
||||
<em:version>2.0</em:version>
|
||||
<em:targetApplication>
|
||||
<RDF:Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
<em:updateLink>https://localhost:4444/broken.xpi</em:updateLink>
|
||||
<em:updateHash>sha1:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6</em:updateHash>
|
||||
</RDF:Description>
|
||||
</em:targetApplication>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</em:updates>
|
||||
<em:signature>MIGTMA0GCSqGSIb3DQEBBQUAA4GBACMX/KReOGSJ8CMGRroH1v3Gjv/Qs/pqH+Ow
|
||||
o+hCKWLUKx7hpJgVJkXXdAHW0U88NXlp1S2H0WqA7I/CdmNXJSPzzV/J4z1dZgXh
|
||||
JbW6mqNb0pj6nIe7g8OLzSxDgBmO4DUP5DAmnmqciJLWQzN7OdbcwrWz6xPN5kZF
|
||||
A90eF5zy</em:signature>
|
||||
</RDF:Description>
|
||||
|
||||
<!-- An update with a valid signature. The updateLink will used since the
|
||||
updateHash verifying it is not strong enough. -->
|
||||
<RDF:Description about="urn:mozilla:extension:test_bug378216_12@tests.mozilla.org">
|
||||
<em:updates>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<RDF:Description>
|
||||
<em:version>2.0</em:version>
|
||||
<em:targetApplication>
|
||||
<RDF:Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
<em:updateLink>http://localhost:4444/broken.xpi</em:updateLink>
|
||||
<em:updateHash>md2:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6</em:updateHash>
|
||||
</RDF:Description>
|
||||
</em:targetApplication>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</em:updates>
|
||||
<em:signature>MIGTMA0GCSqGSIb3DQEBBQUAA4GBAJRfcFvHIWxVyycCw8IjNmEhabc2uqA1zQwp
|
||||
5oKh3Y23hwIsQ6xy68Wtjte1NEYFRt5fWkbMXj9YQj6LpVbzBKiGATcrq6MycZKK
|
||||
o5N22cWbrKKRweJezTyN4eLfQg21pG7r8mdfS0bIA28ZVFtQOmORejoUesEouCGy
|
||||
eKYk9nS2</em:signature>
|
||||
</RDF:Description>
|
||||
|
||||
<!-- An update with a valid signature. The updateLink will used since it is
|
||||
a secure URL. -->
|
||||
<RDF:Description about="urn:mozilla:extension:test_bug378216_13@tests.mozilla.org">
|
||||
<em:updates>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<RDF:Description>
|
||||
<em:version>2.0</em:version>
|
||||
<em:targetApplication>
|
||||
<RDF:Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
<em:updateLink>https://localhost:4444/broken.xpi</em:updateLink>
|
||||
<em:updateHash>md2:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6</em:updateHash>
|
||||
</RDF:Description>
|
||||
</em:targetApplication>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</em:updates>
|
||||
<em:signature>MIGTMA0GCSqGSIb3DQEBBQUAA4GBALQKwzLFr/VOw3gJvv/LCh3/PWDd9FqmFnX+
|
||||
hJjBmCaUDtG7CXn1i0h8ed8IeRHpLLT7FCzVwU3bH9BUjdm8wc3ObtlNbd8go01a
|
||||
CoXz50r3rYPcYz4WS+7/+lvrUqsuWd9Wj+q0NeCPiNaaro6/AolE2Qf5JFRL3lxY
|
||||
lsKWAnVO</em:signature>
|
||||
</RDF:Description>
|
||||
</RDF>
|
|
@ -0,0 +1,452 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
const AM_Cc = Components.classes;
|
||||
const AM_Ci = Components.interfaces;
|
||||
|
||||
const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
|
||||
const XULAPPINFO_CID = Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}");
|
||||
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/FileUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var gInternalManager = null;
|
||||
var gAppInfo = null;
|
||||
var gAddonsList;
|
||||
|
||||
function createAppInfo(id, name, version, platformVersion) {
|
||||
gAppInfo = {
|
||||
// nsIXULAppInfo
|
||||
vendor: "Mozilla",
|
||||
name: name,
|
||||
ID: id,
|
||||
version: version,
|
||||
appBuildID: "2007010101",
|
||||
platformVersion: platformVersion,
|
||||
platformBuildID: "2007010101",
|
||||
|
||||
// nsIXULRuntime
|
||||
inSafeMode: false,
|
||||
logConsoleErrors: true,
|
||||
OS: "XPCShell",
|
||||
XPCOMABI: "noarch-spidermonkey",
|
||||
invalidateCachesOnRestart: function invalidateCachesOnRestart() {
|
||||
// Do nothing
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([AM_Ci.nsIXULAppInfo,
|
||||
AM_Ci.nsIXULRuntime,
|
||||
AM_Ci.nsISupports])
|
||||
};
|
||||
|
||||
var XULAppInfoFactory = {
|
||||
createInstance: function (outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
return gAppInfo.QueryInterface(iid);
|
||||
}
|
||||
};
|
||||
var registrar = Components.manager.QueryInterface(AM_Ci.nsIComponentRegistrar);
|
||||
registrar.registerFactory(XULAPPINFO_CID, "XULAppInfo",
|
||||
XULAPPINFO_CONTRACTID, XULAppInfoFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a testcase xpi
|
||||
*
|
||||
* @param name
|
||||
* The name of the testcase (without extension)
|
||||
* @return an nsILocalFile pointing to the testcase xpi
|
||||
*/
|
||||
function do_get_addon(name) {
|
||||
return do_get_file("addons/" + name + ".xpi");
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts up the add-on manager as if it was started by the application. This
|
||||
* will simulate any restarts requested by the manager.
|
||||
*
|
||||
* @param expectedRestarts
|
||||
* An optional parameter to specify the expected number of restarts.
|
||||
* If passed and the number of restarts requested differs then the
|
||||
* test will fail
|
||||
* @param appChanged
|
||||
* An optional boolean parameter to simulate the case where the
|
||||
* application has changed version since the last run. If not passed it
|
||||
* defaults to true
|
||||
*/
|
||||
function startupManager(expectedRestarts, appChanged) {
|
||||
if (gInternalManager)
|
||||
do_throw("Test attempt to startup manager that was already started.");
|
||||
|
||||
if (appChanged === undefined)
|
||||
appChanged = true;
|
||||
|
||||
// Load the add-ons list as it was during application startup
|
||||
loadAddonsList(appChanged);
|
||||
|
||||
gInternalManager = AM_Cc["@mozilla.org/addons/integration;1"].
|
||||
getService(AM_Ci.nsIObserver).
|
||||
QueryInterface(AM_Ci.nsITimerCallback);
|
||||
|
||||
gInternalManager.observe(null, "profile-after-change", "startup");
|
||||
|
||||
let appStartup = AM_Cc["@mozilla.org/toolkit/app-startup;1"].
|
||||
getService(AM_Ci.nsIAppStartup2);
|
||||
var restart = appChanged || appStartup.needsRestart;
|
||||
appStartup.needsRestart = false;
|
||||
|
||||
if (restart) {
|
||||
if (expectedRestarts !== undefined)
|
||||
restartManager(expectedRestarts - 1);
|
||||
else
|
||||
restartManager();
|
||||
}
|
||||
else if (expectedRestarts !== undefined) {
|
||||
if (expectedRestarts > 0)
|
||||
do_throw("Expected to need to restart " + expectedRestarts + " more times");
|
||||
else if (expectedRestarts < 0)
|
||||
do_throw("Restarted " + (-expectedRestarts) + " more times than expected");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts the add-on manager as if the host application was restarted. This
|
||||
* will simulate any restarts requested by the manager.
|
||||
*
|
||||
* @param expectedRestarts
|
||||
* An optional parameter to specify the expected number of restarts.
|
||||
* If passed and the number of restarts requested differs then the
|
||||
* test will fail
|
||||
* @param newVersion
|
||||
* An optional new version to use for the application. Passing this
|
||||
* will change nsIXULAppInfo.version and make the startup appear as if
|
||||
* the application version has changed.
|
||||
*/
|
||||
function restartManager(expectedRestarts, newVersion) {
|
||||
shutdownManager();
|
||||
if (newVersion) {
|
||||
gAppInfo.version = newVersion;
|
||||
startupManager(expectedRestarts, true);
|
||||
}
|
||||
else {
|
||||
startupManager(expectedRestarts, false);
|
||||
}
|
||||
}
|
||||
|
||||
function shutdownManager() {
|
||||
if (!gInternalManager)
|
||||
return;
|
||||
|
||||
let obs = AM_Cc["@mozilla.org/observer-service;1"].
|
||||
getService(AM_Ci.nsIObserverService);
|
||||
obs.notifyObservers(null, "quit-application-granted", null);
|
||||
gInternalManager.observe(null, "xpcom-shutdown", null);
|
||||
gInternalManager = null;
|
||||
}
|
||||
|
||||
function loadAddonsList(appChanged) {
|
||||
function readDirectories(section) {
|
||||
var dirs = [];
|
||||
var keys = parser.getKeys(section);
|
||||
while (keys.hasMore()) {
|
||||
let descriptor = parser.getString(section, keys.getNext());
|
||||
try {
|
||||
let file = AM_Cc["@mozilla.org/file/local;1"].
|
||||
createInstance(AM_Ci.nsILocalFile);
|
||||
file.persistentDescriptor = descriptor;
|
||||
dirs.push(file);
|
||||
}
|
||||
catch (e) {
|
||||
// Throws if the directory doesn't exist, we can ignore this since the
|
||||
// platform will too.
|
||||
}
|
||||
}
|
||||
return dirs;
|
||||
}
|
||||
|
||||
gAddonsList = {
|
||||
extensions: [],
|
||||
themes: []
|
||||
};
|
||||
|
||||
var file = gProfD.clone();
|
||||
file.append("extensions.ini");
|
||||
if (!file.exists())
|
||||
return;
|
||||
if (appChanged) {
|
||||
file.remove(true);
|
||||
return;
|
||||
}
|
||||
|
||||
var factory = AM_Cc["@mozilla.org/xpcom/ini-parser-factory;1"].
|
||||
getService(AM_Ci.nsIINIParserFactory);
|
||||
var parser = factory.createINIParser(file);
|
||||
gAddonsList.extensions = readDirectories("ExtensionDirs");
|
||||
gAddonsList.themes = readDirectories("ThemeDirs");
|
||||
}
|
||||
|
||||
function isItemInAddonsList(type, dir, id) {
|
||||
var path = dir.clone();
|
||||
path.append(id);
|
||||
for (var i = 0; i < gAddonsList[type].length; i++) {
|
||||
if (gAddonsList[type][i].equals(path))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isThemeInAddonsList(dir, id) {
|
||||
return isItemInAddonsList("themes", dir, id);
|
||||
}
|
||||
|
||||
function isExtensionInAddonsList(dir, id) {
|
||||
return isItemInAddonsList("extensions", dir, id);
|
||||
}
|
||||
|
||||
function writeLocaleStrings(data) {
|
||||
let rdf = "";
|
||||
["name", "description", "creator", "homepageURL"].forEach(function(prop) {
|
||||
if (prop in data)
|
||||
rdf += "<em:" + prop + ">" + data[prop] + "</em:" + prop + ">\n";
|
||||
});
|
||||
|
||||
["developer", "translator", "contributor"].forEach(function(prop) {
|
||||
if (prop in data) {
|
||||
data[prop].forEach(function(value) {
|
||||
rdf += "<em:" + prop + ">" + value + "</em:" + prop + ">\n";
|
||||
});
|
||||
}
|
||||
});
|
||||
return rdf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an install.rdf manifest into a directory using the properties passed
|
||||
* in a JS object. The objects should contain a property for each property to
|
||||
* appear in the RDFThe object may contain an array of objects with id,
|
||||
* minVersion and maxVersion in the targetApplications property to give target
|
||||
* application compatibility.
|
||||
*
|
||||
* @param data
|
||||
* The object holding data about the add-on
|
||||
* @param dir
|
||||
* The directory to add the install.rdf to
|
||||
*/
|
||||
function writeInstallRDFToDir(data, dir) {
|
||||
var rdf = '<?xml version="1.0"?>\n';
|
||||
rdf += '<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n' +
|
||||
' xmlns:em="http://www.mozilla.org/2004/em-rdf#">\n';
|
||||
rdf += '<Description about="urn:mozilla:install-manifest">\n';
|
||||
|
||||
["id", "version", "type", "internalName", "updateURL", "updateKey",
|
||||
"optionsURL", "aboutURL", "iconURL"].forEach(function(prop) {
|
||||
if (prop in data)
|
||||
rdf += "<em:" + prop + ">" + data[prop] + "</em:" + prop + ">\n";
|
||||
});
|
||||
|
||||
rdf += writeLocaleStrings(data);
|
||||
|
||||
if ("targetApplications" in data) {
|
||||
data.targetApplications.forEach(function(app) {
|
||||
rdf += "<em:targetApplication><Description>\n";
|
||||
["id", "minVersion", "maxVersion"].forEach(function(prop) {
|
||||
if (prop in app)
|
||||
rdf += "<em:" + prop + ">" + app[prop] + "</em:" + prop + ">\n";
|
||||
});
|
||||
rdf += "</Description></em:targetApplication>\n";
|
||||
});
|
||||
}
|
||||
|
||||
rdf += "</Description>\n</RDF>\n";
|
||||
|
||||
if (!dir.exists())
|
||||
dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
var file = dir.clone();
|
||||
file.append("install.rdf");
|
||||
var fos = AM_Cc["@mozilla.org/network/file-output-stream;1"].
|
||||
createInstance(AM_Ci.nsIFileOutputStream);
|
||||
fos.init(file,
|
||||
FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE,
|
||||
FileUtils.PERMS_FILE, 0);
|
||||
fos.write(rdf, rdf.length);
|
||||
fos.close();
|
||||
}
|
||||
|
||||
function registerDirectory(key, dir) {
|
||||
var dirProvider = {
|
||||
getFile: function(prop, persistent) {
|
||||
persistent.value = true;
|
||||
if (prop == key)
|
||||
return dir.clone();
|
||||
return null;
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([AM_Ci.nsIDirectoryServiceProvider,
|
||||
AM_Ci.nsISupports])
|
||||
};
|
||||
Services.dirsvc.registerProvider(dirProvider);
|
||||
}
|
||||
|
||||
var gExpectedEvents = {};
|
||||
var gExpectedInstalls = [];
|
||||
var gNext = null;
|
||||
|
||||
function getExpectedEvent(id) {
|
||||
if (!(id in gExpectedEvents))
|
||||
do_throw("Wasn't expecting events for " + id);
|
||||
if (gExpectedEvents[id].length == 0)
|
||||
do_throw("Too many events for " + id);
|
||||
let event = gExpectedEvents[id].shift();
|
||||
if (event instanceof Array)
|
||||
return event;
|
||||
return [event, true];
|
||||
}
|
||||
|
||||
const AddonListener = {
|
||||
onEnabling: function(addon, requiresRestart) {
|
||||
let [event, expectedRestart] = getExpectedEvent(addon.id);
|
||||
do_check_eq("onEnabling", event);
|
||||
do_check_eq(requiresRestart, expectedRestart);
|
||||
if (expectedRestart)
|
||||
do_check_true(hasFlag(addon.pendingOperations, AddonManager.PENDING_ENABLE));
|
||||
do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
},
|
||||
|
||||
onEnabled: function(addon) {
|
||||
let [event, expectedRestart] = getExpectedEvent(addon.id);
|
||||
do_check_eq("onEnabled", event);
|
||||
do_check_eq(requiresRestart, expectedRestart);
|
||||
do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
},
|
||||
|
||||
onDisabling: function(addon, requiresRestart) {
|
||||
let [event, expectedRestart] = getExpectedEvent(addon.id);
|
||||
do_check_eq("onDisabling", event);
|
||||
do_check_eq(requiresRestart, expectedRestart);
|
||||
if (expectedRestart)
|
||||
do_check_true(hasFlag(addon.pendingOperations, AddonManager.PENDING_DISABLE));
|
||||
do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
},
|
||||
|
||||
onDisabled: function(addon) {
|
||||
let [event, expectedRestart] = getExpectedEvent(addon.id);
|
||||
do_check_eq("onDisabled", event);
|
||||
do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
},
|
||||
|
||||
onInstalling: function(addon, requiresRestart) {
|
||||
let [event, expectedRestart] = getExpectedEvent(addon.id);
|
||||
do_check_eq("onInstalling", event);
|
||||
do_check_eq(requiresRestart, expectedRestart);
|
||||
if (expectedRestart)
|
||||
do_check_true(hasFlag(addon.pendingOperations, AddonManager.PENDING_INSTALL));
|
||||
},
|
||||
|
||||
onInstalled: function(addon) {
|
||||
let [event, expectedRestart] = getExpectedEvent(addon.id);
|
||||
do_check_eq("onInstalled", event);
|
||||
},
|
||||
|
||||
onUninstalling: function(addon, requiresRestart) {
|
||||
let [event, expectedRestart] = getExpectedEvent(addon.id);
|
||||
do_check_eq("onUninstalling", event);
|
||||
do_check_eq(requiresRestart, expectedRestart);
|
||||
if (expectedRestart)
|
||||
do_check_true(hasFlag(addon.pendingOperations, AddonManager.PENDING_UNINSTALL));
|
||||
//do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
},
|
||||
|
||||
onUninstalled: function(addon) {
|
||||
let [event, expectedRestart] = getExpectedEvent(addon.id);
|
||||
do_check_eq("onUninstalled", event);
|
||||
do_check_eq(requiresRestart, expectedRestart);
|
||||
do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
},
|
||||
|
||||
onOperationCancelled: function(addon) {
|
||||
let [event, expectedRestart] = getExpectedEvent(addon.id);
|
||||
do_check_eq("onOperationCancelled", event);
|
||||
do_check_eq(requiresRestart, expectedRestart);
|
||||
do_check_eq(addon.pendingOperations, 0);
|
||||
}
|
||||
};
|
||||
|
||||
const InstallListener = {
|
||||
onNewInstall: function(install) {
|
||||
if (install.state != AddonManager.STATE_DOWNLOADED &&
|
||||
install.state != AddonManager.STATE_AVAILABLE)
|
||||
do_throw("Bad install state " + install.state);
|
||||
do_check_eq("onNewInstall", gExpectedInstalls.shift());
|
||||
},
|
||||
|
||||
onDownloadStarted: function(install) {
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOADING);
|
||||
do_check_eq("onDownloadStarted", gExpectedInstalls.shift());
|
||||
},
|
||||
|
||||
onDownloadEnded: function(install) {
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
do_check_eq("onDownloadEnded", gExpectedInstalls.shift());
|
||||
// gNext should determine whether installation continues
|
||||
return gNext(install);
|
||||
},
|
||||
|
||||
onDownloadFailed: function(install, status) {
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
|
||||
do_check_eq("onDownloadFailed", gExpectedInstalls.shift());
|
||||
gNext(install);
|
||||
},
|
||||
|
||||
onInstallStarted: function(install) {
|
||||
do_check_eq(install.state, AddonManager.STATE_INSTALLING);
|
||||
do_check_eq("onInstallStarted", gExpectedInstalls.shift());
|
||||
},
|
||||
|
||||
onInstallEnded: function(install, newAddon) {
|
||||
do_check_eq(install.state, AddonManager.STATE_INSTALLED);
|
||||
do_check_eq("onInstallEnded", gExpectedInstalls.shift());
|
||||
gNext(install);
|
||||
},
|
||||
|
||||
onInstallFailed: function(install, status) {
|
||||
do_check_eq(install.state, AddonManager.STATE_INSTALL_FAILED);
|
||||
do_check_eq("onInstallFailed", gExpectedInstalls.shift());
|
||||
gNext(install);
|
||||
}
|
||||
};
|
||||
|
||||
function hasFlag(bits, flag) {
|
||||
return (bits & flag) != 0;
|
||||
}
|
||||
|
||||
// Just a wrapper around setting the expected events
|
||||
function prepare_test(expectedEvents, expectedInstalls, next) {
|
||||
AddonManager.addAddonListener(AddonListener);
|
||||
AddonManager.addInstallListener(InstallListener);
|
||||
|
||||
gExpectedInstalls = expectedInstalls;
|
||||
gExpectedEvents = expectedEvents;
|
||||
gNext = next;
|
||||
}
|
||||
|
||||
// Verifies that all the expected events for all add-ons were seen
|
||||
function ensure_test_completed() {
|
||||
for (let i in gExpectedEvents) {
|
||||
if (gExpectedEvents[i].length > 0)
|
||||
do_throw("Didn't see all the expected events for " + i);
|
||||
}
|
||||
gExpectedEvents = {};
|
||||
if (gExpectedInstalls)
|
||||
do_check_eq(gExpectedInstalls.length, 0);
|
||||
}
|
||||
// Get the profile directory for tests to use.
|
||||
const gProfD = do_get_profile().QueryInterface(AM_Ci.nsILocalFile);
|
||||
|
||||
// Enable more extensive EM logging
|
||||
Services.prefs.setBoolPref("extensions.logging.enabled", true);
|
||||
|
||||
do_register_cleanup(shutdownManager);
|
|
@ -0,0 +1,304 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies that bootstrappable add-ons can be used with restarts.
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
Services.prefs.setIntPref("bootstraptest.version", 0);
|
||||
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
function getActivatedVersion() {
|
||||
return Services.prefs.getIntPref("bootstraptest.version");
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
startupManager(1);
|
||||
|
||||
run_test_1();
|
||||
}
|
||||
|
||||
// Tests that installing doesn't require a restart
|
||||
function run_test_1() {
|
||||
prepare_test({ }, [
|
||||
"onNewInstall"
|
||||
]);
|
||||
|
||||
AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_1"), function(install) {
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_neq(install, null);
|
||||
do_check_eq(install.type, "bootstrapped");
|
||||
do_check_eq(install.version, "1.0");
|
||||
do_check_eq(install.name, "Test Bootstrap 1");
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
do_check_true(install.addon.hasResource("install.rdf"));
|
||||
do_check_true(install.addon.hasResource("bootstrap.js"));
|
||||
do_check_false(install.addon.hasResource("foo.bar"));
|
||||
|
||||
prepare_test({
|
||||
"bootstrap1@tests.mozilla.org": [
|
||||
["onInstalling", false],
|
||||
"onInstalled"
|
||||
]
|
||||
}, [
|
||||
"onInstallStarted",
|
||||
"onInstallEnded",
|
||||
], check_test_1);
|
||||
install.install();
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_1() {
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(b1) {
|
||||
do_check_neq(b1, null);
|
||||
do_check_eq(b1.version, "1.0");
|
||||
do_check_false(b1.appDisabled);
|
||||
do_check_false(b1.userDisabled);
|
||||
do_check_true(b1.isActive);
|
||||
do_check_eq(getActivatedVersion(), 1);
|
||||
do_check_true(b1.hasResource("install.rdf"));
|
||||
do_check_true(b1.hasResource("bootstrap.js"));
|
||||
do_check_false(b1.hasResource("foo.bar"));
|
||||
|
||||
let dir = profileDir.clone();
|
||||
dir.append("bootstrap1@tests.mozilla.org");
|
||||
dir.append("bootstrap.js");
|
||||
let uri = Services.io.newFileURI(dir).spec;
|
||||
do_check_eq(b1.getResourceURL("bootstrap.js"), uri);
|
||||
|
||||
AddonManager.getAddonsWithPendingOperations(null, function(list) {
|
||||
do_check_eq(list.length, 0);
|
||||
|
||||
run_test_2();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Tests that disabling doesn't require a restart
|
||||
function run_test_2() {
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(b1) {
|
||||
prepare_test({
|
||||
"bootstrap1@tests.mozilla.org": [
|
||||
["onDisabling", false],
|
||||
"onDisabled"
|
||||
]
|
||||
});
|
||||
|
||||
b1.userDisabled = true;
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_neq(b1, null);
|
||||
do_check_eq(b1.version, "1.0");
|
||||
do_check_false(b1.appDisabled);
|
||||
do_check_true(b1.userDisabled);
|
||||
do_check_false(b1.isActive);
|
||||
do_check_eq(getActivatedVersion(), 0);
|
||||
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(newb1) {
|
||||
do_check_neq(newb1, null);
|
||||
do_check_eq(newb1.version, "1.0");
|
||||
do_check_false(newb1.appDisabled);
|
||||
do_check_true(newb1.userDisabled);
|
||||
do_check_false(newb1.isActive);
|
||||
|
||||
run_test_3();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Test that restarting doesn't accidentally re-enable
|
||||
function run_test_3() {
|
||||
shutdownManager();
|
||||
do_check_eq(getActivatedVersion(), 0);
|
||||
startupManager(0, false);
|
||||
do_check_eq(getActivatedVersion(), 0);
|
||||
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(b1) {
|
||||
do_check_neq(b1, null);
|
||||
do_check_eq(b1.version, "1.0");
|
||||
do_check_false(b1.appDisabled);
|
||||
do_check_true(b1.userDisabled);
|
||||
do_check_false(b1.isActive);
|
||||
|
||||
run_test_4();
|
||||
});
|
||||
}
|
||||
|
||||
// Tests that enabling doesn't require a restart
|
||||
function run_test_4() {
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(b1) {
|
||||
prepare_test({
|
||||
"bootstrap1@tests.mozilla.org": [
|
||||
["onEnabling", false],
|
||||
"onEnabled"
|
||||
]
|
||||
});
|
||||
|
||||
b1.userDisabled = false;
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_neq(b1, null);
|
||||
do_check_eq(b1.version, "1.0");
|
||||
do_check_false(b1.appDisabled);
|
||||
do_check_false(b1.userDisabled);
|
||||
do_check_true(b1.isActive);
|
||||
do_check_eq(getActivatedVersion(), 1);
|
||||
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(newb1) {
|
||||
do_check_neq(newb1, null);
|
||||
do_check_eq(newb1.version, "1.0");
|
||||
do_check_false(newb1.appDisabled);
|
||||
do_check_false(newb1.userDisabled);
|
||||
do_check_true(newb1.isActive);
|
||||
|
||||
run_test_5();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Tests that a restart shuts down and restarts the add-on
|
||||
function run_test_5() {
|
||||
shutdownManager();
|
||||
do_check_eq(getActivatedVersion(), 0);
|
||||
startupManager(0, false);
|
||||
do_check_eq(getActivatedVersion(), 1);
|
||||
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(b1) {
|
||||
do_check_neq(b1, null);
|
||||
do_check_eq(b1.version, "1.0");
|
||||
do_check_false(b1.appDisabled);
|
||||
do_check_false(b1.userDisabled);
|
||||
do_check_true(b1.isActive);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, b1.id));
|
||||
|
||||
run_test_6();
|
||||
});
|
||||
}
|
||||
|
||||
// Tests that installing an upgrade doesn't require a restart
|
||||
function run_test_6() {
|
||||
prepare_test({ }, [
|
||||
"onNewInstall"
|
||||
]);
|
||||
|
||||
AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_2"), function(install) {
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_neq(install, null);
|
||||
do_check_eq(install.type, "bootstrapped");
|
||||
do_check_eq(install.version, "2.0");
|
||||
do_check_eq(install.name, "Test Bootstrap 1");
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
|
||||
prepare_test({
|
||||
"bootstrap1@tests.mozilla.org": [
|
||||
["onInstalling", false],
|
||||
"onInstalled"
|
||||
]
|
||||
}, [
|
||||
"onInstallStarted",
|
||||
"onInstallEnded",
|
||||
], check_test_6);
|
||||
install.install();
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_6() {
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(b1) {
|
||||
do_check_neq(b1, null);
|
||||
do_check_eq(b1.version, "2.0");
|
||||
do_check_false(b1.appDisabled);
|
||||
do_check_false(b1.userDisabled);
|
||||
do_check_true(b1.isActive);
|
||||
do_check_eq(getActivatedVersion(), 2);
|
||||
|
||||
run_test_7();
|
||||
});
|
||||
}
|
||||
|
||||
// Tests that uninstalling doesn't require a restart
|
||||
function run_test_7() {
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(b1) {
|
||||
prepare_test({
|
||||
"bootstrap1@tests.mozilla.org": [
|
||||
["onUninstalling", false],
|
||||
"onUninstalled"
|
||||
]
|
||||
});
|
||||
|
||||
b1.uninstall();
|
||||
|
||||
check_test_7();
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_7() {
|
||||
ensure_test_completed();
|
||||
do_check_eq(getActivatedVersion(), 0);
|
||||
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(b1) {
|
||||
do_check_eq(b1, null);
|
||||
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(newb1) {
|
||||
do_check_eq(newb1, null);
|
||||
|
||||
run_test_8();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Test that a bootstrapped extension dropped into the profile loads properly
|
||||
// on startup and doesn't cause an EM restart
|
||||
function run_test_8() {
|
||||
shutdownManager();
|
||||
|
||||
let dir = profileDir.clone();
|
||||
dir.append("bootstrap1@tests.mozilla.org");
|
||||
dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
let zip = AM_Cc["@mozilla.org/libjar/zip-reader;1"].
|
||||
createInstance(AM_Ci.nsIZipReader);
|
||||
zip.open(do_get_addon("test_bootstrap1_1"));
|
||||
dir.append("install.rdf");
|
||||
zip.extract("install.rdf", dir);
|
||||
dir = dir.parent;
|
||||
dir.append("bootstrap.js");
|
||||
zip.extract("bootstrap.js", dir);
|
||||
zip.close();
|
||||
|
||||
startupManager(0, false);
|
||||
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(b1) {
|
||||
do_check_neq(b1, null);
|
||||
do_check_eq(b1.version, "1.0");
|
||||
do_check_false(b1.appDisabled);
|
||||
do_check_false(b1.userDisabled);
|
||||
do_check_true(b1.isActive);
|
||||
do_check_eq(getActivatedVersion(), 1);
|
||||
|
||||
run_test_9();
|
||||
});
|
||||
}
|
||||
|
||||
// Test that items detected as removed during startup don't force an EM restart
|
||||
function run_test_9() {
|
||||
shutdownManager();
|
||||
|
||||
let dir = profileDir.clone();
|
||||
dir.append("bootstrap1@tests.mozilla.org");
|
||||
dir.remove(true);
|
||||
startupManager(0, false);
|
||||
|
||||
AddonManager.getAddon("bootstrap1@tests.mozilla.org", function(b1) {
|
||||
do_check_eq(b1, null);
|
||||
|
||||
do_test_finished();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies that the extensions.checkCompatibility.* preferences work.
|
||||
|
||||
var ADDONS = [{
|
||||
// Cannot be enabled as it has no target app info for the applciation
|
||||
id: "addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 1",
|
||||
targetApplications: [{
|
||||
id: "unknown@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
}, {
|
||||
// Always appears incompatible but can be enabled if compatibility checking is
|
||||
// disabled
|
||||
id: "addon2@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 2",
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
}, {
|
||||
// Always appears incompatible but can be enabled if compatibility checking is
|
||||
// disabled
|
||||
id: "addon3@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 3",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
}, { // Always compatible and enabled
|
||||
id: "addon4@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 4",
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "2"
|
||||
}]
|
||||
}, { // Always compatible and enabled
|
||||
id: "addon5@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 5",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "3"
|
||||
}]
|
||||
}];
|
||||
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.2.3", "2");
|
||||
|
||||
ADDONS.forEach(function(a) {
|
||||
let dest = profileDir.clone();
|
||||
dest.append(a.id);
|
||||
writeInstallRDFToDir(a, dest);
|
||||
});
|
||||
|
||||
startupManager(1);
|
||||
|
||||
run_test_1();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the add-ons are enabled as expected.
|
||||
* @param overridden
|
||||
* A boolean indicating that compatibility checking is overridden
|
||||
* @param a1
|
||||
* The Addon for addon1@tests.mozilla.org
|
||||
* @param a2
|
||||
* The Addon for addon2@tests.mozilla.org
|
||||
* @param a3
|
||||
* The Addon for addon3@tests.mozilla.org
|
||||
* @param a4
|
||||
* The Addon for addon4@tests.mozilla.org
|
||||
* @param a5
|
||||
* The Addon for addon5@tests.mozilla.org
|
||||
*/
|
||||
function check_state(overridden, a1, a2, a3, a4, a5) {
|
||||
do_check_neq(a1, null);
|
||||
do_check_false(a1.isActive);
|
||||
do_check_false(a1.isCompatible);
|
||||
|
||||
do_check_neq(a2, null);
|
||||
if (overridden)
|
||||
do_check_true(a2.isActive);
|
||||
else
|
||||
do_check_false(a2.isActive);
|
||||
do_check_false(a2.isCompatible);
|
||||
|
||||
do_check_neq(a3, null);
|
||||
if (overridden)
|
||||
do_check_true(a3.isActive);
|
||||
else
|
||||
do_check_false(a3.isActive);
|
||||
do_check_false(a3.isCompatible);
|
||||
|
||||
do_check_neq(a4, null);
|
||||
do_check_true(a4.isActive);
|
||||
do_check_true(a4.isCompatible);
|
||||
|
||||
do_check_neq(a5, null);
|
||||
do_check_true(a5.isActive);
|
||||
do_check_true(a5.isCompatible);
|
||||
}
|
||||
|
||||
// Tests that with compatibility checking enabled we see the incompatible
|
||||
// add-ons disabled
|
||||
function run_test_1() {
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
check_state(false, a1, a2, a3, a4, a5);
|
||||
|
||||
run_test_2();
|
||||
});
|
||||
}
|
||||
|
||||
// Tests that with compatibility checking disabled we see the incompatible
|
||||
// add-ons enabled
|
||||
function run_test_2() {
|
||||
Services.prefs.setBoolPref("extensions.checkCompatibility.2.2", false);
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
check_state(true, a1, a2, a3, a4, a5);
|
||||
|
||||
run_test_3();
|
||||
});
|
||||
}
|
||||
|
||||
// Tests that with compatibility checking disabled we see the incompatible
|
||||
// add-ons enabled.
|
||||
function run_test_3() {
|
||||
Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", false);
|
||||
restartManager(1, "2.1a4");
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
check_state(true, a1, a2, a3, a4, a5);
|
||||
|
||||
run_test_4();
|
||||
});
|
||||
}
|
||||
|
||||
// Tests that with compatibility checking enabled we see the incompatible
|
||||
// add-ons disabled.
|
||||
function run_test_4() {
|
||||
Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", true);
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
check_state(false, a1, a2, a3, a4, a5);
|
||||
|
||||
do_test_finished();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,158 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies that add-ons can be disabled and enabled.
|
||||
|
||||
var addon1 = {
|
||||
id: "addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 1",
|
||||
iconURL: "chrome://foo/content/icon.png",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
// Sets up the profile by installing an add-on.
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
startupManager(1);
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_eq(a1, null);
|
||||
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon1, dest);
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(newa1) {
|
||||
do_check_neq(newa1, null);
|
||||
do_check_true(newa1.isActive);
|
||||
do_check_false(newa1.userDisabled);
|
||||
do_check_eq(newa1.iconURL, "chrome://foo/content/icon.png");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, newa1.id));
|
||||
do_check_true(hasFlag(newa1.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_false(hasFlag(newa1.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
run_test_1();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Disabling an add-on should work
|
||||
function run_test_1() {
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onDisabling"
|
||||
]
|
||||
});
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
a1.userDisabled = true;
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
AddonManager.getAddonsWithPendingOperations(null, function(list) {
|
||||
do_check_eq(list.length, 1);
|
||||
do_check_eq(list[0].id, "addon1@tests.mozilla.org");
|
||||
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(newa1) {
|
||||
do_check_neq(newa1, null);
|
||||
do_check_false(newa1.isActive);
|
||||
do_check_true(newa1.userDisabled);
|
||||
do_check_eq(newa1.iconURL, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, newa1.id));
|
||||
do_check_false(hasFlag(newa1.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_true(hasFlag(newa1.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
run_test_2();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Enabling an add-on should work.
|
||||
function run_test_2() {
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onEnabling"
|
||||
]
|
||||
});
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
a1.userDisabled = false;
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
AddonManager.getAddonsWithPendingOperations(null, function(list) {
|
||||
do_check_eq(list.length, 1);
|
||||
do_check_eq(list[0].id, "addon1@tests.mozilla.org");
|
||||
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(newa1) {
|
||||
do_check_neq(newa1, null);
|
||||
do_check_true(newa1.isActive);
|
||||
do_check_false(newa1.userDisabled);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, newa1.id));
|
||||
do_check_true(hasFlag(newa1.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_false(hasFlag(newa1.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
run_test_3();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Disabling then enabling withut restart should fire onOperationCancelled.
|
||||
function run_test_3() {
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onDisabling"
|
||||
]
|
||||
});
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
a1.userDisabled = true;
|
||||
ensure_test_completed();
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onOperationCancelled"
|
||||
]
|
||||
});
|
||||
a1.userDisabled = false;
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(newa1) {
|
||||
do_check_neq(newa1, null);
|
||||
do_check_true(newa1.isActive);
|
||||
do_check_false(newa1.userDisabled);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, newa1.id));
|
||||
do_check_true(hasFlag(newa1.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_false(hasFlag(newa1.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
do_test_finished();
|
||||
});
|
||||
});
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This just verifies that the EM can actually startup and shutdown a few times
|
||||
// without any errors
|
||||
|
||||
// We have to look up how many add-ons are present in case apps like SeaMonkey
|
||||
// try to use this test with their built-in add-ons.
|
||||
var gCount;
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
var count = 0;
|
||||
startupManager(1);
|
||||
AddonManager.getAddonsByTypes(null, function(list) {
|
||||
gCount = list.length;
|
||||
|
||||
run_test_1();
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_1() {
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddonsByTypes(null, function(addons) {
|
||||
do_check_eq(gCount, addons.length);
|
||||
|
||||
AddonManager.getAddonsWithPendingOperations(null, function(pendingAddons) {
|
||||
do_check_eq(0, pendingAddons.length);
|
||||
|
||||
run_test_2();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_2() {
|
||||
shutdownManager();
|
||||
|
||||
startupManager(0, false);
|
||||
|
||||
AddonManager.getAddonsByTypes(null, function(addons) {
|
||||
do_check_eq(gCount, addons.length);
|
||||
|
||||
run_test_3();
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_3() {
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddonsByTypes(null, function(addons) {
|
||||
do_check_eq(gCount, addons.length);
|
||||
shutdownManager();
|
||||
do_test_finished();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,379 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies that add-ons can be installed from XPI files
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
do_load_httpd_js();
|
||||
var testserver;
|
||||
var gInstallDate;
|
||||
|
||||
// The test extension uses an insecure update url.
|
||||
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
|
||||
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
function run_test() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
startupManager(1);
|
||||
// Make sure we only register once despite multiple calls
|
||||
AddonManager.addInstallListener(InstallListener);
|
||||
AddonManager.addAddonListener(AddonListener);
|
||||
AddonManager.addInstallListener(InstallListener);
|
||||
AddonManager.addAddonListener(AddonListener);
|
||||
|
||||
// Create and configure the HTTP server.
|
||||
testserver = new nsHttpServer();
|
||||
testserver.registerDirectory("/addons/", do_get_file("addons"));
|
||||
testserver.registerDirectory("/data/", do_get_file("data"));
|
||||
testserver.start(4444);
|
||||
|
||||
do_test_pending();
|
||||
run_test_1();
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
testserver.stop(do_test_finished);
|
||||
}
|
||||
|
||||
// Checks that an install from a local file proceeds as expected
|
||||
function run_test_1() {
|
||||
prepare_test({ }, [
|
||||
"onNewInstall"
|
||||
]);
|
||||
|
||||
AddonManager.getInstallForFile(do_get_addon("test_install1"), function(install) {
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_neq(install, null);
|
||||
do_check_eq(install.type, "extension");
|
||||
do_check_eq(install.version, "1.0");
|
||||
do_check_eq(install.name, "Test 1");
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
do_check_true(install.addon.hasResource("install.rdf"));
|
||||
|
||||
let file = do_get_addon("test_install1");
|
||||
let uri = Services.io.newFileURI(file).spec;
|
||||
do_check_eq(install.addon.getResourceURL("install.rdf"), "jar:" + uri + "!/install.rdf");
|
||||
|
||||
AddonManager.getInstalls(null, function(activeInstalls) {
|
||||
do_check_eq(activeInstalls.length, 1);
|
||||
do_check_eq(activeInstalls[0], install);
|
||||
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onInstalling"
|
||||
]
|
||||
}, [
|
||||
"onInstallStarted",
|
||||
"onInstallEnded",
|
||||
], check_test_1);
|
||||
install.install();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_1() {
|
||||
ensure_test_completed();
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(olda1) {
|
||||
do_check_eq(olda1, null);
|
||||
|
||||
AddonManager.getAddonsWithPendingOperations(null, function(pendingAddons) {
|
||||
do_check_eq(pendingAddons.length, 1);
|
||||
do_check_eq(pendingAddons[0].id, "addon1@tests.mozilla.org");
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getInstalls(null, function(activeInstalls) {
|
||||
do_check_eq(activeInstalls, 0);
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.type, "extension");
|
||||
do_check_eq(a1.version, "1.0");
|
||||
do_check_eq(a1.name, "Test 1");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
|
||||
do_check_true(do_get_addon("test_install1").exists());
|
||||
|
||||
// Should have been installed sometime in the last two second.
|
||||
let difference = Date.now() - a1.installDate.getTime();
|
||||
if (difference > 2000)
|
||||
do_throw("Add-on was installed " + difference + "ms ago");
|
||||
if (difference < 0)
|
||||
do_throw("Add-on was installed " + difference + "ms in the future");
|
||||
|
||||
do_check_eq(a1.installDate.getTime(), a1.updateDate.getTime());
|
||||
|
||||
do_check_true(a1.hasResource("install.rdf"));
|
||||
do_check_false(a1.hasResource("foo.bar"));
|
||||
|
||||
let dir = profileDir.clone();
|
||||
dir.append("addon1@tests.mozilla.org");
|
||||
dir.append("install.rdf");
|
||||
let uri = Services.io.newFileURI(dir).spec;
|
||||
do_check_eq(a1.getResourceURL("install.rdf"), uri);
|
||||
|
||||
a1.uninstall();
|
||||
restartManager(0);
|
||||
|
||||
run_test_2();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Tests that an install from a url downloads.
|
||||
function run_test_2() {
|
||||
let url = "http://localhost:4444/addons/test_install2_1.xpi";
|
||||
AddonManager.getInstallForURL(url, function(install) {
|
||||
do_check_neq(install, null);
|
||||
do_check_eq(install.version, "1.0");
|
||||
do_check_eq(install.name, "Test 2");
|
||||
do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
|
||||
|
||||
AddonManager.getInstalls(null, function(activeInstalls) {
|
||||
do_check_eq(activeInstalls.length, 1);
|
||||
do_check_eq(activeInstalls[0], install);
|
||||
|
||||
prepare_test({}, [
|
||||
"onDownloadStarted",
|
||||
"onDownloadEnded",
|
||||
], check_test_2);
|
||||
|
||||
install.addListener({
|
||||
onDownloadProgress: function(install) {
|
||||
do_execute_soon(function() {
|
||||
Components.utils.forceGC();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
install.install();
|
||||
});
|
||||
}, "application/x-xpinstall", null, "Test 2", null, "1.0");
|
||||
}
|
||||
|
||||
function check_test_2(install) {
|
||||
ensure_test_completed();
|
||||
do_check_eq(install.version, "2.0");
|
||||
do_check_eq(install.name, "Real Test 2");
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
|
||||
// Pause the install here and start it again in run_test_3
|
||||
do_execute_soon(function() { run_test_3(install); });
|
||||
return false;
|
||||
}
|
||||
|
||||
// Tests that the downloaded XPI installs ok
|
||||
function run_test_3(install) {
|
||||
prepare_test({
|
||||
"addon2@tests.mozilla.org": [
|
||||
"onInstalling"
|
||||
]
|
||||
}, [
|
||||
"onInstallStarted",
|
||||
"onInstallEnded",
|
||||
], check_test_3);
|
||||
install.install();
|
||||
}
|
||||
|
||||
function check_test_3() {
|
||||
ensure_test_completed();
|
||||
AddonManager.getAddon("addon2@tests.mozilla.org", function(olda2) {
|
||||
do_check_eq(olda2, null);
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getInstalls(null, function(installs) {
|
||||
do_check_eq(installs, 0);
|
||||
|
||||
AddonManager.getAddon("addon2@tests.mozilla.org", function(a2) {
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.type, "extension");
|
||||
do_check_eq(a2.version, "2.0");
|
||||
do_check_eq(a2.name, "Real Test 2");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_true(do_get_addon("test_install2_1").exists());
|
||||
|
||||
// Should have been installed sometime in the last two second.
|
||||
let difference = Date.now() - a2.installDate.getTime();
|
||||
if (difference > 2000)
|
||||
do_throw("Add-on was installed " + difference + "ms ago");
|
||||
if (difference < 0)
|
||||
do_throw("Add-on was installed " + difference + "ms in the future");
|
||||
|
||||
do_check_eq(a2.installDate.getTime(), a2.updateDate.getTime());
|
||||
gInstallDate = a2.installDate.getTime();
|
||||
|
||||
run_test_4();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Tests that installing a new version of an existing add-on works
|
||||
function run_test_4() {
|
||||
prepare_test({ }, [
|
||||
"onNewInstall"
|
||||
]);
|
||||
|
||||
let url = "http://localhost:4444/addons/test_install2_2.xpi";
|
||||
AddonManager.getInstallForURL(url, function(install) {
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_neq(install, null);
|
||||
do_check_eq(install.version, "3.0");
|
||||
do_check_eq(install.name, "Test 3");
|
||||
do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
|
||||
|
||||
AddonManager.getInstalls(null, function(activeInstalls) {
|
||||
do_check_eq(activeInstalls.length, 1);
|
||||
do_check_eq(activeInstalls[0], install);
|
||||
do_check_eq(install.existingAddon, null);
|
||||
|
||||
prepare_test({}, [
|
||||
"onDownloadStarted",
|
||||
"onDownloadEnded",
|
||||
], check_test_4);
|
||||
install.install();
|
||||
});
|
||||
}, "application/x-xpinstall", null, "Test 3", null, "3.0");
|
||||
}
|
||||
|
||||
function check_test_4(install) {
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_eq(install.version, "3.0");
|
||||
do_check_eq(install.name, "Real Test 3");
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
do_check_neq(install.existingAddon);
|
||||
do_check_eq(install.existingAddon.id, "addon2@tests.mozilla.org");
|
||||
|
||||
run_test_5();
|
||||
// Installation will continue when there is nothing returned.
|
||||
}
|
||||
|
||||
// Continue installing the new version
|
||||
function run_test_5() {
|
||||
prepare_test({
|
||||
"addon2@tests.mozilla.org": [
|
||||
"onInstalling"
|
||||
]
|
||||
}, [
|
||||
"onInstallStarted",
|
||||
"onInstallEnded",
|
||||
], check_test_5);
|
||||
}
|
||||
|
||||
function check_test_5() {
|
||||
ensure_test_completed();
|
||||
AddonManager.getAddon("addon2@tests.mozilla.org", function(olda2) {
|
||||
do_check_neq(olda2, null);
|
||||
restartManager();
|
||||
|
||||
AddonManager.getInstalls(null, function(installs) {
|
||||
do_check_eq(installs, 0);
|
||||
|
||||
AddonManager.getAddon("addon2@tests.mozilla.org", function(a2) {
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.type, "extension");
|
||||
do_check_eq(a2.version, "3.0");
|
||||
do_check_eq(a2.name, "Real Test 3");
|
||||
do_check_true(a2.isActive);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_true(do_get_addon("test_install2_2").exists());
|
||||
|
||||
do_check_eq(a2.installDate.getTime(), gInstallDate);
|
||||
// Update date should be later (or the same if this test is too fast)
|
||||
do_check_true(a2.installDate <= a2.updateDate);
|
||||
|
||||
a2.uninstall();
|
||||
restartManager(0);
|
||||
|
||||
run_test_6();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Tests that an install that requires a compatibility update works
|
||||
function run_test_6() {
|
||||
prepare_test({ }, [
|
||||
"onNewInstall"
|
||||
]);
|
||||
|
||||
let url = "http://localhost:4444/addons/test_install3.xpi";
|
||||
AddonManager.getInstallForURL(url, function(install) {
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_neq(install, null);
|
||||
do_check_eq(install.version, "1.0");
|
||||
do_check_eq(install.name, "Real Test 4");
|
||||
do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
|
||||
|
||||
AddonManager.getInstalls(null, function(activeInstalls) {
|
||||
do_check_eq(activeInstalls.length, 1);
|
||||
do_check_eq(activeInstalls[0], install);
|
||||
|
||||
prepare_test({}, [
|
||||
"onDownloadStarted",
|
||||
"onDownloadEnded",
|
||||
], check_test_6);
|
||||
install.install();
|
||||
});
|
||||
}, "application/x-xpinstall", null, "Real Test 4", null, "1.0");
|
||||
}
|
||||
|
||||
function check_test_6(install) {
|
||||
ensure_test_completed();
|
||||
do_check_eq(install.version, "1.0");
|
||||
do_check_eq(install.name, "Real Test 4");
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
do_check_eq(install.existingAddon, null);
|
||||
do_check_false(install.addon.appDisabled);
|
||||
run_test_7();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Continue the install
|
||||
function run_test_7() {
|
||||
prepare_test({
|
||||
"addon3@tests.mozilla.org": [
|
||||
"onInstalling"
|
||||
]
|
||||
}, [
|
||||
"onInstallStarted",
|
||||
"onInstallEnded",
|
||||
], check_test_7);
|
||||
}
|
||||
|
||||
function check_test_7() {
|
||||
ensure_test_completed();
|
||||
AddonManager.getAddon("addon3@tests.mozilla.org", function(olda3) {
|
||||
do_check_eq(olda3, null);
|
||||
restartManager();
|
||||
|
||||
AddonManager.getInstalls(null, function(installs) {
|
||||
do_check_eq(installs, 0);
|
||||
|
||||
AddonManager.getAddon("addon3@tests.mozilla.org", function(a3) {
|
||||
do_check_neq(a3, null);
|
||||
do_check_eq(a3.type, "extension");
|
||||
do_check_eq(a3.version, "1.0");
|
||||
do_check_eq(a3.name, "Real Test 4");
|
||||
do_check_true(a3.isActive);
|
||||
do_check_false(a3.appDisabled);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
|
||||
do_check_true(do_get_addon("test_install3").exists());
|
||||
a3.uninstall();
|
||||
restartManager(0);
|
||||
|
||||
end_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
|
@ -0,0 +1,397 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This tests that all properties are read from the install manifests and that
|
||||
// items are correctly enabled/disabled based on them (blocklist tests are
|
||||
// elsewhere)
|
||||
|
||||
function run_test() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
optionsURL: "chrome://test/content/options.xul",
|
||||
aboutURL: "chrome://test/content/about.xul",
|
||||
iconURL: "chrome://test/skin/icon.png",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 1",
|
||||
description: "Test Description",
|
||||
creator: "Test Creator",
|
||||
homepageURL: "http://www.example.com",
|
||||
developer: [
|
||||
"Test Developer 1",
|
||||
"Test Developer 2"
|
||||
],
|
||||
translator: [
|
||||
"Test Translator 1",
|
||||
"Test Translator 2"
|
||||
],
|
||||
contributor: [
|
||||
"Test Contributor 1",
|
||||
"Test Contributor 2"
|
||||
]
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon2@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
updateURL: "https://www.foo.com",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 2"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon3@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon3@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
updateURL: "http://www.foo.com",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 3"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon4@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon4@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
updateURL: "http://www.foo.com",
|
||||
updateKey: "foo",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 4"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon5@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon5@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "*"
|
||||
}],
|
||||
name: "Test Addon 5"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon6@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon6@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "0",
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 6"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon7@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon7@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "0",
|
||||
maxVersion: "0"
|
||||
}],
|
||||
name: "Test Addon 7"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon8@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon8@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1.1",
|
||||
maxVersion: "*"
|
||||
}],
|
||||
name: "Test Addon 8"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon9@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon9@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9.2",
|
||||
maxVersion: "1.9.*"
|
||||
}],
|
||||
name: "Test Addon 9"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon10@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon10@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9.2.1",
|
||||
maxVersion: "1.9.*"
|
||||
}],
|
||||
name: "Test Addon 10"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon11@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon11@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9",
|
||||
maxVersion: "1.9.2"
|
||||
}],
|
||||
name: "Test Addon 11"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon12@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon12@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9",
|
||||
maxVersion: "1.9.1.*"
|
||||
}],
|
||||
name: "Test Addon 12"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon13@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon13@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9",
|
||||
maxVersion: "1.9.*"
|
||||
}, {
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "0",
|
||||
maxVersion: "0.5"
|
||||
}],
|
||||
name: "Test Addon 13"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon14@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon14@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9",
|
||||
maxVersion: "1.9.1"
|
||||
}, {
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 14"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon15@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon15@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
updateKey: "foo",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 15"
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon16@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon16@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
updateKey: "foo",
|
||||
updateURL: "https://www.foo.com",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 16"
|
||||
}, dest);
|
||||
|
||||
do_test_pending();
|
||||
startupManager(1);
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org",
|
||||
"addon6@tests.mozilla.org",
|
||||
"addon7@tests.mozilla.org",
|
||||
"addon8@tests.mozilla.org",
|
||||
"addon9@tests.mozilla.org",
|
||||
"addon10@tests.mozilla.org",
|
||||
"addon11@tests.mozilla.org",
|
||||
"addon12@tests.mozilla.org",
|
||||
"addon13@tests.mozilla.org",
|
||||
"addon14@tests.mozilla.org",
|
||||
"addon15@tests.mozilla.org",
|
||||
"addon16@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||
a11, a12, a13, a14, a15, a16]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.id, "addon1@tests.mozilla.org");
|
||||
do_check_eq(a1.type, "extension");
|
||||
do_check_eq(a1.version, "1.0");
|
||||
do_check_eq(a1.optionsURL, "chrome://test/content/options.xul");
|
||||
do_check_eq(a1.aboutURL, "chrome://test/content/about.xul");
|
||||
do_check_eq(a1.iconURL, "chrome://test/skin/icon.png");
|
||||
do_check_eq(a1.name, "Test Addon 1");
|
||||
do_check_eq(a1.description, "Test Description");
|
||||
do_check_eq(a1.creator, "Test Creator");
|
||||
do_check_eq(a1.homepageURL, "http://www.example.com");
|
||||
do_check_eq(a1.developers[0], "Test Developer 1");
|
||||
do_check_eq(a1.developers[1], "Test Developer 2");
|
||||
do_check_eq(a1.translators[0], "Test Translator 1");
|
||||
do_check_eq(a1.translators[1], "Test Translator 2");
|
||||
do_check_eq(a1.contributors[0], "Test Contributor 1");
|
||||
do_check_eq(a1.contributors[1], "Test Contributor 2");
|
||||
do_check_true(a1.isActive);
|
||||
do_check_false(a1.userDisabled);
|
||||
do_check_false(a1.appDisabled);
|
||||
do_check_true(a1.isCompatible);
|
||||
do_check_true(a1.providesUpdatesSecurely);
|
||||
do_check_eq(a1.blocklistState, AM_Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
do_check_true(a2.isActive);
|
||||
do_check_false(a2.userDisabled);
|
||||
do_check_false(a2.appDisabled);
|
||||
do_check_true(a2.providesUpdatesSecurely);
|
||||
|
||||
do_check_neq(a3, null);
|
||||
do_check_eq(a3.id, "addon3@tests.mozilla.org");
|
||||
do_check_false(a3.isActive);
|
||||
do_check_false(a3.userDisabled);
|
||||
do_check_true(a3.appDisabled);
|
||||
do_check_false(a3.providesUpdatesSecurely);
|
||||
|
||||
do_check_neq(a4, null);
|
||||
do_check_eq(a4.id, "addon4@tests.mozilla.org");
|
||||
do_check_true(a4.isActive);
|
||||
do_check_false(a4.userDisabled);
|
||||
do_check_false(a4.appDisabled);
|
||||
do_check_true(a4.providesUpdatesSecurely);
|
||||
|
||||
do_check_neq(a5, null);
|
||||
do_check_true(a5.isActive);
|
||||
do_check_false(a5.userDisabled);
|
||||
do_check_false(a5.appDisabled);
|
||||
do_check_true(a5.isCompatible);
|
||||
|
||||
do_check_neq(a6, null);
|
||||
do_check_true(a6.isActive);
|
||||
do_check_false(a6.userDisabled);
|
||||
do_check_false(a6.appDisabled);
|
||||
do_check_true(a6.isCompatible);
|
||||
|
||||
do_check_neq(a7, null);
|
||||
do_check_false(a7.isActive);
|
||||
do_check_false(a7.userDisabled);
|
||||
do_check_true(a7.appDisabled);
|
||||
do_check_false(a7.isCompatible);
|
||||
|
||||
do_check_neq(a8, null);
|
||||
do_check_false(a8.isActive);
|
||||
do_check_false(a8.userDisabled);
|
||||
do_check_true(a8.appDisabled);
|
||||
do_check_false(a8.isCompatible);
|
||||
|
||||
do_check_neq(a9, null);
|
||||
do_check_true(a9.isActive);
|
||||
do_check_false(a9.userDisabled);
|
||||
do_check_false(a9.appDisabled);
|
||||
do_check_true(a9.isCompatible);
|
||||
|
||||
do_check_neq(a10, null);
|
||||
do_check_false(a10.isActive);
|
||||
do_check_false(a10.userDisabled);
|
||||
do_check_true(a10.appDisabled);
|
||||
do_check_false(a10.isCompatible);
|
||||
|
||||
do_check_neq(a11, null);
|
||||
do_check_true(a11.isActive);
|
||||
do_check_false(a11.userDisabled);
|
||||
do_check_false(a11.appDisabled);
|
||||
do_check_true(a11.isCompatible);
|
||||
|
||||
do_check_neq(a12, null);
|
||||
do_check_false(a12.isActive);
|
||||
do_check_false(a12.userDisabled);
|
||||
do_check_true(a12.appDisabled);
|
||||
do_check_false(a12.isCompatible);
|
||||
|
||||
do_check_neq(a13, null);
|
||||
do_check_false(a13.isActive);
|
||||
do_check_false(a13.userDisabled);
|
||||
do_check_true(a13.appDisabled);
|
||||
do_check_false(a13.isCompatible);
|
||||
|
||||
do_check_neq(a14, null);
|
||||
do_check_true(a14.isActive);
|
||||
do_check_false(a14.userDisabled);
|
||||
do_check_false(a14.appDisabled);
|
||||
do_check_true(a14.isCompatible);
|
||||
|
||||
do_check_neq(a15, null);
|
||||
do_check_true(a15.isActive);
|
||||
do_check_false(a15.userDisabled);
|
||||
do_check_false(a15.appDisabled);
|
||||
do_check_true(a15.isCompatible);
|
||||
do_check_true(a15.providesUpdatesSecurely);
|
||||
|
||||
do_check_neq(a16, null);
|
||||
do_check_true(a16.isActive);
|
||||
do_check_false(a16.userDisabled);
|
||||
do_check_false(a16.appDisabled);
|
||||
do_check_true(a16.isCompatible);
|
||||
do_check_true(a16.providesUpdatesSecurely);
|
||||
|
||||
do_test_finished();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Checks that we migrate data from previous versions of the database
|
||||
|
||||
var addon1 = {
|
||||
id: "addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 1",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
var addon2 = {
|
||||
id: "addon2@tests.mozilla.org",
|
||||
version: "2.0",
|
||||
name: "Test 2",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
var addon3 = {
|
||||
id: "addon3@tests.mozilla.org",
|
||||
version: "2.0",
|
||||
name: "Test 3",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
var addon4 = {
|
||||
id: "addon4@tests.mozilla.org",
|
||||
version: "2.0",
|
||||
name: "Test 4",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon1, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon2, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon3@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon3, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon4@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon4, dest);
|
||||
|
||||
let old = do_get_file("data/test_migrate.rdf");
|
||||
old.copyTo(gProfD, "extensions.rdf");
|
||||
|
||||
startupManager(1);
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org"], function([a1, a2, a3, a4]) {
|
||||
// addon1 was enabled in the old extensions.rdf
|
||||
do_check_neq(a1, null);
|
||||
do_check_false(a1.userDisabled);
|
||||
// addon1 was disabled in the old extensions.rdf
|
||||
do_check_neq(a2, null);
|
||||
do_check_true(a2.userDisabled);
|
||||
// addon1 was pending-disable in the old extensions.rdf
|
||||
do_check_neq(a3, null);
|
||||
do_check_true(a3.userDisabled);
|
||||
// addon1 was pending-enable in the old extensions.rdf
|
||||
do_check_neq(a4, null);
|
||||
do_check_false(a4.userDisabled);
|
||||
do_test_finished();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Checks that we migrate data from future versions of the database
|
||||
|
||||
var addon1 = {
|
||||
id: "addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 1",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
var addon2 = {
|
||||
id: "addon2@tests.mozilla.org",
|
||||
version: "2.0",
|
||||
name: "Test 2",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
var addon3 = {
|
||||
id: "addon3@tests.mozilla.org",
|
||||
version: "2.0",
|
||||
name: "Test 3",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
var addon4 = {
|
||||
id: "addon4@tests.mozilla.org",
|
||||
version: "2.0",
|
||||
name: "Test 4",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon1, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon2, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon3@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon3, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon4@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon4, dest);
|
||||
|
||||
|
||||
// Write out a minimal database
|
||||
let dbfile = gProfD.clone();
|
||||
dbfile.append("extensions.sqlite");
|
||||
let db = AM_Cc["@mozilla.org/storage/service;1"].
|
||||
getService(AM_Ci.mozIStorageService).
|
||||
openDatabase(dbfile);
|
||||
db.createTable("addon", "id TEXT, location TEXT, active INTEGER, " +
|
||||
"userDisabled INTEGER, installDate INTEGER, " +
|
||||
"UNIQUE (id, location)");
|
||||
let stmt = db.createStatement("INSERT INTO addon VALUES (:id, :location, " +
|
||||
":active, :userDisabled, :installDate)");
|
||||
|
||||
[["addon1@tests.mozilla.org", "app-profile", "1", "0", "0"],
|
||||
["addon2@tests.mozilla.org", "app-profile", "0", "1", "0"],
|
||||
["addon3@tests.mozilla.org", "app-profile", "1", "1", "0"],
|
||||
["addon4@tests.mozilla.org", "app-profile", "0", "0", "0"]].forEach(function(a) {
|
||||
stmt.params.id = a[0];
|
||||
stmt.params.location = a[1];
|
||||
stmt.params.active = a[2];
|
||||
stmt.params.userDisabled = a[3];
|
||||
stmt.params.installDate = a[4];
|
||||
stmt.execute();
|
||||
});
|
||||
stmt.finalize();
|
||||
db.close();
|
||||
Services.prefs.setIntPref("extensions.databaseSchema", 100);
|
||||
|
||||
startupManager(1);
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org"], function([a1, a2, a3, a4]) {
|
||||
// addon1 was enabled in the database
|
||||
do_check_neq(a1, null);
|
||||
do_check_false(a1.userDisabled);
|
||||
// addon1 was disabled in the database
|
||||
do_check_neq(a2, null);
|
||||
do_check_true(a2.userDisabled);
|
||||
// addon1 was pending-disable in the database
|
||||
do_check_neq(a3, null);
|
||||
do_check_true(a3.userDisabled);
|
||||
// addon1 was pending-enable in the database
|
||||
do_check_neq(a4, null);
|
||||
do_check_false(a4.userDisabled);
|
||||
do_test_finished();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,501 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies startup detection of added/removed/changed items and install
|
||||
// location priorities
|
||||
|
||||
// We try to count the non-test extensions the add-on manager detects like the
|
||||
// built-in extensions in seamonkey.
|
||||
var additionalAddons, additionalExtensions;
|
||||
|
||||
var addon1 = {
|
||||
id: "addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 1",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
var addon2 = {
|
||||
id: "addon2@tests.mozilla.org",
|
||||
version: "2.0",
|
||||
name: "Test 2",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "2"
|
||||
}]
|
||||
};
|
||||
|
||||
var addon3 = {
|
||||
id: "addon3@tests.mozilla.org",
|
||||
version: "3.0",
|
||||
name: "Test 3",
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9.2",
|
||||
maxVersion: "1.9.2.*"
|
||||
}]
|
||||
};
|
||||
|
||||
// Should be ignored because it has no ID
|
||||
var addon4 = {
|
||||
version: "4.0",
|
||||
name: "Test 4",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
// Should be ignored because it has no version
|
||||
var addon5 = {
|
||||
id: "addon5@tests.mozilla.org",
|
||||
name: "Test 5",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
const globalDir = gProfD.clone();
|
||||
globalDir.append("extensions2");
|
||||
globalDir.append(gAppInfo.ID);
|
||||
registerDirectory("XRESysSExtPD", globalDir.parent);
|
||||
const userDir = gProfD.clone();
|
||||
userDir.append("extensions3");
|
||||
userDir.append(gAppInfo.ID);
|
||||
registerDirectory("XREUSysExt", userDir.parent);
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
// Set up the profile
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
startupManager(1);
|
||||
|
||||
AddonManager.getAddonsByTypes(null, function(allAddons) {
|
||||
additionalAddons = allAddons.length;
|
||||
AddonManager.getAddonsByTypes(["extension"], function(allExtensions) {
|
||||
additionalExtensions = allExtensions.length;
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_eq(a1, null);
|
||||
do_check_eq(a2, null);
|
||||
do_check_eq(a3, null);
|
||||
do_check_eq(a4, null);
|
||||
do_check_eq(a5, null);
|
||||
|
||||
run_test_1();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
do_test_finished();
|
||||
}
|
||||
|
||||
// Try to install all the items into the profile
|
||||
function run_test_1() {
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon1, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon2, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon3@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon3, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon4@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon4, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon5@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon5, dest);
|
||||
|
||||
restartManager(1);
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.id, "addon1@tests.mozilla.org");
|
||||
do_check_eq(a1.version, "1.0");
|
||||
do_check_eq(a1.name, "Test 1");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
do_check_eq(a2.version, "2.0");
|
||||
do_check_eq(a2.name, "Test 2");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_neq(a3, null);
|
||||
do_check_eq(a3.id, "addon3@tests.mozilla.org");
|
||||
do_check_eq(a3.version, "3.0");
|
||||
do_check_eq(a3.name, "Test 3");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
|
||||
do_check_true(hasFlag(a3.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a3.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_eq(a4, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon4@tests.mozilla.org");
|
||||
do_check_false(dest.exists());
|
||||
|
||||
do_check_eq(a5, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon5@tests.mozilla.org");
|
||||
do_check_false(dest.exists());
|
||||
|
||||
AddonManager.getAddonsByTypes(null, function(addons) {
|
||||
do_check_eq(addons.length, 3 + additionalAddons);
|
||||
AddonManager.getAddonsByTypes(["extension"], function(extensionAddons) {
|
||||
do_check_eq(extensionAddons.length, 3 + additionalExtensions);
|
||||
run_test_2();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Test that modified items are detected and items in other install locations
|
||||
// are ignored
|
||||
function run_test_2() {
|
||||
var dest = userDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
addon1.version = "1.1";
|
||||
writeInstallRDFToDir(addon1, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
try {
|
||||
dest.lastModifiedTime -= 20000; // test runs too fast to see real modifications
|
||||
}
|
||||
catch (e) {
|
||||
// Cannot set last modified time for directories on windows
|
||||
dest.append("install.rdf");
|
||||
dest.lastModifiedTime -= 20000;
|
||||
}
|
||||
addon2.version="2.1";
|
||||
writeInstallRDFToDir(addon2, dest);
|
||||
dest = globalDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
addon2.version="2.2";
|
||||
writeInstallRDFToDir(addon2, dest);
|
||||
dest = userDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
addon2.version="2.3";
|
||||
writeInstallRDFToDir(addon2, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon3@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.id, "addon1@tests.mozilla.org");
|
||||
do_check_eq(a1.version, "1.0");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
|
||||
do_check_false(isExtensionInAddonsList(userDir, a1.id));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
do_check_eq(a2.version, "2.1");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_false(isExtensionInAddonsList(userDir, a2.id));
|
||||
do_check_false(isExtensionInAddonsList(globalDir, a2.id));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_eq(a3, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
|
||||
|
||||
do_check_eq(a4, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
|
||||
|
||||
do_check_eq(a5, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
|
||||
|
||||
run_test_3();
|
||||
});
|
||||
}
|
||||
|
||||
// Check that removing items from the profile reveals their hidden versions.
|
||||
function run_test_3() {
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon4@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon3, dest);
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.id, "addon1@tests.mozilla.org");
|
||||
do_check_eq(a1.version, "1.1");
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
|
||||
do_check_true(isExtensionInAddonsList(userDir, a1.id));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
do_check_eq(a2.version, "2.3");
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_true(isExtensionInAddonsList(userDir, a2.id));
|
||||
do_check_false(isExtensionInAddonsList(globalDir, a2.id));
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_eq(a3, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
|
||||
|
||||
do_check_eq(a4, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
|
||||
|
||||
do_check_eq(a5, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon4@tests.mozilla.org");
|
||||
do_check_false(dest.exists());
|
||||
|
||||
run_test_4();
|
||||
});
|
||||
}
|
||||
|
||||
// Check that items in the profile hide the others again.
|
||||
function run_test_4() {
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
addon1.version = "1.2";
|
||||
writeInstallRDFToDir(addon1, dest);
|
||||
dest = userDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.id, "addon1@tests.mozilla.org");
|
||||
do_check_eq(a1.version, "1.2");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
|
||||
do_check_false(isExtensionInAddonsList(userDir, a1.id));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
do_check_eq(a2.version, "2.2");
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_false(isExtensionInAddonsList(userDir, a2.id));
|
||||
do_check_true(isExtensionInAddonsList(globalDir, a2.id));
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_eq(a3, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
|
||||
|
||||
do_check_eq(a4, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
|
||||
|
||||
do_check_eq(a5, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
|
||||
|
||||
run_test_5();
|
||||
});
|
||||
}
|
||||
|
||||
// More hiding and revealing
|
||||
function run_test_5() {
|
||||
var dest = userDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
dest = globalDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
addon2.version = "2.4";
|
||||
writeInstallRDFToDir(addon2, dest);
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.id, "addon1@tests.mozilla.org");
|
||||
do_check_eq(a1.version, "1.2");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
|
||||
do_check_false(isExtensionInAddonsList(userDir, a1.id));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
do_check_eq(a2.version, "2.4");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_false(isExtensionInAddonsList(userDir, a2.id));
|
||||
do_check_false(isExtensionInAddonsList(globalDir, a2.id));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_eq(a3, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
|
||||
|
||||
do_check_eq(a4, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
|
||||
|
||||
do_check_eq(a5, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
|
||||
|
||||
run_test_6();
|
||||
});
|
||||
}
|
||||
|
||||
// Checks that a removal from one location and an addition in another location
|
||||
// for the same item is handled
|
||||
function run_test_6() {
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
dest = userDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
addon1.version = "1.3";
|
||||
writeInstallRDFToDir(addon1, dest);
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.id, "addon1@tests.mozilla.org");
|
||||
do_check_eq(a1.version, "1.3");
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
|
||||
do_check_true(isExtensionInAddonsList(userDir, a1.id));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
do_check_eq(a2.version, "2.4");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_false(isExtensionInAddonsList(userDir, a2.id));
|
||||
do_check_false(isExtensionInAddonsList(globalDir, a2.id));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
|
||||
do_check_eq(a3, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
|
||||
|
||||
do_check_eq(a4, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
|
||||
|
||||
do_check_eq(a5, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
|
||||
|
||||
run_test_7();
|
||||
});
|
||||
}
|
||||
|
||||
// This should remove any remaining items
|
||||
function run_test_7() {
|
||||
var dest = userDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_eq(a1, null);
|
||||
do_check_eq(a2, null);
|
||||
do_check_eq(a3, null);
|
||||
do_check_eq(a4, null);
|
||||
do_check_eq(a5, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon1@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon2@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(userDir, "addon1@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(userDir, "addon2@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(userDir, "addon3@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(userDir, "addon4@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(userDir, "addon5@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(globalDir, "addon1@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(globalDir, "addon2@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(globalDir, "addon3@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(globalDir, "addon4@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(globalDir, "addon5@tests.mozilla.org"));
|
||||
|
||||
end_test();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,680 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies that themes behave as expected
|
||||
|
||||
// TODO This test relies on the default theme being present
|
||||
|
||||
const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
|
||||
|
||||
Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm");
|
||||
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, "theme1/1.0");
|
||||
var dest = profileDir.clone();
|
||||
dest.append("theme1@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "theme1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 1",
|
||||
type: 4,
|
||||
internalName: "theme1/1.0",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "2"
|
||||
}]
|
||||
}, dest);
|
||||
dest = profileDir.clone();
|
||||
dest.append("theme2@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "theme2@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 1",
|
||||
internalName: "theme2/1.0",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "2"
|
||||
}]
|
||||
}, dest);
|
||||
|
||||
startupManager(1);
|
||||
// Make sure we only register once despite multiple calls
|
||||
AddonManager.addInstallListener(InstallListener);
|
||||
AddonManager.addAddonListener(AddonListener);
|
||||
AddonManager.addInstallListener(InstallListener);
|
||||
AddonManager.addAddonListener(AddonListener);
|
||||
|
||||
AddonManager.getAddons(["theme1@tests.mozilla.org", "theme2@tests.mozilla.org"], function([t1, t2]) {
|
||||
do_check_neq(t1, null);
|
||||
do_check_false(t1.userDisabled);
|
||||
do_check_false(t1.appDisabled);
|
||||
do_check_true(t1.isActive);
|
||||
do_check_true(isThemeInAddonsList(profileDir, t1.id));
|
||||
do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
do_check_neq(t2, null);
|
||||
do_check_true(t2.userDisabled);
|
||||
do_check_false(t2.appDisabled);
|
||||
do_check_false(t2.isActive);
|
||||
do_check_false(isThemeInAddonsList(profileDir, t2.id));
|
||||
do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_true(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
run_test_1();
|
||||
});
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
do_test_finished();
|
||||
}
|
||||
|
||||
// Checks enabling one theme disables the others
|
||||
function run_test_1() {
|
||||
prepare_test({
|
||||
"theme1@tests.mozilla.org": [
|
||||
"onDisabling"
|
||||
],
|
||||
"theme2@tests.mozilla.org": [
|
||||
"onEnabling"
|
||||
]
|
||||
});
|
||||
AddonManager.getAddons(["theme1@tests.mozilla.org", "theme2@tests.mozilla.org"], function([t1, t2]) {
|
||||
t2.userDisabled = false;
|
||||
|
||||
ensure_test_completed();
|
||||
do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
do_check_true(t1.userDisabled);
|
||||
do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_true(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
check_test_1();
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_1() {
|
||||
restartManager(0);
|
||||
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "theme2/1.0");
|
||||
|
||||
AddonManager.getAddons(["theme1@tests.mozilla.org", "theme2@tests.mozilla.org"], function([t1, t2]) {
|
||||
do_check_neq(t1, null);
|
||||
do_check_true(t1.userDisabled);
|
||||
do_check_false(t1.appDisabled);
|
||||
do_check_false(t1.isActive);
|
||||
do_check_false(isThemeInAddonsList(profileDir, t1.id));
|
||||
do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_true(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
do_check_neq(t2, null);
|
||||
do_check_false(t2.userDisabled);
|
||||
do_check_false(t2.appDisabled);
|
||||
do_check_true(t2.isActive);
|
||||
do_check_true(isThemeInAddonsList(profileDir, t2.id));
|
||||
do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
run_test_2();
|
||||
});
|
||||
}
|
||||
|
||||
// Removing the active theme should fall back to the default (not ideal in this
|
||||
// case since we don't have the default theme installed)
|
||||
function run_test_2() {
|
||||
var dest = profileDir.clone();
|
||||
dest.append("theme2@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
|
||||
restartManager(1);
|
||||
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
||||
|
||||
AddonManager.getAddons(["theme1@tests.mozilla.org", "theme2@tests.mozilla.org"], function([t1, t2]) {
|
||||
do_check_neq(t1, null);
|
||||
do_check_true(t1.userDisabled);
|
||||
do_check_false(t1.appDisabled);
|
||||
do_check_false(t1.isActive);
|
||||
do_check_false(isThemeInAddonsList(profileDir, t1.id));
|
||||
do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
do_check_true(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
|
||||
do_check_eq(t2, null);
|
||||
do_check_false(isThemeInAddonsList(profileDir, "theme2@tests.mozilla.org"));
|
||||
|
||||
run_test_3();
|
||||
});
|
||||
}
|
||||
|
||||
// Installing a lightweight theme should happen instantly and disable the default theme
|
||||
function run_test_3() {
|
||||
var dest = profileDir.clone();
|
||||
dest.append("theme2@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "theme2@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 1",
|
||||
internalName: "theme2/1.0",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "2"
|
||||
}]
|
||||
}, dest);
|
||||
restartManager(1);
|
||||
|
||||
prepare_test({
|
||||
"1@personas.mozilla.org": [
|
||||
["onInstalling", false],
|
||||
"onInstalled",
|
||||
["onEnabling", false],
|
||||
"onEnabled"
|
||||
],
|
||||
"{972ce4c6-7e08-4474-a285-3208198ce6fd}": [
|
||||
["onDisabling", false],
|
||||
"onDisabled",
|
||||
]
|
||||
});
|
||||
|
||||
LightweightThemeManager.currentTheme = {
|
||||
id: "1",
|
||||
version: "1",
|
||||
name: "Test LW Theme",
|
||||
description: "A test theme",
|
||||
author: "Mozilla",
|
||||
homepageURL: "http://localhost:4444/data/index.html",
|
||||
headerURL: "http://localhost:4444/data/header.png",
|
||||
footerURL: "http://localhost:4444/data/footer.png",
|
||||
previewURL: "http://localhost:4444/data/preview.png",
|
||||
iconURL: "http://localhost:4444/data/icon.png"
|
||||
};
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
AddonManager.getAddon("1@personas.mozilla.org", function(p1) {
|
||||
do_check_neq(null, p1);
|
||||
do_check_eq(p1.name, "Test LW Theme");
|
||||
do_check_eq(p1.version, "1");
|
||||
do_check_eq(p1.description, "A test theme");
|
||||
do_check_eq(p1.creator, "Mozilla");
|
||||
do_check_eq(p1.homepageURL, "http://localhost:4444/data/index.html");
|
||||
do_check_eq(p1.iconURL, "http://localhost:4444/data/icon.png");
|
||||
do_check_eq(p1.screenshots.length, 1);
|
||||
do_check_eq(p1.screenshots[0], "http://localhost:4444/data/preview.png");
|
||||
do_check_false(p1.appDisabled);
|
||||
do_check_false(p1.userDisabled);
|
||||
do_check_true(p1.isActive);
|
||||
do_check_eq(p1.pendingOperations, 0);
|
||||
do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL);
|
||||
|
||||
AddonManager.getAddonsByTypes(["theme"], function(addons) {
|
||||
let seen = false;
|
||||
addons.forEach(function(a) {
|
||||
if (a.id == "1@personas.mozilla.org") {
|
||||
seen = true;
|
||||
}
|
||||
else {
|
||||
dump("Checking theme " + a.id + "\n");
|
||||
do_check_false(a.isActive);
|
||||
do_check_true(a.userDisabled);
|
||||
}
|
||||
});
|
||||
do_check_true(seen);
|
||||
|
||||
run_test_4();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Installing a second lightweight theme should disable the first with no restart
|
||||
function run_test_4() {
|
||||
prepare_test({
|
||||
"1@personas.mozilla.org": [
|
||||
["onDisabling", false],
|
||||
"onDisabled",
|
||||
],
|
||||
"2@personas.mozilla.org": [
|
||||
["onInstalling", false],
|
||||
"onInstalled",
|
||||
["onEnabling", false],
|
||||
"onEnabled"
|
||||
]
|
||||
});
|
||||
|
||||
LightweightThemeManager.currentTheme = {
|
||||
id: "2",
|
||||
version: "1",
|
||||
name: "Test LW Theme",
|
||||
description: "A second test theme",
|
||||
author: "Mozilla",
|
||||
homepageURL: "http://localhost:4444/data/index.html",
|
||||
headerURL: "http://localhost:4444/data/header.png",
|
||||
footerURL: "http://localhost:4444/data/footer.png",
|
||||
previewURL: "http://localhost:4444/data/preview.png",
|
||||
iconURL: "http://localhost:4444/data/icon.png"
|
||||
};
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
AddonManager.getAddons(["1@personas.mozilla.org",
|
||||
"2@personas.mozilla.org"], function([p1, p2]) {
|
||||
do_check_neq(null, p2);
|
||||
do_check_false(p2.appDisabled);
|
||||
do_check_false(p2.userDisabled);
|
||||
do_check_true(p2.isActive);
|
||||
do_check_eq(p2.pendingOperations, 0);
|
||||
do_check_eq(p2.permissions, AddonManager.PERM_CAN_UNINSTALL);
|
||||
|
||||
do_check_neq(null, p1);
|
||||
do_check_false(p1.appDisabled);
|
||||
do_check_true(p1.userDisabled);
|
||||
do_check_false(p1.isActive);
|
||||
do_check_eq(p1.pendingOperations, 0);
|
||||
do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL + AddonManager.PERM_CAN_ENABLE);
|
||||
|
||||
AddonManager.getAddonsByTypes(["theme"], function(addons) {
|
||||
let seen = false;
|
||||
addons.forEach(function(a) {
|
||||
if (a.id == "2@personas.mozilla.org") {
|
||||
seen = true;
|
||||
}
|
||||
else {
|
||||
dump("Checking theme " + a.id + "\n");
|
||||
do_check_false(a.isActive);
|
||||
do_check_true(a.userDisabled);
|
||||
}
|
||||
});
|
||||
do_check_true(seen);
|
||||
|
||||
run_test_5();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Switching to a custom theme should disable the lightweight theme and require
|
||||
// a restart. Cancelling that should also be possible.
|
||||
function run_test_5() {
|
||||
prepare_test({
|
||||
"2@personas.mozilla.org": [
|
||||
"onDisabling",
|
||||
],
|
||||
"theme2@tests.mozilla.org": [
|
||||
"onEnabling"
|
||||
]
|
||||
});
|
||||
|
||||
AddonManager.getAddons(["2@personas.mozilla.org",
|
||||
"theme2@tests.mozilla.org"], function([p2, t2]) {
|
||||
t2.userDisabled = false;
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
prepare_test({
|
||||
"2@personas.mozilla.org": [
|
||||
"onOperationCancelled",
|
||||
],
|
||||
"theme2@tests.mozilla.org": [
|
||||
"onOperationCancelled"
|
||||
]
|
||||
});
|
||||
|
||||
p2.userDisabled = false;
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
prepare_test({
|
||||
"2@personas.mozilla.org": [
|
||||
"onDisabling",
|
||||
],
|
||||
"theme2@tests.mozilla.org": [
|
||||
"onEnabling"
|
||||
]
|
||||
});
|
||||
|
||||
t2.userDisabled = false;
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_false(t2.isActive);
|
||||
do_check_false(t2.userDisabled);
|
||||
do_check_true(hasFlag(AddonManager.PENDING_ENABLE, t2.pendingOperations));
|
||||
do_check_true(p2.isActive);
|
||||
do_check_true(p2.userDisabled);
|
||||
do_check_true(hasFlag(AddonManager.PENDING_DISABLE, p2.pendingOperations));
|
||||
do_check_true(hasFlag(AddonManager.PERM_CAN_ENABLE, p2.permissions));
|
||||
|
||||
check_test_5();
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_5() {
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddons(["2@personas.mozilla.org",
|
||||
"theme2@tests.mozilla.org"], function([p2, t2]) {
|
||||
do_check_true(t2.isActive);
|
||||
do_check_false(t2.userDisabled);
|
||||
do_check_false(hasFlag(AddonManager.PENDING_ENABLE, t2.pendingOperations));
|
||||
do_check_false(p2.isActive);
|
||||
do_check_true(p2.userDisabled);
|
||||
do_check_false(hasFlag(AddonManager.PENDING_DISABLE, p2.pendingOperations));
|
||||
|
||||
run_test_6();
|
||||
});
|
||||
}
|
||||
|
||||
// Switching from a custom theme to a lightweight theme should require a restart
|
||||
function run_test_6() {
|
||||
prepare_test({
|
||||
"2@personas.mozilla.org": [
|
||||
"onEnabling",
|
||||
],
|
||||
"theme2@tests.mozilla.org": [
|
||||
"onDisabling"
|
||||
]
|
||||
});
|
||||
|
||||
AddonManager.getAddons(["2@personas.mozilla.org",
|
||||
"theme2@tests.mozilla.org"], function([p2, t2]) {
|
||||
p2.userDisabled = false;
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
prepare_test({
|
||||
"2@personas.mozilla.org": [
|
||||
"onOperationCancelled",
|
||||
],
|
||||
"theme2@tests.mozilla.org": [
|
||||
"onOperationCancelled"
|
||||
]
|
||||
});
|
||||
|
||||
t2.userDisabled = false;
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
prepare_test({
|
||||
"2@personas.mozilla.org": [
|
||||
"onEnabling",
|
||||
],
|
||||
"theme2@tests.mozilla.org": [
|
||||
"onDisabling"
|
||||
]
|
||||
});
|
||||
|
||||
p2.userDisabled = false;
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_false(p2.isActive);
|
||||
do_check_false(p2.userDisabled);
|
||||
do_check_true(hasFlag(AddonManager.PENDING_ENABLE, p2.pendingOperations));
|
||||
do_check_true(t2.isActive);
|
||||
do_check_true(t2.userDisabled);
|
||||
do_check_true(hasFlag(AddonManager.PENDING_DISABLE, t2.pendingOperations));
|
||||
|
||||
check_test_6();
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_6() {
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddons(["2@personas.mozilla.org",
|
||||
"theme2@tests.mozilla.org"], function([p2, t2]) {
|
||||
do_check_true(p2.isActive);
|
||||
do_check_false(p2.userDisabled);
|
||||
do_check_false(hasFlag(AddonManager.PENDING_ENABLE, p2.pendingOperations));
|
||||
do_check_false(t2.isActive);
|
||||
do_check_true(t2.userDisabled);
|
||||
do_check_false(hasFlag(AddonManager.PENDING_DISABLE, t2.pendingOperations));
|
||||
|
||||
run_test_7();
|
||||
});
|
||||
}
|
||||
|
||||
// Uninstalling a lightweight theme should not require a restart
|
||||
function run_test_7() {
|
||||
prepare_test({
|
||||
"1@personas.mozilla.org": [
|
||||
["onUninstalling", false],
|
||||
"onUninstalled"
|
||||
]
|
||||
});
|
||||
|
||||
AddonManager.getAddon("1@personas.mozilla.org", function(p1) {
|
||||
p1.uninstall();
|
||||
|
||||
ensure_test_completed();
|
||||
do_check_eq(LightweightThemeManager.usedThemes.length, 1);
|
||||
|
||||
run_test_8();
|
||||
});
|
||||
}
|
||||
|
||||
// Uninstalling a lightweight theme in use should not require a restart and it
|
||||
// should reactivate the default theme
|
||||
function run_test_8() {
|
||||
// TODO stop this depending on the default theme being present
|
||||
prepare_test({
|
||||
"2@personas.mozilla.org": [
|
||||
["onUninstalling", false],
|
||||
"onUninstalled"
|
||||
],
|
||||
"{972ce4c6-7e08-4474-a285-3208198ce6fd}": [
|
||||
["onEnabling", false],
|
||||
"onEnabled"
|
||||
]
|
||||
});
|
||||
|
||||
AddonManager.getAddon("2@personas.mozilla.org", function(p2) {
|
||||
p2.uninstall();
|
||||
|
||||
ensure_test_completed();
|
||||
do_check_eq(LightweightThemeManager.usedThemes.length, 0);
|
||||
|
||||
run_test_9();
|
||||
});
|
||||
}
|
||||
|
||||
// Uninstalling a theme not in use should not require a restart
|
||||
function run_test_9() {
|
||||
AddonManager.getAddon("theme1@tests.mozilla.org", function(t1) {
|
||||
prepare_test({
|
||||
"theme1@tests.mozilla.org": [
|
||||
["onUninstalling", false],
|
||||
"onUninstalled"
|
||||
]
|
||||
});
|
||||
|
||||
t1.uninstall();
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
AddonManager.getAddon("theme1@tests.mozilla.org", function(newt1) {
|
||||
do_check_eq(newt1, null);
|
||||
|
||||
run_test_10();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Uninstalling a custom theme in use should require a restart
|
||||
function run_test_10() {
|
||||
AddonManager.getAddon("theme2@tests.mozilla.org", function(oldt2) {
|
||||
prepare_test({
|
||||
"theme2@tests.mozilla.org": [
|
||||
"onEnabling",
|
||||
],
|
||||
"{972ce4c6-7e08-4474-a285-3208198ce6fd}": [
|
||||
"onDisabling"
|
||||
]
|
||||
});
|
||||
|
||||
oldt2.userDisabled = false;
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddons(["{972ce4c6-7e08-4474-a285-3208198ce6fd}",
|
||||
"theme2@tests.mozilla.org"], function([d, t2]) {
|
||||
do_check_true(t2.isActive);
|
||||
do_check_false(t2.userDisabled);
|
||||
do_check_false(t2.appDisabled);
|
||||
do_check_false(d.isActive);
|
||||
do_check_true(d.userDisabled);
|
||||
do_check_false(d.appDisabled);
|
||||
|
||||
prepare_test({
|
||||
"theme2@tests.mozilla.org": [
|
||||
"onUninstalling",
|
||||
],
|
||||
"{972ce4c6-7e08-4474-a285-3208198ce6fd}": [
|
||||
"onEnabling"
|
||||
]
|
||||
});
|
||||
|
||||
t2.uninstall();
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
restartManager(0);
|
||||
|
||||
run_test_11();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Installing a custom theme not in use should not require a restart
|
||||
function run_test_11() {
|
||||
prepare_test({ }, [
|
||||
"onNewInstall"
|
||||
]);
|
||||
|
||||
AddonManager.getInstallForFile(do_get_addon("test_theme"), function(install) {
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_neq(install, null);
|
||||
do_check_eq(install.type, "theme");
|
||||
do_check_eq(install.version, "1.0");
|
||||
do_check_eq(install.name, "Test Theme 1");
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
|
||||
prepare_test({
|
||||
"theme1@tests.mozilla.org": [
|
||||
["onInstalling", false],
|
||||
"onInstalled"
|
||||
]
|
||||
}, [
|
||||
"onInstallStarted",
|
||||
"onInstallEnded",
|
||||
], check_test_11);
|
||||
install.install();
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_11() {
|
||||
AddonManager.getAddon("theme1@tests.mozilla.org", function(t1) {
|
||||
do_check_neq(t1, null);
|
||||
|
||||
run_test_12();
|
||||
});
|
||||
}
|
||||
|
||||
// Updating a custom theme not in use should not require a restart
|
||||
function run_test_12() {
|
||||
prepare_test({ }, [
|
||||
"onNewInstall"
|
||||
]);
|
||||
|
||||
AddonManager.getInstallForFile(do_get_addon("test_theme"), function(install) {
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_neq(install, null);
|
||||
do_check_eq(install.type, "theme");
|
||||
do_check_eq(install.version, "1.0");
|
||||
do_check_eq(install.name, "Test Theme 1");
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
|
||||
prepare_test({
|
||||
"theme1@tests.mozilla.org": [
|
||||
["onInstalling", false],
|
||||
"onInstalled"
|
||||
]
|
||||
}, [
|
||||
"onInstallStarted",
|
||||
"onInstallEnded",
|
||||
], check_test_12);
|
||||
install.install();
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_12() {
|
||||
AddonManager.getAddon("theme1@tests.mozilla.org", function(t1) {
|
||||
do_check_neq(t1, null);
|
||||
|
||||
run_test_13();
|
||||
});
|
||||
}
|
||||
|
||||
// Updating a custom theme in use should require a restart
|
||||
function run_test_13() {
|
||||
AddonManager.getAddon("theme1@tests.mozilla.org", function(t1) {
|
||||
prepare_test({
|
||||
"theme1@tests.mozilla.org": [
|
||||
"onEnabling",
|
||||
],
|
||||
"{972ce4c6-7e08-4474-a285-3208198ce6fd}": [
|
||||
"onDisabling"
|
||||
]
|
||||
});
|
||||
|
||||
t1.userDisabled = false;
|
||||
ensure_test_completed();
|
||||
restartManager(0);
|
||||
|
||||
prepare_test({ }, [
|
||||
"onNewInstall"
|
||||
]);
|
||||
|
||||
AddonManager.getInstallForFile(do_get_addon("test_theme"), function(install) {
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_neq(install, null);
|
||||
do_check_eq(install.type, "theme");
|
||||
do_check_eq(install.version, "1.0");
|
||||
do_check_eq(install.name, "Test Theme 1");
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
|
||||
prepare_test({
|
||||
"theme1@tests.mozilla.org": [
|
||||
"onInstalling",
|
||||
]
|
||||
}, [
|
||||
"onInstallStarted",
|
||||
"onInstallEnded",
|
||||
], check_test_13);
|
||||
install.install();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_13() {
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddon("theme1@tests.mozilla.org", function(t1) {
|
||||
do_check_neq(t1, null);
|
||||
do_check_true(t1.isActive);
|
||||
|
||||
end_test();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,212 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies that add-ons can be uninstalled.
|
||||
|
||||
var addon1 = {
|
||||
id: "addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Test 1",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}]
|
||||
};
|
||||
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
// Sets up the profile by installing a couple of add-ons. One is dependent on
|
||||
// the other.
|
||||
function run_test() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
do_test_pending();
|
||||
startupManager(1);
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(olda1) {
|
||||
do_check_eq(olda1, null);
|
||||
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
writeInstallRDFToDir(addon1, dest);
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_neq(a1, null);
|
||||
do_check_true(a1.isActive);
|
||||
do_check_false(a1.userDisabled);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
|
||||
do_check_eq(a1.pendingOperations, 0);
|
||||
|
||||
run_test_1();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
do_test_finished();
|
||||
}
|
||||
|
||||
// Uninstalling an add-on should work.
|
||||
function run_test_1() {
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onUninstalling"
|
||||
]
|
||||
});
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_eq(a1.pendingOperations, 0);
|
||||
a1.uninstall();
|
||||
do_check_true(hasFlag(a1.pendingOperations, AddonManager.PENDING_UNINSTALL));
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
AddonManager.getAddonsWithPendingOperations(null, function(list) {
|
||||
do_check_eq(list.length, 1);
|
||||
do_check_eq(list[0].id, "addon1@tests.mozilla.org");
|
||||
|
||||
check_test_1();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_1() {
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_eq(a1, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon1@tests.mozilla.org"));
|
||||
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
do_check_false(dest.exists());
|
||||
writeInstallRDFToDir(addon1, dest);
|
||||
restartManager(1);
|
||||
|
||||
run_test_2();
|
||||
});
|
||||
}
|
||||
|
||||
// Cancelling the uninstall should send onOperationCancelled
|
||||
function run_test_2() {
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onUninstalling"
|
||||
]
|
||||
});
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_neq(a1, null);
|
||||
do_check_true(a1.isActive);
|
||||
do_check_false(a1.userDisabled);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
|
||||
do_check_eq(a1.pendingOperations, 0);
|
||||
a1.uninstall();
|
||||
do_check_true(hasFlag(a1.pendingOperations, AddonManager.PENDING_UNINSTALL));
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onOperationCancelled"
|
||||
]
|
||||
});
|
||||
a1.cancelUninstall();
|
||||
do_check_eq(a1.pendingOperations, 0);
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
check_test_2();
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_2() {
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_neq(a1, null);
|
||||
do_check_true(a1.isActive);
|
||||
do_check_false(a1.userDisabled);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
|
||||
|
||||
run_test_3();
|
||||
});
|
||||
}
|
||||
|
||||
// Uninstalling an item pending disable should still require a restart
|
||||
function run_test_3() {
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onDisabling"
|
||||
]
|
||||
});
|
||||
a1.userDisabled = true;
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_true(hasFlag(AddonManager.PENDING_DISABLE, a1.pendingOperations));
|
||||
do_check_true(a1.isActive);
|
||||
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onUninstalling"
|
||||
]
|
||||
});
|
||||
a1.uninstall();
|
||||
|
||||
check_test_3();
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_3() {
|
||||
ensure_test_completed();
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_neq(a1, null);
|
||||
do_check_true(hasFlag(AddonManager.PENDING_DISABLE, a1.pendingOperations));
|
||||
do_check_true(hasFlag(AddonManager.PENDING_UNINSTALL, a1.pendingOperations));
|
||||
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onOperationCancelled"
|
||||
]
|
||||
});
|
||||
a1.cancelUninstall();
|
||||
ensure_test_completed();
|
||||
|
||||
restartManager(0);
|
||||
run_test_4();
|
||||
});
|
||||
}
|
||||
|
||||
// Test that uninstalling an inactive item should happen without a restart
|
||||
function run_test_4() {
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_neq(a1, null);
|
||||
do_check_false(a1.isActive);
|
||||
do_check_true(a1.userDisabled);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
|
||||
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
["onUninstalling", false],
|
||||
"onUninstalled"
|
||||
]
|
||||
});
|
||||
a1.uninstall();
|
||||
|
||||
check_test_4();
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_4() {
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_eq(a1, null);
|
||||
|
||||
end_test();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,233 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies that add-on update checks work
|
||||
|
||||
// The test extension uses an insecure update url.
|
||||
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
|
||||
|
||||
do_load_httpd_js();
|
||||
var testserver;
|
||||
var profileDir;
|
||||
|
||||
function run_test() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
// Create and configure the HTTP server.
|
||||
testserver = new nsHttpServer();
|
||||
testserver.registerDirectory("/data/", do_get_file("data"));
|
||||
testserver.registerDirectory("/addons/", do_get_file("addons"));
|
||||
testserver.start(4444);
|
||||
|
||||
profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
updateURL: "http://localhost:4444/data/test_update.rdf",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 1",
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon2@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
updateURL: "http://localhost:4444/data/test_update.rdf",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "0",
|
||||
maxVersion: "0"
|
||||
}],
|
||||
name: "Test Addon 2",
|
||||
}, dest);
|
||||
|
||||
startupManager(1);
|
||||
|
||||
do_test_pending();
|
||||
run_test_1();
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
testserver.stop(do_test_finished);
|
||||
}
|
||||
|
||||
// Verify that an update is available and can be installed.
|
||||
function run_test_1() {
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.version, "1.0");
|
||||
|
||||
prepare_test({}, [
|
||||
"onNewInstall",
|
||||
]);
|
||||
|
||||
a1.findUpdates({
|
||||
onCompatibilityUpdated: function(addon) {
|
||||
do_throw("Should not have seen a compatibility update");
|
||||
},
|
||||
|
||||
onUpdateAvailable: function(addon, install) {
|
||||
ensure_test_completed();
|
||||
|
||||
do_check_eq(addon, a1);
|
||||
do_check_eq(install.name, addon.name);
|
||||
do_check_eq(install.version, "2.0");
|
||||
do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
|
||||
do_check_eq(install.existingAddon, addon);
|
||||
|
||||
prepare_test({}, [
|
||||
"onDownloadStarted",
|
||||
"onDownloadEnded",
|
||||
], check_test_1);
|
||||
install.install();
|
||||
},
|
||||
|
||||
onUpdateFinished: function(addon, status) {
|
||||
do_check_eq(addon, a1);
|
||||
do_check_eq(status, 0);
|
||||
}
|
||||
}, AddonManager.UPDATE_WHEN_USER_REQUESTED);
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_1(install) {
|
||||
ensure_test_completed();
|
||||
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
run_test_2();
|
||||
}
|
||||
|
||||
// Continue installing the update.
|
||||
function run_test_2() {
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onInstalling"
|
||||
]
|
||||
}, [
|
||||
"onInstallStarted",
|
||||
"onInstallEnded",
|
||||
], check_test_2);
|
||||
}
|
||||
|
||||
function check_test_2() {
|
||||
ensure_test_completed();
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(olda1) {
|
||||
do_check_neq(olda1, null);
|
||||
do_check_eq(olda1.version, "1.0");
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.version, "2.0");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
|
||||
a1.uninstall();
|
||||
restartManager(0);
|
||||
|
||||
run_test_3();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Check that an update check finds compatibility updates and applies them
|
||||
function run_test_3() {
|
||||
AddonManager.getAddon("addon2@tests.mozilla.org", function(a2) {
|
||||
do_check_neq(a2, null);
|
||||
do_check_false(a2.isActive);
|
||||
do_check_false(a2.isCompatible);
|
||||
do_check_true(a2.appDisabled);
|
||||
a2.findUpdates({
|
||||
onCompatibilityUpdated: function(addon) {
|
||||
do_check_true(a2.isCompatible);
|
||||
do_check_false(a2.appDisabled);
|
||||
do_check_false(a2.isActive);
|
||||
},
|
||||
|
||||
onUpdateAvailable: function(addon, install) {
|
||||
do_throw("Should not have seen an available update");
|
||||
},
|
||||
|
||||
onUpdateFinished: function(addon, status) {
|
||||
do_check_eq(addon, a2);
|
||||
do_check_eq(status, 0);
|
||||
restartManager(0);
|
||||
check_test_3();
|
||||
}
|
||||
}, AddonManager.UPDATE_WHEN_USER_REQUESTED);
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_3() {
|
||||
AddonManager.getAddon("addon2@tests.mozilla.org", function(a2) {
|
||||
do_check_neq(a2, null);
|
||||
do_check_true(a2.isActive);
|
||||
do_check_true(a2.isCompatible);
|
||||
do_check_false(a2.appDisabled);
|
||||
a2.uninstall();
|
||||
|
||||
run_test_4();
|
||||
});
|
||||
}
|
||||
|
||||
// Test that background update checks work
|
||||
function run_test_4() {
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
updateURL: "http://localhost:4444/data/test_update.rdf",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 1",
|
||||
}, dest);
|
||||
restartManager(1);
|
||||
|
||||
prepare_test({}, [
|
||||
"onNewInstall",
|
||||
"onDownloadStarted",
|
||||
"onDownloadEnded"
|
||||
], continue_test_4);
|
||||
|
||||
// Fake a timer event to cause a background update and wait for the magic to
|
||||
// happen
|
||||
gInternalManager.notify(null);
|
||||
}
|
||||
|
||||
function continue_test_4(install) {
|
||||
do_check_neq(install.existingAddon, null);
|
||||
do_check_eq(install.existingAddon.id, "addon1@tests.mozilla.org");
|
||||
prepare_test({
|
||||
"addon1@tests.mozilla.org": [
|
||||
"onInstalling"
|
||||
]
|
||||
}, [
|
||||
"onInstallStarted",
|
||||
"onInstallEnded",
|
||||
], check_test_4);
|
||||
}
|
||||
|
||||
function check_test_4() {
|
||||
restartManager(1);
|
||||
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.version, "2.0");
|
||||
a1.uninstall();
|
||||
restartManager(0);
|
||||
|
||||
end_test();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,202 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies that AddonUpdateChecker works correctly
|
||||
|
||||
Components.utils.import("resource://gre/modules/AddonUpdateChecker.jsm");
|
||||
|
||||
do_load_httpd_js();
|
||||
var testserver;
|
||||
|
||||
function run_test() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
// Create and configure the HTTP server.
|
||||
testserver = new nsHttpServer();
|
||||
testserver.registerDirectory("/data/", do_get_file("data"));
|
||||
testserver.start(4444);
|
||||
|
||||
do_test_pending();
|
||||
run_test_1();
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
testserver.stop(do_test_finished);
|
||||
}
|
||||
|
||||
// Test that a basic update check returns the expected available updates
|
||||
function run_test_1() {
|
||||
AddonUpdateChecker.checkForUpdates("updatecheck1@tests.mozilla.org", "extension", null,
|
||||
"http://localhost:4444/data/test_updatecheck.rdf", {
|
||||
onUpdateCheckComplete: function(updates) {
|
||||
check_test_1(updates);
|
||||
},
|
||||
|
||||
onUpdateCheckError: function(status) {
|
||||
do_throw("Update check failed with status " + status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function check_test_1(updates) {
|
||||
do_check_eq(updates.length, 5);
|
||||
let update = AddonUpdateChecker.getNewestCompatibleUpdate(updates);
|
||||
do_check_neq(update, null);
|
||||
do_check_eq(update.version, 3);
|
||||
update = AddonUpdateChecker.getCompatibilityUpdate(updates, "2");
|
||||
do_check_neq(update, null);
|
||||
do_check_eq(update.version, 2);
|
||||
do_check_eq(update.targetApplications[0].minVersion, 1);
|
||||
do_check_eq(update.targetApplications[0].maxVersion, 2);
|
||||
|
||||
run_test_2();
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests that the security checks are applied correctly
|
||||
*
|
||||
* Test signature updateHash updateLink expected
|
||||
*--------------------------------------------------------
|
||||
* 2 absent absent http fail
|
||||
* 3 broken absent http fail
|
||||
* 4 correct absent http no update
|
||||
* 5 correct sha1 http update
|
||||
* 6 corrent absent https update
|
||||
* 7 corrent sha1 https update
|
||||
* 8 corrent md2 http no update
|
||||
* 9 corrent md2 https update
|
||||
*/
|
||||
|
||||
let updateKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDK426erD/H3XtsjvaB5+PJqbhj" +
|
||||
"Zc9EDI5OCJS8R3FIObJ9ZHJK1TXeaE7JWqt9WUmBWTEFvwS+FI9vWu8058N9CHhD" +
|
||||
"NyeP6i4LuUYjTURnn7Yw/IgzyIJ2oKsYa32RuxAyteqAWqPT/J63wBixIeCxmysf" +
|
||||
"awB/zH4KaPiY3vnrzQIDAQAB";
|
||||
|
||||
function run_test_2() {
|
||||
AddonUpdateChecker.checkForUpdates("test_bug378216_5@tests.mozilla.org",
|
||||
"extension", updateKey,
|
||||
"http://localhost:4444/data/test_updatecheck.rdf", {
|
||||
onUpdateCheckComplete: function(updates) {
|
||||
do_throw("Expected the update check to fail");
|
||||
},
|
||||
|
||||
onUpdateCheckError: function(status) {
|
||||
run_test_3();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_3() {
|
||||
AddonUpdateChecker.checkForUpdates("test_bug378216_7@tests.mozilla.org",
|
||||
"extension", updateKey,
|
||||
"http://localhost:4444/data/test_updatecheck.rdf", {
|
||||
onUpdateCheckComplete: function(updates) {
|
||||
do_throw("Expected the update check to fail");
|
||||
},
|
||||
|
||||
onUpdateCheckError: function(status) {
|
||||
run_test_4();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_4() {
|
||||
AddonUpdateChecker.checkForUpdates("test_bug378216_8@tests.mozilla.org",
|
||||
"extension", updateKey,
|
||||
"http://localhost:4444/data/test_updatecheck.rdf", {
|
||||
onUpdateCheckComplete: function(updates) {
|
||||
do_check_eq(updates.length, 1);
|
||||
do_check_false("updateURL" in updates[0]);
|
||||
run_test_5();
|
||||
},
|
||||
|
||||
onUpdateCheckError: function(status) {
|
||||
do_throw("Update check failed with status " + status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_5() {
|
||||
AddonUpdateChecker.checkForUpdates("test_bug378216_9@tests.mozilla.org",
|
||||
"extension", updateKey,
|
||||
"http://localhost:4444/data/test_updatecheck.rdf", {
|
||||
onUpdateCheckComplete: function(updates) {
|
||||
do_check_eq(updates.length, 1);
|
||||
do_check_eq(updates[0].version, "2.0");
|
||||
do_check_true("updateURL" in updates[0]);
|
||||
run_test_6();
|
||||
},
|
||||
|
||||
onUpdateCheckError: function(status) {
|
||||
do_throw("Update check failed with status " + status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_6() {
|
||||
AddonUpdateChecker.checkForUpdates("test_bug378216_10@tests.mozilla.org",
|
||||
"extension", updateKey,
|
||||
"http://localhost:4444/data/test_updatecheck.rdf", {
|
||||
onUpdateCheckComplete: function(updates) {
|
||||
do_check_eq(updates.length, 1);
|
||||
do_check_eq(updates[0].version, "2.0");
|
||||
do_check_true("updateURL" in updates[0]);
|
||||
run_test_7();
|
||||
},
|
||||
|
||||
onUpdateCheckError: function(status) {
|
||||
do_throw("Update check failed with status " + status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_7() {
|
||||
AddonUpdateChecker.checkForUpdates("test_bug378216_11@tests.mozilla.org",
|
||||
"extension", updateKey,
|
||||
"http://localhost:4444/data/test_updatecheck.rdf", {
|
||||
onUpdateCheckComplete: function(updates) {
|
||||
do_check_eq(updates.length, 1);
|
||||
do_check_eq(updates[0].version, "2.0");
|
||||
do_check_true("updateURL" in updates[0]);
|
||||
run_test_8();
|
||||
},
|
||||
|
||||
onUpdateCheckError: function(status) {
|
||||
do_throw("Update check failed with status " + status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_8() {
|
||||
AddonUpdateChecker.checkForUpdates("test_bug378216_12@tests.mozilla.org",
|
||||
"extension", updateKey,
|
||||
"http://localhost:4444/data/test_updatecheck.rdf", {
|
||||
onUpdateCheckComplete: function(updates) {
|
||||
do_check_eq(updates.length, 1);
|
||||
do_check_false("updateURL" in updates[0]);
|
||||
run_test_9();
|
||||
},
|
||||
|
||||
onUpdateCheckError: function(status) {
|
||||
do_throw("Update check failed with status " + status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_9() {
|
||||
AddonUpdateChecker.checkForUpdates("test_bug378216_13@tests.mozilla.org",
|
||||
"extension", updateKey,
|
||||
"http://localhost:4444/data/test_updatecheck.rdf", {
|
||||
onUpdateCheckComplete: function(updates) {
|
||||
do_check_eq(updates.length, 1);
|
||||
do_check_eq(updates[0].version, "2.0");
|
||||
do_check_true("updateURL" in updates[0]);
|
||||
end_test();
|
||||
},
|
||||
|
||||
onUpdateCheckError: function(status) {
|
||||
do_throw("Update check failed with status " + status);
|
||||
}
|
||||
});
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies that app upgrades produce the expected behaviours.
|
||||
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
function run_test() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
// Will be enabled in the first version and disabled in subsequent versions
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 1",
|
||||
}, dest);
|
||||
|
||||
// Works in all tested versions
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon2@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon2@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "2"
|
||||
}],
|
||||
name: "Test Addon 2",
|
||||
}, dest);
|
||||
|
||||
// Will be disabled in the first version and enabled in the second.
|
||||
dest = profileDir.clone();
|
||||
dest.append("addon3@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "addon3@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "2",
|
||||
maxVersion: "2"
|
||||
}],
|
||||
name: "Test Addon 3",
|
||||
}, dest);
|
||||
|
||||
do_test_pending();
|
||||
|
||||
run_test_1();
|
||||
}
|
||||
|
||||
// Test that the test extensions are all installed
|
||||
function run_test_1() {
|
||||
startupManager(1);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org"], function([a1, a2, a3]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
||||
|
||||
do_check_neq(a3, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
|
||||
|
||||
run_test_2();
|
||||
});
|
||||
}
|
||||
|
||||
// Test that upgrading the application disables now incompatible add-ons
|
||||
function run_test_2() {
|
||||
restartManager(1, "2");
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org"], function([a1, a2, a3]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
||||
|
||||
do_check_neq(a3, null);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
|
||||
|
||||
run_test_3();
|
||||
});
|
||||
}
|
||||
|
||||
// Test that nothing changes when only the build ID changes.
|
||||
function run_test_3() {
|
||||
// Simulates a simple Build ID change, the platform deletes extensions.ini
|
||||
// whenever the application is changed.
|
||||
var file = gProfD.clone();
|
||||
file.append("extensions.ini");
|
||||
file.remove(true);
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org"], function([a1, a2, a3]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
||||
|
||||
do_check_neq(a3, null);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
|
||||
|
||||
do_test_finished();
|
||||
});
|
||||
}
|
Загрузка…
Ссылка в новой задаче