diff --git a/toolkit/mozapps/update/content/updates.js b/toolkit/mozapps/update/content/updates.js index 48a1a27099fb..fd4d80ad2237 100644 --- a/toolkit/mozapps/update/content/updates.js +++ b/toolkit/mozapps/update/content/updates.js @@ -73,6 +73,7 @@ const SRCEVT_BACKGROUND = 2; var gConsole = null; var gPref = null; var gLogEnabled = false; +var gUpdatesFoundPageId; // Notes: // 1. use the wizard's goTo method whenever possible to change the wizard @@ -525,9 +526,10 @@ var gUpdates = { * on the update's metadata. */ get updatesFoundPageId() { - delete this.updatesFoundPageId; - return this.updatesFoundPageId = this.update.billboardURL ? "updatesfoundbillboard" - : "updatesfoundbasic"; + if (gUpdatesFoundPageId) + return gUpdatesFoundPageId; + return gUpdatesFoundPageId = this.update.billboardURL ? "updatesfoundbillboard" + : "updatesfoundbasic"; }, /** @@ -596,6 +598,9 @@ var gCheckingPage = { if (gUpdates.update) { LOG("gCheckingPage", "onCheckComplete - update found"); if (!aus.canApplyUpdates) { + // Prevent multiple notifications for the same update when the user is + // unable to apply updates. + gUpdates.never(); gUpdates.wiz.goTo("manualUpdate"); return; } @@ -837,10 +842,6 @@ var gManualUpdatePage = { manualUpdateLinkLabel.value = manualURL; manualUpdateLinkLabel.setAttribute("url", manualURL); - // Prevent multiple notifications for the same update when the user is - // unable to apply updates. - gUpdates.never(); - gUpdates.setButtons(null, null, "okButton", true); gUpdates.wiz.getButton("finish").focus(); } @@ -929,6 +930,9 @@ var gUpdatesFoundBillboardPage = { return; var remoteContent = document.getElementById("updateMoreInfoContent"); + remoteContent.addEventListener("load", + gUpdatesFoundBillboardPage.onBillboardLoad, + false); // update_name and update_version need to be set before url // so that when attempting to download the url, we can show // the formatted "Download..." string @@ -959,6 +963,25 @@ var gUpdatesFoundBillboardPage = { this._billboardLoaded = true; }, + /** + * When the billboard document has loaded + */ + onBillboardLoad: function(aEvent) { + var remoteContent = document.getElementById("updateMoreInfoContent"); + // Note: may be called multiple times due to multiple onLoad events. + var state = remoteContent.getAttribute("state"); + if (state == "loading" || !aEvent.originalTarget.isSameNode(remoteContent)) + return; + + remoteContent.removeEventListener("load", gUpdatesFoundBillboardPage.onBillboardLoad, false); + if (state == "error") { + gUpdatesFoundPageId = "updatesfoundbasic"; + var next = gUpdates.wiz.getPageById("updatesfoundbillboard").getAttribute("next"); + gUpdates.wiz.getPageById(gUpdates.updatesFoundPageId).setAttribute("next", next); + gUpdates.wiz.goTo(gUpdates.updatesFoundPageId); + } + }, + onExtra1: function() { this.onWizardCancel(); gUpdates.later(); @@ -1028,20 +1051,24 @@ var gLicensePage = { /** * When the license document has loaded */ - onLicenseLoad: function() { + onLicenseLoad: function(aEvent) { var licenseContent = document.getElementById("licenseContent"); // Disable or enable the radiogroup based on the state attribute of // licenseContent. // Note: may be called multiple times due to multiple onLoad events. var state = licenseContent.getAttribute("state"); - if (state == "loading") + if (state == "loading" || !aEvent.originalTarget.isSameNode(licenseContent)) return; licenseContent.removeEventListener("load", gLicensePage.onLicenseLoad, false); - var errorLoading = (state == "error"); - document.getElementById("acceptDeclineLicense").disabled = errorLoading; - gLicensePage._licenseLoaded = !errorLoading; + if (state == "error") { + gUpdates.wiz.goTo("manualUpdate"); + return; + } + + gLicensePage._licenseLoaded = true; + document.getElementById("acceptDeclineLicense").disabled = false; gUpdates.wiz.getButton("extra1").disabled = false; }, diff --git a/toolkit/mozapps/update/content/updates.xml b/toolkit/mozapps/update/content/updates.xml index 296b7f0aa849..e812cf049fb0 100644 --- a/toolkit/mozapps/update/content/updates.xml +++ b/toolkit/mozapps/update/content/updates.xml @@ -78,11 +78,20 @@ [this.update_name]); this._setMessageValue(statusText); this.setAttribute("state", "error"); + var e = document.createEvent("Events"); + e.initEvent("load", false, true); + this.dispatchEvent(e); ]]> - + - + diff --git a/toolkit/mozapps/update/test/chrome/Makefile.in b/toolkit/mozapps/update/test/chrome/Makefile.in index b061a85af598..f13e380683c5 100644 --- a/toolkit/mozapps/update/test/chrome/Makefile.in +++ b/toolkit/mozapps/update/test/chrome/Makefile.in @@ -58,6 +58,8 @@ _CHROME_FILES = \ test_0042_available_noBillboard_noAddons.xul \ test_0051_check_error_xml_malformed.xul \ test_0052_check_no_updates.xul \ + test_0053_check_billboard_license_noAttr.xul \ + test_0054_check_billboard_license_404.xul \ test_0081_error_patchApplyFailure_partial_only.xul \ test_0082_error_patchApplyFailure_complete_only.xul \ test_0083_error_patchApplyFailure_partial_complete.xul \ diff --git a/toolkit/mozapps/update/test/chrome/test_0052_check_no_updates.xul b/toolkit/mozapps/update/test/chrome/test_0052_check_no_updates.xul index ec69487eed0d..1523c98df9ec 100644 --- a/toolkit/mozapps/update/test/chrome/test_0052_check_no_updates.xul +++ b/toolkit/mozapps/update/test/chrome/test_0052_check_no_updates.xul @@ -89,7 +89,7 @@ function test02() { } /** - * finished page + * no updates found page */ function test03() { ok(true, "Entering test03 - finished page"); diff --git a/toolkit/mozapps/update/test/chrome/test_0053_check_billboard_license_noAttr.xul b/toolkit/mozapps/update/test/chrome/test_0053_check_billboard_license_noAttr.xul new file mode 100644 index 000000000000..0098334ed2b9 --- /dev/null +++ b/toolkit/mozapps/update/test/chrome/test_0053_check_billboard_license_noAttr.xul @@ -0,0 +1,143 @@ + + + + + + + + + + +

+ +

+
+
diff --git a/toolkit/mozapps/update/test/chrome/test_0054_check_billboard_license_404.xul b/toolkit/mozapps/update/test/chrome/test_0054_check_billboard_license_404.xul new file mode 100644 index 000000000000..f594fc484ce0 --- /dev/null +++ b/toolkit/mozapps/update/test/chrome/test_0054_check_billboard_license_404.xul @@ -0,0 +1,131 @@ + + + + + + + + + + +

+ +

+
+
diff --git a/toolkit/mozapps/update/test/chrome/update.sjs b/toolkit/mozapps/update/test/chrome/update.sjs index 93ad7706ae80..16465fa1020d 100644 --- a/toolkit/mozapps/update/test/chrome/update.sjs +++ b/toolkit/mozapps/update/test/chrome/update.sjs @@ -10,21 +10,28 @@ const SERVICE_URL = URL_HOST + URL_PATH + "empty.mar"; function handleRequest(request, response) { - response.setStatusLine(request.httpVersion, 200, "OK"); + var params = { }; + if (request.queryString) + params = parseQueryString(request.queryString); + + var statusCode = params.statusCode ? parseInt(params.statusCode) : 200; + var statusReason = params.statusReason ? params.statusReason : "OK"; + response.setStatusLine(request.httpVersion, statusCode, statusReason); response.setHeader("Cache-Control", "no-cache", false); - if (request.queryString.match(/^uiURL=/)) { - var uiURL = decodeURIComponent(request.queryString.substring(6)); + + if (params.uiURL) { + var remoteType = ""; + if (!params.remoteNoTypeAttr && + (params.uiURL == "BILLBOARD" || params.uiURL == "LICENSE")) + remoteType = " " + params.uiURL.toLowerCase() + "=\"1\""; response.write("" + uiURL + + "\"text/html; charset=utf-8\">" + params.uiURL + "

this is a test mar that will not affect your " + "build."); return; } - var params = { }; - if (request.queryString) - params = parseQueryString(request.queryString); - if (params.xmlMalformed) { response.write("xml error"); return; @@ -51,7 +58,15 @@ function handleRequest(request, response) { // var detailsURL = params.showDetails ? URL_UPDATE + "?uiURL=DETAILS" : null; var detailsURL = URL_UPDATE + "?uiURL=DETAILS"; var billboardURL = params.showBillboard ? URL_UPDATE + "?uiURL=BILLBOARD" : null; + if (billboardURL && params.remoteNoTypeAttr) + billboardURL += "&remoteNoTypeAttr=1"; + if (params.billboard404) + billboardURL = URL_HOST + URL_PATH + "missing.html" var licenseURL = params.showLicense ? URL_UPDATE + "?uiURL=LICENSE" : null; + if (licenseURL && params.remoteNoTypeAttr) + licenseURL += "&remoteNoTypeAttr=1"; + if (params.license404) + licenseURL = URL_HOST + URL_PATH + "missing.html" var showPrompt = params.showPrompt ? "true" : null; var showNever = params.showNever ? "true" : null; var showSurvey = params.showSurvey ? "true" : null; diff --git a/toolkit/mozapps/update/test/chrome/utils.js b/toolkit/mozapps/update/test/chrome/utils.js index 2d7ecd3047a6..16b6a02ae1f1 100644 --- a/toolkit/mozapps/update/test/chrome/utils.js +++ b/toolkit/mozapps/update/test/chrome/utils.js @@ -41,7 +41,7 @@ const PAGEID_CHECKING = "checking"; // Done const PAGEID_PLUGIN_UPDATES = "pluginupdatesfound"; const PAGEID_NO_UPDATES_FOUND = "noupdatesfound"; // Done -const PAGEID_MANUAL_UPDATE = "manualUpdate"; // Can't test? Requires restricted access +const PAGEID_MANUAL_UPDATE = "manualUpdate"; // Tested on license load failure const PAGEID_INCOMPAT_CHECK = "incompatibleCheck"; // Bug 546595 const PAGEID_FOUND_BASIC = "updatesfoundbasic"; // Done const PAGEID_FOUND_BILLBOARD = "updatesfoundbillboard"; // Done