mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 424107: Extension updates installed from app mismatches window are lost. r=robstrong
This commit is contained in:
parent
cc4349db6e
commit
fcc08d49f4
@ -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);
|
||||
|
@ -0,0 +1,20 @@
|
||||
<?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>bug424107@tests.mozilla.org</em:id>
|
||||
<em:version>1</em:version>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>5</em:minVersion>
|
||||
<em:maxVersion>5</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<em:name>Bug 424107 test 1</em:name>
|
||||
</Description>
|
||||
</RDF>
|
@ -0,0 +1,20 @@
|
||||
<?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>bug424107@tests.mozilla.org</em:id>
|
||||
<em:version>2</em:version>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>5</em:minVersion>
|
||||
<em:maxVersion>5</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<em:name>Bug 424107 test 2</em:name>
|
||||
</Description>
|
||||
</RDF>
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
73
toolkit/mozapps/extensions/test/unit/test_bug424107.js
Normal file
73
toolkit/mozapps/extensions/test/unit/test_bug424107.js
Normal file
@ -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 <dtownsend@oxymoronical.com>.
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user