This commit is contained in:
Robert Sayre 2010-09-14 19:04:21 -07:00
Родитель 23d250224b 4236071ef1
Коммит fd337aaef5
15 изменённых файлов: 187 добавлений и 48 удалений

Просмотреть файл

@ -91,6 +91,11 @@ pref("app.update.timer", 600000);
// Enables some extra Application Update Logging (can reduce performance)
pref("app.update.log", false);
// The number of general background check failures to allow before notifying the
// user of the failure. User initiated update checks always notify the user of
// the failure.
pref("app.update.backgroundMaxErrors", 10);
// When |app.update.cert.requireBuiltIn| is true or not specified the
// final certificate and all certificates the connection is redirected to before
// the final certificate for the url specified in the |app.update.url|

Просмотреть файл

@ -458,7 +458,7 @@ Section "-InstallEndCleanup"
${EndUnless}
; Win7 taskbar and start menu link maintenance
${UpdateShortcutAppModelIDs} "$INSTDIR\${FileMainEXE}" "${AppUserModelID}"
${UpdateShortcutAppModelIDs} "$INSTDIR\${FileMainEXE}" "${AppUserModelID}" $0
; Refresh desktop icons
System::Call "shell32::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)"

Просмотреть файл

@ -85,7 +85,7 @@
${SetUninstallKeys}
; Win7 taskbar and start menu link maintenance
${UpdateShortcutAppModelIDs} "$INSTDIR\${FileMainEXE}" "${AppUserModelID}"
${UpdateShortcutAppModelIDs} "$INSTDIR\${FileMainEXE}" "${AppUserModelID}" $0
; Remove files that may be left behind by the application in the
; VirtualStore directory.

Просмотреть файл

@ -4771,8 +4771,9 @@
ClearErrors
${GetOptions} "$R0" "/UpdateShortcutAppUserModelIds" $R2
IfErrors hideshortcuts +1
${UpdateShortcutAppModelIDs} "$INSTDIR\${FileMainEXE}" "${AppUserModelID}"
GoTo finish
${UpdateShortcutAppModelIDs} "$INSTDIR\${FileMainEXE}" "${AppUserModelID}" $R2
StrCmp "$R2" "true" finish +1 ; true indicates that shortcuts have been updated
Quit ; Nothing initialized so no need to call OnEndCommon
; Require elevation if the user can elevate
hideshortcuts:
@ -6131,6 +6132,9 @@
* The install path of the app
* @param _APP_ID
* The application user model ID for the current install
* @return _RESULT
* false if no shotcuts were found for this install location.
* true if shotcuts were found for this install location.
*/
!macro UpdateShortcutAppModelIDs
@ -6149,9 +6153,11 @@
Push $R7 ; stack: $R7, $R8, $R9
Push $R6
Push $R5
Push $R4 ; stack: $R4, $R5, $R6, $R7, $R8, $R9
Push $R4
Push $R3 ; stack: $R3, $R5, $R6, $R7, $R8, $R9
StrCpy $R7 "$QUICKLAUNCH\User Pinned"
StrCpy $R3 "false"
ClearErrors
@ -6171,6 +6177,7 @@
${If} "$R4" == "$R9" ; link path == install path
ApplicationID::Set "$R7\TaskBar\$R5" "$R8"
Pop $R4 ; pop Set result off the stack
StrCpy $R3 "true"
${EndIf}
${EndIf}
ClearErrors
@ -6191,6 +6198,7 @@
${If} "$R4" == "$R9" ; link path == install path
ApplicationID::Set "$R7\StartMenu\$R5" "$R8"
Pop $R4 ; pop Set result off the stack
StrCpy $R3 "true"
${EndIf}
${EndIf}
ClearErrors
@ -6200,6 +6208,9 @@
${EndUnless}
FindClose $R6
StrCpy $R9 $R3
Pop $R3 ; stack: $R4, $R5, $R6, $R7, $R8, $R9
Pop $R4 ; stack: $R5, $R6, $R7, $R8, $R9
Pop $R5 ; stack: $R6, $R7, $R8, $R9
Pop $R6 ; stack: $R7, $R8, $R9
@ -6213,11 +6224,12 @@
!endif
!macroend
!macro UpdateShortcutAppModelIDsCall _INSTALL_PATH _APP_ID
!macro UpdateShortcutAppModelIDsCall _INSTALL_PATH _APP_ID _RESULT
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
Push "${_APP_ID}"
Push "${_INSTALL_PATH}"
Call UpdateShortcutAppModelIDs
Pop ${_RESULT}
!verbose pop
!macroend

Просмотреть файл

@ -50,6 +50,7 @@ const CoR = Components.results;
const XMLNS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const PREF_APP_UPDATE_BACKGROUNDERRORS = "app.update.backgroundErrors";
const PREF_APP_UPDATE_BILLBOARD_TEST_URL = "app.update.billboard.test_url";
const PREF_APP_UPDATE_CERT_ERRORS = "app.update.cert.errors";
const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
@ -75,6 +76,7 @@ const SRCEVT_BACKGROUND = 2;
const CERT_ATTR_CHECK_FAILED_NO_UPDATE = 100;
const CERT_ATTR_CHECK_FAILED_HAS_UPDATE = 101;
const BACKGROUNDCHECK_MULTIPLE_FAILURES = 110;
var gLogEnabled = false;
var gUpdatesFoundPageId;
@ -404,7 +406,8 @@ var gUpdates = {
// their permission to install, and it's ready for download.
this.setUpdate(arg0);
if (this.update.errorCode == CERT_ATTR_CHECK_FAILED_NO_UPDATE ||
this.update.errorCode == CERT_ATTR_CHECK_FAILED_HAS_UPDATE) {
this.update.errorCode == CERT_ATTR_CHECK_FAILED_HAS_UPDATE ||
this.update.errorCode == BACKGROUNDCHECK_MULTIPLE_FAILURES) {
aCallback("errorextra");
return;
}
@ -591,6 +594,11 @@ var gCheckingPage = {
// notifications will never happen.
Services.prefs.deleteBranch(PREF_APP_UPDATE_NEVER_BRANCH);
// The user will be notified if there is an error so clear the background
// check error count.
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_BACKGROUNDERRORS))
Services.prefs.clearUserPref(PREF_APP_UPDATE_BACKGROUNDERRORS);
this._checker = CoC["@mozilla.org/updates/update-checker;1"].
createInstance(CoI.nsIUpdateChecker);
this._checker.checkForUpdates(this.updateListener, true);
@ -666,7 +674,7 @@ var gCheckingPage = {
gUpdates.setUpdate(update);
if (update.errorCode &&
(update.errorCode == CERT_ATTR_CHECK_FAILED_NO_UPDATE ||
update.errorCode == CERT_ATTR_CHECK_FAILED_HAS_UPDATE )) {
update.errorCode == CERT_ATTR_CHECK_FAILED_HAS_UPDATE)) {
gUpdates.wiz.goTo("errorextra");
}
else {
@ -1624,13 +1632,19 @@ var gErrorExtraPage = {
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_ERRORS))
Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_ERRORS);
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_BACKGROUNDERRORS))
Services.prefs.clearUserPref(PREF_APP_UPDATE_BACKGROUNDERRORS);
if (gUpdates.update.errorCode == CERT_ATTR_CHECK_FAILED_HAS_UPDATE) {
document.getElementById("errorCertAttrHasUpdateLabel").hidden = false;
}
else {
document.getElementById("errorCertCheckNoUpdateLabel").hidden = false;
if (gUpdates.update.errorCode == CERT_ATTR_CHECK_FAILED_NO_UPDATE)
document.getElementById("errorCertCheckNoUpdateLabel").hidden = false;
else
document.getElementById("genericBackgroundErrorLabel").hidden = false;
var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_MANUAL_URL);
var errorLinkLabel = document.getElementById("errorCertAttrLinkLabel");
var errorLinkLabel = document.getElementById("errorExtraLinkLabel");
errorLinkLabel.value = manualURL;
errorLinkLabel.setAttribute("url", manualURL);
errorLinkLabel.hidden = false;

Просмотреть файл

@ -242,7 +242,7 @@
<label id="genericBackgroundErrorLabel"
hidden="true">&genericBackgroundError.label;</label>
<hbox>
<label id="errorCertAttrLinkLabel" class="text-link" hidden="true"
<label id="errorExtraLinkLabel" class="text-link" hidden="true"
value="" onclick="openUpdateURL(event);"/>
</hbox>
</vbox>

Просмотреть файл

@ -53,6 +53,8 @@ const Cr = Components.results;
const PREF_APP_UPDATE_AUTO = "app.update.auto";
const PREF_APP_UPDATE_BACKGROUND_INTERVAL = "app.update.download.backgroundInterval";
const PREF_APP_UPDATE_BACKGROUNDERRORS = "app.update.backgroundErrors";
const PREF_APP_UPDATE_BACKGROUNDMAXERRORS = "app.update.backgroundMaxErrors";
const PREF_APP_UPDATE_CERTS_BRANCH = "app.update.certs.";
const PREF_APP_UPDATE_CERT_CHECKATTRS = "app.update.cert.checkAttributes";
const PREF_APP_UPDATE_CERT_ERRORS = "app.update.cert.errors";
@ -124,6 +126,7 @@ const ELEVATION_CANCELED = 9;
const CERT_ATTR_CHECK_FAILED_NO_UPDATE = 100;
const CERT_ATTR_CHECK_FAILED_HAS_UPDATE = 101;
const BACKGROUNDCHECK_MULTIPLE_FAILURES = 110;
const DOWNLOAD_CHUNK_SIZE = 300000; // bytes
const DOWNLOAD_BACKGROUND_INTERVAL = 600; // seconds
@ -1286,16 +1289,25 @@ UpdateService.prototype = {
LOG("UpdateService:notify:listener - error during background update: " +
update.statusText);
if (!update.errorCode ||
update.errorCode != CERT_ATTR_CHECK_FAILED_NO_UPDATE &&
update.errorCode != CERT_ATTR_CHECK_FAILED_HAS_UPDATE)
return;
var maxErrors;
var errCount;
if (update.errorCode == CERT_ATTR_CHECK_FAILED_NO_UPDATE ||
update.errorCode == CERT_ATTR_CHECK_FAILED_HAS_UPDATE) {
errCount = getPref("getIntPref", PREF_APP_UPDATE_CERT_ERRORS, 0);
errCount++;
Services.prefs.setIntPref(PREF_APP_UPDATE_CERT_ERRORS, errCount);
maxErrors = getPref("getIntPref", PREF_APP_UPDATE_CERT_MAXERRORS, 5);
}
else {
update.errorCode = BACKGROUNDCHECK_MULTIPLE_FAILURES;
errCount = getPref("getIntPref", PREF_APP_UPDATE_BACKGROUNDERRORS, 0);
errCount++;
Services.prefs.setIntPref(PREF_APP_UPDATE_BACKGROUNDERRORS, errCount);
maxErrors = getPref("getIntPref", PREF_APP_UPDATE_BACKGROUNDMAXERRORS,
10);
}
var errCount = getPref("getIntPref", PREF_APP_UPDATE_CERT_ERRORS, 0);
errCount++;
Services.prefs.setIntPref(PREF_APP_UPDATE_CERT_ERRORS, errCount);
if (errCount >= getPref("getIntPref", PREF_APP_UPDATE_CERT_MAXERRORS, 5)) {
if (errCount >= maxErrors) {
var prompter = Cc["@mozilla.org/updates/update-prompt;1"].
createInstance(Ci.nsIUpdatePrompt);
prompter.showUpdateError(update);
@ -2157,6 +2169,9 @@ Checker.prototype = {
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_ERRORS))
Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_ERRORS);
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_BACKGROUNDERRORS))
Services.prefs.clearUserPref(PREF_APP_UPDATE_BACKGROUNDERRORS);
// Tell the Update Service about the updates
this._callback.onCheckComplete(event.target, updates, updates.length);
}
@ -2834,7 +2849,8 @@ UpdatePrompt.prototype = {
}
if (update.errorCode == CERT_ATTR_CHECK_FAILED_NO_UPDATE ||
update.errorCode == CERT_ATTR_CHECK_FAILED_HAS_UPDATE) {
update.errorCode == CERT_ATTR_CHECK_FAILED_HAS_UPDATE ||
update.errorCode == BACKGROUNDCHECK_MULTIPLE_FAILURES) {
this._showUIWhenIdle(null, URI_UPDATE_PROMPT_DIALOG, null,
UPDATE_WINDOW_NAME, null, update);
return;

Просмотреть файл

@ -100,6 +100,7 @@ _CHROME_FILES = \
test_0132_check_invalidCertAttrs_hasUpdate.xul \
test_0141_notify_invalidCertAttrs_noUpdate.xul \
test_0142_notify_invalidCertAttrs_hasUpdate.xul \
test_0151_notify_backgroundCheckError.xul \
test_9999_cleanup.xul \
$(NULL)

Просмотреть файл

@ -25,8 +25,9 @@ const TESTS = [ {
pageid: PAGEID_CHECKING
}, {
pageid: PAGEID_ERROR_EXTRA,
extraDelayedCheckFunction: checkCertErrorPage,
extraDelayedCheckFunction: checkErrorExtraPage,
shouldBeHidden: false,
displayedTextElem: "errorCertCheckNoUpdateLabel",
buttonClick: "finish"
} ];

Просмотреть файл

@ -25,8 +25,9 @@ const TESTS = [ {
pageid: PAGEID_CHECKING
}, {
pageid: PAGEID_ERROR_EXTRA,
extraDelayedCheckFunction: checkCertErrorPage,
extraDelayedCheckFunction: checkErrorExtraPage,
shouldBeHidden: true,
displayedTextElem: "errorCertAttrHasUpdateLabel",
buttonClick: "finish"
} ];

Просмотреть файл

@ -23,8 +23,9 @@
const TESTS = [ {
pageid: PAGEID_ERROR_EXTRA,
extraDelayedCheckFunction: checkCertErrorPage,
extraDelayedCheckFunction: checkErrorExtraPage,
shouldBeHidden: false,
displayedTextElem: "errorCertCheckNoUpdateLabel",
buttonClick: "finish"
} ];
@ -39,7 +40,8 @@ function runTest() {
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url);
debugDump("Default Update URL: " + url);
certErrorsPrefObserver.init();
errorsPrefObserver.init(PREF_APP_UPDATE_CERT_ERRORS,
PREF_APP_UPDATE_CERT_MAXERRORS);
gAUS.notify(null);
}

Просмотреть файл

@ -23,8 +23,9 @@
const TESTS = [ {
pageid: PAGEID_ERROR_EXTRA,
extraDelayedCheckFunction: checkCertErrorPage,
extraDelayedCheckFunction: checkErrorExtraPage,
shouldBeHidden: true,
displayedTextElem: "errorCertAttrHasUpdateLabel",
buttonClick: "finish"
} ];
@ -40,7 +41,8 @@ function runTest() {
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url);
debugDump("Default Update URL: " + url);
certErrorsPrefObserver.init();
errorsPrefObserver.init(PREF_APP_UPDATE_CERT_ERRORS,
PREF_APP_UPDATE_CERT_MAXERRORS);
gAUS.notify(null);
}

Просмотреть файл

@ -0,0 +1,53 @@
<?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="Test notification when multiple background check errors occur (bug 595455)"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="runTestDefault();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<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_ERROR_EXTRA,
extraDelayedCheckFunction: checkErrorExtraPage,
shouldBeHidden: false,
displayedTextElem: "genericBackgroundErrorLabel",
buttonClick: "finish"
} ];
function runTest() {
debugDump("Entering runTest");
let url = URL_UPDATE + "?xmlMalformed=1";
setUpdateURLOverride(url);
debugDump("Update URL: " + url);
errorsPrefObserver.init(PREF_APP_UPDATE_BACKGROUNDERRORS,
PREF_APP_UPDATE_BACKGROUNDMAXERRORS);
gAUS.notify(null);
}
]]>
</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>

Просмотреть файл

@ -609,9 +609,10 @@ function checkPrefHasUserValue(aPrefHasValue) {
}
/**
* Checks whether the link is hidden (certificate attribute check error with an
* update) or not (certificate attribute check error without an update) on the
* errorcertcheck page and that the app.update.cert.errors preference does note
* Checks whether the link is hidden (general background update check error or
* a certificate attribute check error with an update) or not (certificate
* attribute check error without an update) on the errorextra page and that the
* app.update.cert.errors and app.update.backgroundErrors preferences do not
& have a user value.
*
* @param aShouldBeHidden (optional)
@ -619,16 +620,23 @@ function checkPrefHasUserValue(aPrefHasValue) {
* aShouldBeHidden is undefined the value of the current test's
* shouldBeHidden property will be used.
*/
function checkCertErrorPage(aShouldBeHidden) {
function checkErrorExtraPage(aShouldBeHidden) {
let shouldBeHidden = aShouldBeHidden === undefined ? gTest.shouldBeHidden
: aShouldBeHidden;
is(gWin.document.getElementById("errorCertAttrLinkLabel").hidden, shouldBeHidden,
"Checking errorCertAttrLinkLabel hidden attribute equals " +
is(gWin.document.getElementById("errorExtraLinkLabel").hidden, shouldBeHidden,
"Checking errorExtraLinkLabel hidden attribute equals " +
(shouldBeHidden ? "true" : "false"));
is(gWin.document.getElementById(gTest.displayedTextElem).hidden, false,
"Checking " + gTest.displayedTextElem + " should not be hidden");
ok(!Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_ERRORS),
"Preference " + PREF_APP_UPDATE_CERT_ERRORS + " should not have a " +
"user value");
ok(!Services.prefs.prefHasUserValue(PREF_APP_UPDATE_BACKGROUNDERRORS),
"Preference " + PREF_APP_UPDATE_BACKGROUNDERRORS + " should not have a " +
"user value");
}
/**
@ -786,10 +794,22 @@ function resetPrefs() {
Services.prefs.clearUserPref(PREF_APP_UPDATE_LOG);
}
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_ERRORS)) {
Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_ERRORS);
}
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_MAXERRORS)) {
Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_MAXERRORS);
}
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_BACKGROUNDERRORS)) {
Services.prefs.clearUserPref(PREF_APP_UPDATE_BACKGROUNDERRORS);
}
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_BACKGROUNDMAXERRORS)) {
Services.prefs.clearUserPref(PREF_APP_UPDATE_BACKGROUNDMAXERRORS);
}
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME)) {
Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME);
}
@ -1105,35 +1125,45 @@ function getUpdateWindow() {
}
/**
* Helper for certificate attribute check errors.
* Helper for background check errors.
*/
var certErrorsPrefObserver = {
var errorsPrefObserver = {
observedPref: null,
maxErrorPref: null,
/**
* Sets up the app.update.cert.errors preference observer and sets the
* app.update.cert.maxErrors preference.
* Sets up a preference observer and sets the associated maximum errors
* preference used for background notification.
*
* @param aMaxErrors
* @param aObservePref
* The preference to observe.
* @param aMaxErrorPref
* The maximum errors preference.
* @param aMaxErrorCount
* The value to set the app.update.cert.maxErrors preference to.
*/
init: function(aMaxErrors) {
let maxErrors = aMaxErrors ? aMaxErrors : 5;
Services.prefs.setIntPref(PREF_APP_UPDATE_CERT_MAXERRORS, maxErrors);
Services.prefs.addObserver(PREF_APP_UPDATE_CERT_ERRORS, this, false);
init: function(aObservePref, aMaxErrorPref, aMaxErrorCount) {
this.observedPref = aObservePref;
this.maxErrorPref = aMaxErrorPref;
let maxErrors = aMaxErrorCount ? aMaxErrorCount : 5;
Services.prefs.setIntPref(aMaxErrorPref, maxErrors);
Services.prefs.addObserver(aObservePref, this, false);
},
/**
* Preference observer for the app.update.cert.errors preference.
*/
observe: function XPI_observe(aSubject, aTopic, aData) {
if (aData == PREF_APP_UPDATE_CERT_ERRORS) {
let errCount = Services.prefs.getIntPref(PREF_APP_UPDATE_CERT_ERRORS);
let errMax = Services.prefs.getIntPref(PREF_APP_UPDATE_CERT_MAXERRORS);
if (aData == this.observedPref) {
let errCount = Services.prefs.getIntPref(this.observedPref);
let errMax = Services.prefs.getIntPref(this.maxErrorPref);
if (errCount >= errMax) {
debugDump("prefObserver - removing pref observer");
Services.prefs.removeObserver(PREF_APP_UPDATE_CERT_ERRORS, this);
debugDump("errorsPrefObserver - removing pref observer");
Services.prefs.removeObserver(this.observedPref, this);
}
else {
debugDump("prefObserver - notifying AUS");
debugDump("errorsPrefObserver - notifying AUS");
SimpleTest.executeSoon(function() {
gAUS.notify(null);
});

Просмотреть файл

@ -44,6 +44,8 @@ const AUS_Ci = Components.interfaces;
const AUS_Cr = Components.results;
const AUS_Cu = Components.utils;
const PREF_APP_UPDATE_BACKGROUNDERRORS = "app.update.backgroundErrors";
const PREF_APP_UPDATE_BACKGROUNDMAXERRORS = "app.update.backgroundMaxErrors";
const PREF_APP_UPDATE_CERTS_BRANCH = "app.update.certs.";
const PREF_APP_UPDATE_CERT_CHECKATTRS = "app.update.cert.checkAttributes";
const PREF_APP_UPDATE_CERT_ERRORS = "app.update.cert.errors";