diff --git a/toolkit/mozapps/extensions/src/nsExtensionManager.js.in b/toolkit/mozapps/extensions/src/nsExtensionManager.js.in
index c49c2417771..b841eb6ccd5 100644
--- a/toolkit/mozapps/extensions/src/nsExtensionManager.js.in
+++ b/toolkit/mozapps/extensions/src/nsExtensionManager.js.in
@@ -849,8 +849,22 @@ function extractRDFFileToTempDir(zipFile, fileName, suppressErrors) {
* @returns The Install Manifest datasource
*/
function getInstallManifest(file) {
- var fileURL = getURLSpecFromFile(file);
- var ds = gRDF.GetDataSourceBlocking(fileURL);
+ var fis = Cc["@mozilla.org/network/file-input-stream;1"].
+ createInstance(Ci.nsIFileInputStream);
+ fis.init(file, -1, -1, false);
+ fis.QueryInterface(Ci.nsILineInputStream);
+ var line = { value: "" };
+ var text = "";
+ while (fis.readLine(line))
+ text += line.value;
+ fis.close();
+
+ var rdfParser = Cc["@mozilla.org/rdf/xml-parser;1"].
+ createInstance(Ci.nsIRDFXMLParser)
+ var ds = Cc["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].
+ createInstance(Ci.nsIRDFDataSource);
+ rdfParser.parseString(ds, getURIFromFile(file), text);
+
var arcs = ds.ArcLabelsOut(gInstallManifestRoot);
if (!arcs.hasMoreElements()) {
ds = null;
@@ -3586,10 +3600,10 @@ ExtensionManager.prototype = {
if (ds.getItemProperty(id, "providesUpdatesSecurely") == "false") {
/* It's possible the previous version did not understand updateKeys so
* check if we can import one for this addon from it's manifest. */
- var location = this.getInstallLocation(id);
- var installRDF = location.getItemFile(id, FILE_INSTALL_MANIFEST);
+ location = this.getInstallLocation(id);
+ installRDF = location.getItemFile(id, FILE_INSTALL_MANIFEST);
if (installRDF.exists()) {
- var metadataDS = getInstallManifest(installRDF);
+ metadataDS = getInstallManifest(installRDF);
var literal = metadataDS.GetTarget(gInstallManifestRoot, EM_R("updateKey"), true);
if (literal && literal instanceof Ci.nsIRDFLiteral)
ds.setItemProperty(id, EM_R("updateKey"), literal);
@@ -4408,10 +4422,6 @@ ExtensionManager.prototype = {
addon.maxAppVersion,
null);
}
- // Prevent the datasource file from being lazily recreated after
- // it is deleted by calling Flush.
- this._installManifest.QueryInterface(Ci.nsIRDFRemoteDataSource);
- this._installManifest.Flush();
}
else {
em.datasource.removeDownload(this._xpi.path);
diff --git a/toolkit/mozapps/extensions/test/unit/data/test_bug424107_1.rdf b/toolkit/mozapps/extensions/test/unit/data/test_bug424107_1.rdf
new file mode 100644
index 00000000000..a8f33789a08
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/unit/data/test_bug424107_1.rdf
@@ -0,0 +1,20 @@
+
+
+
+
+
+ bug424107@tests.mozilla.org
+ 1
+
+
+
+ xpcshell@tests.mozilla.org
+ 5
+ 5
+
+
+
+ Bug 424107 test 1
+
+
diff --git a/toolkit/mozapps/extensions/test/unit/data/test_bug424107_2.rdf b/toolkit/mozapps/extensions/test/unit/data/test_bug424107_2.rdf
new file mode 100644
index 00000000000..18da35d5b1c
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/unit/data/test_bug424107_2.rdf
@@ -0,0 +1,20 @@
+
+
+
+
+
+ bug424107@tests.mozilla.org
+ 2
+
+
+
+ xpcshell@tests.mozilla.org
+ 5
+ 5
+
+
+
+ Bug 424107 test 2
+
+
diff --git a/toolkit/mozapps/extensions/test/unit/head_extensionmanager.js b/toolkit/mozapps/extensions/test/unit/head_extensionmanager.js
index baff1638b2a..712be8f1975 100644
--- a/toolkit/mozapps/extensions/test/unit/head_extensionmanager.js
+++ b/toolkit/mozapps/extensions/test/unit/head_extensionmanager.js
@@ -218,20 +218,21 @@ function startupEM()
gEM.QueryInterface(Components.interfaces.nsIObserver);
gEM.observe(null, "app-startup", null);
gEM.observe(null, "profile-after-change", "startup");
-
+
+ // First run is a new profile which nsAppRunner would consider as an update
+ // (no existing compatibility.ini)
+ var upgraded = true;
var needsRestart = false;
try {
needsRestart = gEM.checkForMismatches();
}
catch (e) {
- needsRestart = gEM.start(null);
+ needsRestart = false;
+ upgraded = false;
}
-
- if (needsRestart)
- gEM.start(null);
- // Make sure extension manager datasource is initialized by requesting it
- var dummy = gEM.datasource;
+ if (!upgraded || !needsRestart)
+ needsRestart = gEM.start(null);
}
/**
@@ -251,25 +252,6 @@ function shutdownEM()
*/
function restartEM()
{
- // We must unregister any datasources that may have been read from addons.
- var extensions = gProfD.clone();
- extensions.append("extensions");
- if (extensions.exists()) {
- var ioServ = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService);
- var addons = extensions.directoryEntries;
- while (addons.hasMoreElements()) {
- var addon = addons.getNext().QueryInterface(Components.interfaces.nsIFile);
- if (addon.isDirectory() && addon.leafName != "staged-xpis") {
- addon.append("install.rdf");
- if (addon.exists()) {
- var ds = gRDF.GetDataSource(ioServ.newFileURI(addon).spec);
- gRDF.UnregisterDataSource(ds);
- }
- }
- }
- }
-
var needsRestart = gEM.start(null);
if (needsRestart)
gEM.start(null);
diff --git a/toolkit/mozapps/extensions/test/unit/test_bug394717.js b/toolkit/mozapps/extensions/test/unit/test_bug394717.js
index 43138f46ee5..b6cf908f8ff 100644
--- a/toolkit/mozapps/extensions/test/unit/test_bug394717.js
+++ b/toolkit/mozapps/extensions/test/unit/test_bug394717.js
@@ -39,6 +39,8 @@
const checkListener = {
_onUpdateStartedCalled: false,
_onUpdateEndedCalled: false,
+ _onAddonUpdateStartedCount: 0,
+ _onAddonUpdateEndedCount: 0,
// nsIAddonUpdateCheckListener
onUpdateStarted: function onUpdateStarted() {
@@ -52,12 +54,12 @@ const checkListener = {
// nsIAddonUpdateCheckListener
onAddonUpdateStarted: function onAddonUpdateStarted(aAddon) {
- do_throw("Unexpected call to onAddonUpdateStarted!");
+ this._onAddonUpdateStartedCount++;
},
// nsIAddonUpdateCheckListener
onAddonUpdateEnded: function onAddonUpdateEnded(aAddon, aStatus) {
- do_throw("Unexpected call to onAddonUpdateEnded!");
+ this._onAddonUpdateEndedCount++;
}
}
@@ -78,5 +80,6 @@ function run_test_pt2() {
do_check_true(checkListener._onUpdateStartedCalled);
dump("Checking onUpdateEnded\n");
do_check_true(checkListener._onUpdateEndedCalled);
+ do_check_eq(checkListener._onAddonUpdateStartedCount, checkListener._onAddonUpdateEndedCount);
do_test_finished();
}
diff --git a/toolkit/mozapps/extensions/test/unit/test_bug424107.js b/toolkit/mozapps/extensions/test/unit/test_bug424107.js
new file mode 100644
index 00000000000..8c31c17f6f5
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/unit/test_bug424107.js
@@ -0,0 +1,73 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Dave Townsend .
+ *
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK *****
+ */
+
+function run_test()
+{
+ // Copy an initial add-on into the profile.
+ var extension = gProfD.clone()
+ extension.append("extensions");
+ extension.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
+ extension.append("bug424107@tests.mozilla.org");
+ extension.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
+ var sourcerdf = do_get_file("toolkit/mozapps/extensions/test/unit/data/test_bug424107_1.rdf");
+ sourcerdf.copyTo(extension, "install.rdf");
+
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "5", "1.9");
+ startupEM();
+ var addon = gEM.getItemForID("bug424107@tests.mozilla.org");
+ do_check_neq(addon, null);
+ do_check_eq(addon.version, 1);
+
+ // Uninstall
+ extension.remove(true);
+
+ restartEM();
+ addon = gEM.getItemForID("bug424107@tests.mozilla.org");
+ do_check_eq(addon, null);
+
+ // Install a new version
+ extension.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
+ sourcerdf = do_get_file("toolkit/mozapps/extensions/test/unit/data/test_bug424107_2.rdf");
+ sourcerdf.copyTo(extension, "install.rdf");
+
+ restartEM();
+ addon = gEM.getItemForID("bug424107@tests.mozilla.org");
+ do_check_neq(addon, null);
+ do_check_eq(addon.version, 2);
+}
+