mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1171792 - An update is attempted from an update notification when it is not possible to update. r=spohl
This commit is contained in:
parent
c509a2a687
commit
7e1a7f911b
@ -444,8 +444,17 @@ var gUpdates = {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.update.licenseURL)
|
||||
|
||||
let aus = CoC["@mozilla.org/updates/update-service;1"].
|
||||
getService(CoI.nsIApplicationUpdateService);
|
||||
if (!aus.canApplyUpdates) {
|
||||
aCallback("manualUpdate");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.update.licenseURL) {
|
||||
this.wiz.getPageById(this.updatesFoundPageId).setAttribute("next", "license");
|
||||
}
|
||||
|
||||
var self = this;
|
||||
this.getShouldCheckAddonCompatibility(function(shouldCheck) {
|
||||
@ -453,8 +462,7 @@ var gUpdates = {
|
||||
var incompatCheckPage = document.getElementById("incompatibleCheck");
|
||||
incompatCheckPage.setAttribute("next", self.updatesFoundPageId);
|
||||
aCallback(incompatCheckPage.id);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
aCallback(self.updatesFoundPageId);
|
||||
}
|
||||
});
|
||||
|
@ -495,25 +495,25 @@ function hasUpdateMutex() {
|
||||
return !!gUpdateMutexHandle;
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gCanApplyUpdates", function aus_gCanApplyUpdates() {
|
||||
function getCanApplyUpdates() {
|
||||
let useService = false;
|
||||
if (shouldUseService()) {
|
||||
// No need to perform directory write checks, the maintenance service will
|
||||
// be able to write to all directories.
|
||||
LOG("gCanApplyUpdates - bypass the write checks because we'll use the service");
|
||||
LOG("getCanApplyUpdates - bypass the write checks because we'll use the service");
|
||||
useService = true;
|
||||
}
|
||||
|
||||
if (!useService) {
|
||||
try {
|
||||
let updateTestFile = getUpdateFile([FILE_PERMS_TEST]);
|
||||
LOG("gCanApplyUpdates - testing write access " + updateTestFile.path);
|
||||
LOG("getCanApplyUpdates - testing write access " + updateTestFile.path);
|
||||
testWriteAccess(updateTestFile, false);
|
||||
if (AppConstants.platform == "macosx") {
|
||||
// Check that the application bundle can be written to.
|
||||
let appDirTestFile = getAppBaseDir();
|
||||
appDirTestFile.append(FILE_PERMS_TEST);
|
||||
LOG("gCanApplyUpdates - testing write access " + appDirTestFile.path);
|
||||
LOG("getCanApplyUpdates - testing write access " + appDirTestFile.path);
|
||||
if (appDirTestFile.exists()) {
|
||||
appDirTestFile.remove(false);
|
||||
}
|
||||
@ -522,7 +522,7 @@ XPCOMUtils.defineLazyGetter(this, "gCanApplyUpdates", function aus_gCanApplyUpda
|
||||
} else if (AppConstants.platform == "win") {
|
||||
// Example windowsVersion: Windows XP == 5.1
|
||||
let windowsVersion = Services.sysinfo.getProperty("version");
|
||||
LOG("gCanApplyUpdates - windowsVersion = " + windowsVersion);
|
||||
LOG("getCanApplyUpdates - windowsVersion = " + windowsVersion);
|
||||
|
||||
/**
|
||||
* For Vista, updates can be performed to a location requiring admin
|
||||
@ -545,13 +545,13 @@ XPCOMUtils.defineLazyGetter(this, "gCanApplyUpdates", function aus_gCanApplyUpda
|
||||
// appDir is under Program Files, so check if the user can elevate
|
||||
userCanElevate = Services.appinfo.QueryInterface(Ci.nsIWinAppHelper).
|
||||
userCanElevate;
|
||||
LOG("gCanApplyUpdates - on Vista, userCanElevate: " + userCanElevate);
|
||||
LOG("getCanApplyUpdates - on Vista, userCanElevate: " + userCanElevate);
|
||||
}
|
||||
catch (ex) {
|
||||
// When the installation directory is not under Program Files,
|
||||
// fall through to checking if write access to the
|
||||
// installation directory is available.
|
||||
LOG("gCanApplyUpdates - on Vista, appDir is not under Program Files");
|
||||
LOG("getCanApplyUpdates - on Vista, appDir is not under Program Files");
|
||||
}
|
||||
}
|
||||
|
||||
@ -579,7 +579,7 @@ XPCOMUtils.defineLazyGetter(this, "gCanApplyUpdates", function aus_gCanApplyUpda
|
||||
// if we're unable to create the test file this will throw an exception.
|
||||
let appDirTestFile = getAppBaseDir();
|
||||
appDirTestFile.append(FILE_PERMS_TEST);
|
||||
LOG("gCanApplyUpdates - testing write access " + appDirTestFile.path);
|
||||
LOG("getCanApplyUpdates - testing write access " + appDirTestFile.path);
|
||||
if (appDirTestFile.exists()) {
|
||||
appDirTestFile.remove(false);
|
||||
}
|
||||
@ -588,15 +588,15 @@ XPCOMUtils.defineLazyGetter(this, "gCanApplyUpdates", function aus_gCanApplyUpda
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
LOG("gCanApplyUpdates - unable to apply updates. Exception: " + e);
|
||||
LOG("getCanApplyUpdates - unable to apply updates. Exception: " + e);
|
||||
// No write privileges to install directory
|
||||
return false;
|
||||
}
|
||||
} // if (!useService)
|
||||
|
||||
LOG("gCanApplyUpdates - able to apply updates");
|
||||
LOG("getCanApplyUpdates - able to apply updates");
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the application can stage an update for the current session.
|
||||
@ -2396,7 +2396,7 @@ UpdateService.prototype = {
|
||||
// UPDATE_UNABLE_TO_APPLY_EXTERNAL
|
||||
// UPDATE_UNABLE_TO_APPLY_NOTIFY
|
||||
AUSTLMY.pingGeneric("UPDATE_UNABLE_TO_APPLY_" + this._pingSuffix,
|
||||
gCanApplyUpdates, true);
|
||||
getCanApplyUpdates(), true);
|
||||
// Histogram IDs:
|
||||
// UPDATE_CANNOT_STAGE_EXTERNAL
|
||||
// UPDATE_CANNOT_STAGE_NOTIFY
|
||||
@ -2646,7 +2646,7 @@ UpdateService.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gCanApplyUpdates) {
|
||||
if (!getCanApplyUpdates()) {
|
||||
LOG("UpdateService:_selectAndInstallUpdate - the user is unable to " +
|
||||
"apply updates... prompting");
|
||||
this._showPrompt(update);
|
||||
@ -2856,7 +2856,7 @@ UpdateService.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._incompatibleAddons.length > 0 || !gCanApplyUpdates) {
|
||||
if (this._incompatibleAddons.length > 0 || !getCanApplyUpdates()) {
|
||||
LOG("UpdateService:onUpdateEnded - prompting because there are " +
|
||||
"incompatible add-ons");
|
||||
if (this._incompatibleAddons.length > 0) {
|
||||
@ -2903,7 +2903,7 @@ UpdateService.prototype = {
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
get canApplyUpdates() {
|
||||
return gCanApplyUpdates && hasUpdateMutex();
|
||||
return getCanApplyUpdates() && hasUpdateMutex();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -87,6 +87,12 @@ reason = only Windows has the maintenance service.
|
||||
[test_0151_notify_backgroundCheckError.xul]
|
||||
[test_0161_check_unsupported.xul]
|
||||
[test_0162_notify_unsupported.xul]
|
||||
[test_0171_check_noPerms_manual.xul]
|
||||
skip-if = os != 'win'
|
||||
reason = test must be able to prevent file deletion.
|
||||
[test_0172_notify_noPerms_manual.xul]
|
||||
skip-if = os != 'win'
|
||||
reason = test must be able to prevent file deletion.
|
||||
[test_0900_deprecatedUpdateFormat_minor.xul]
|
||||
[test_0901_deprecatedUpdateFormat_major.xul]
|
||||
[test_9999_cleanup.xul]
|
||||
|
@ -0,0 +1,64 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
|
||||
<window title="Update Wizard pages: manual"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="runTestDefault();">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript"
|
||||
src="utils.js"/>
|
||||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
const TESTS = [ {
|
||||
pageid: PAGEID_CHECKING
|
||||
}, {
|
||||
pageid: PAGEID_MANUAL_UPDATE,
|
||||
buttonClick: "finish",
|
||||
extraCheckFunction: getWriteTestFile
|
||||
} ];
|
||||
|
||||
function runTest() {
|
||||
debugDump("entering");
|
||||
|
||||
let file = getWriteTestFile();
|
||||
file.create(file.NORMAL_FILE_TYPE, 0o444);
|
||||
file.fileAttributesWin |= file.WFA_READONLY;
|
||||
file.fileAttributesWin &= ~file.WFA_READWRITE;
|
||||
|
||||
let url = URL_HTTP_UPDATE_XML + "?showDetails=1" + getVersionParams();
|
||||
setUpdateURLOverride(url);
|
||||
|
||||
gUP.checkForUpdates();
|
||||
}
|
||||
|
||||
function getWriteTestFile() {
|
||||
let file = getAppBaseDir();
|
||||
file.append(FILE_PERMS_TEST);
|
||||
file.QueryInterface(Ci.nsILocalFileWin);
|
||||
if (file.exists()) {
|
||||
file.fileAttributesWin |= file.WFA_READWRITE;
|
||||
file.fileAttributesWin &= ~file.WFA_READONLY;
|
||||
file.remove(true);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test"></pre>
|
||||
</body>
|
||||
</window>
|
@ -0,0 +1,63 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
|
||||
<window title="Update Wizard pages: manual"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="runTestDefault();">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript"
|
||||
src="utils.js"/>
|
||||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
const TESTS = [ {
|
||||
pageid: PAGEID_MANUAL_UPDATE,
|
||||
buttonClick: "finish",
|
||||
extraCheckFunction: getWriteTestFile
|
||||
} ];
|
||||
|
||||
function runTest() {
|
||||
debugDump("entering");
|
||||
|
||||
let file = getWriteTestFile();
|
||||
file.create(file.NORMAL_FILE_TYPE, 0o444);
|
||||
file.fileAttributesWin |= file.WFA_READONLY;
|
||||
file.fileAttributesWin &= ~file.WFA_READWRITE;
|
||||
|
||||
let url = URL_HTTP_UPDATE_XML + "?showDetails=1&showPrompt=1" +
|
||||
getVersionParams();
|
||||
setUpdateURLOverride(url);
|
||||
|
||||
gAUS.checkForBackgroundUpdates();
|
||||
}
|
||||
|
||||
function getWriteTestFile() {
|
||||
let file = getAppBaseDir();
|
||||
file.append(FILE_PERMS_TEST);
|
||||
file.QueryInterface(Ci.nsILocalFileWin);
|
||||
if (file.exists()) {
|
||||
file.fileAttributesWin |= file.WFA_READWRITE;
|
||||
file.fileAttributesWin &= ~file.WFA_READONLY;
|
||||
file.remove(true);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test"></pre>
|
||||
</body>
|
||||
</window>
|
@ -13,7 +13,7 @@
|
||||
* overrideCallback (optional)
|
||||
* The function to call for the next test. This is typically called when the
|
||||
* wizard page changes but can also be called for other events by the previous
|
||||
* test. If this property isn't defined then the defailtCallback function will
|
||||
* test. If this property isn't defined then the defaultCallback function will
|
||||
* be called. If this property is defined then all other properties are
|
||||
* optional.
|
||||
*
|
||||
@ -137,7 +137,7 @@ const PAGEID_DUMMY = "dummy"; // Done
|
||||
const PAGEID_CHECKING = "checking"; // Done
|
||||
const PAGEID_PLUGIN_UPDATES = "pluginupdatesfound";
|
||||
const PAGEID_NO_UPDATES_FOUND = "noupdatesfound"; // Done
|
||||
const PAGEID_MANUAL_UPDATE = "manualUpdate"; // Tested on license load failure
|
||||
const PAGEID_MANUAL_UPDATE = "manualUpdate"; // Done
|
||||
const PAGEID_UNSUPPORTED = "unsupported"; // Done
|
||||
const PAGEID_INCOMPAT_CHECK = "incompatibleCheck"; // Done
|
||||
const PAGEID_FOUND_BASIC = "updatesfoundbasic"; // Done
|
||||
@ -1277,7 +1277,7 @@ function setupAddons(aCallback) {
|
||||
// Start the timout timer before the update window is displayed so it can
|
||||
// clean up tests that don't successfully display the update window.
|
||||
setupTimer(gTestTimeout);
|
||||
aCallback();
|
||||
SimpleTest.executeSoon(aCallback);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1389,7 +1389,7 @@ function resetAddons(aCallback) {
|
||||
aAddon.userDisabled = false;
|
||||
}
|
||||
});
|
||||
aCallback();
|
||||
SimpleTest.executeSoon(aCallback);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ const DIR_UPDATED = IS_MACOSX ? "Updated.app" : "updated";
|
||||
const FILE_APPLICATION_INI = "application.ini";
|
||||
const FILE_BACKUP_LOG = "backup-update.log";
|
||||
const FILE_LAST_LOG = "last-update.log";
|
||||
const FILE_PERMS_TEST = "update.test";
|
||||
const FILE_UPDATER_INI = "updater.ini";
|
||||
const FILE_UPDATES_DB = "updates.xml";
|
||||
const FILE_UPDATE_ACTIVE = "active-update.xml";
|
||||
|
Loading…
Reference in New Issue
Block a user