Bug 548061 - Billboard should handle 404 (other errors?) for billboard better. r=dolske

This commit is contained in:
Robert Strong 2010-03-17 16:12:12 -07:00
Родитель f9208a9ad2
Коммит 8517a5a984
9 изменённых файлов: 351 добавлений и 24 удалений

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

@ -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;
},

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

@ -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);
]]></body>
</method>
<method name="onLoad">
<body><![CDATA[
var doc = this._content.contentDocument;
var type = this.getAttribute("remotetype");
if (!doc.body.hasAttribute(type)) {
this.onError();
return;
}
// The remote html can tell us to zoom out the page if the page
// will create scrollbars by adding a zoomOutToFit attribute to the
// body of the billboard's html. Since zooming out will not always

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

@ -155,7 +155,7 @@
<!-- note: the localized strings used by remotecontent are prefixed by the
id for the remotecontent (e.g. updateMoreInfoContentNotFound,
updateMoreInfoContentDownloading, etc.) -->
<remotecontent id="updateMoreInfoContent" flex="1"/>
<remotecontent id="updateMoreInfoContent" flex="1" remotetype="billboard"/>
</wizardpage>
<wizardpage id="license" pageid="license" next="downloading"
@ -167,7 +167,7 @@
<!-- note: the localized strings used by remotecontent are prefixed by
the id for the remotecontent (e.g. licenseContentNotFound,
licenseContentDownloading, etc.) -->
<remotecontent id="licenseContent" flex="1"/>
<remotecontent id="licenseContent" flex="1" remotetype="license"/>
<separator class="thin"/>
<radiogroup id="acceptDeclineLicense" align="start"
onselect="gLicensePage.onAcceptDeclineRadio();">

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

@ -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 \

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

@ -89,7 +89,7 @@ function test02() {
}
/**
* finished page
* no updates found page
*/
function test03() {
ok(true, "Entering test03 - finished page");

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

@ -0,0 +1,143 @@
<?xml version="1.0"?>
<!--
/* ***** 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
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert Strong <robert.bugzilla@gmail.com> (Original Author)
*
* 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 ***** */
-->
<?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 update checking wizard billboard and license without required attribute (bug 548061)"
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="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
<script type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
/**
* test preparation
*/
function test01() {
ok(true, "Entering test01 - test preparation");
removeUpdateDirsAndFiles();
reloadUpdateManagerData();
var queryString = "?showBillboard=1&showLicense=1&remoteNoTypeAttr=1&showDetails=1";
setUpdateURLOverride(URL_UPDATE + queryString);
gNextFunc = test02;
gPageId = PAGEID_CHECKING;
gUP.checkForUpdates();
}
/**
* updates checking page
*/
function test02() {
ok(true, "Entering test02 - updates checking page");
is(gDocElem.currentPage.pageid, PAGEID_CHECKING,
"Page ID should be " + PAGEID_CHECKING);
gNextFunc = test03;
gPageId = PAGEID_FOUND_BASIC;
// This page will automatically go to the updates found basic page after the
// billboard without the billboard attribute loads.
addPageShowListener();
}
/**
* updates found basic page
*/
function test03() {
ok(true, "Entering test03 - updates found basic page");
is(gDocElem.currentPage.pageid, PAGEID_FOUND_BASIC,
"Page ID should be " + PAGEID_FOUND_BASIC);
gNextFunc = test04;
gPageId = PAGEID_MANUAL_UPDATE;
addPageShowListener();
// go forward to the license page which will automatically go to the manual
// update page after the license without the license attribute loads.
gDocElem.getButton("next").click();
}
/**
* manual update page
*/
function test04(aEvent) {
ok(true, "Entering test04 - manual update page");
is(gDocElem.currentPage.pageid, PAGEID_MANUAL_UPDATE,
"Page ID should be " + PAGEID_MANUAL_UPDATE);
ok(gDocElem.getButton("extra1").hidden, "extra1 button should be hidden");
ok(gDocElem.getButton("extra1").disabled, "extra1 button should be disabled");
ok(gDocElem.getButton("extra2").hidden, "extra2 button should be hidden");
ok(gDocElem.getButton("extra2").disabled, "extra2 button should be disabled");
ok(gDocElem.getButton("back").hidden, "back button should be hidden");
ok(gDocElem.getButton("back").disabled, "back button should be disabled");
ok(gDocElem.getButton("next").hidden, "next button should not be hidden");
ok(gDocElem.getButton("next").disabled, "next button should not be disabled");
ok(!gDocElem.getButton("finish").hidden, "finish button should not be hidden");
ok(!gDocElem.getButton("finish").disabled, "finish button should not be disabled");
ok(gDocElem.getButton("cancel").hidden, "cancel button should be hidden");
ok(gDocElem.getButton("cancel").disabled, "cancel button should be disabled");
gNextFunc = finishTestDefault;
// exit by clicking the finish button
gDocElem.getButton("finish").click();
}
]]>
</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,131 @@
<?xml version="1.0"?>
<!--
/* ***** 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
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert Strong <robert.bugzilla@gmail.com> (Original Author)
*
* 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 ***** */
-->
<?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 update checking wizard billboard and license not found (bug 548061)"
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="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
<script type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
/**
* test preparation
*/
function test01() {
ok(true, "Entering test01 - test preparation");
removeUpdateDirsAndFiles();
reloadUpdateManagerData();
var queryString = "?billboard404=1&license404=1&showDetails=1";
setUpdateURLOverride(URL_UPDATE + queryString);
gNextFunc = test02;
gPageId = PAGEID_CHECKING;
gUP.checkForUpdates();
}
/**
* updates checking page
*/
function test02() {
ok(true, "Entering test02 - updates checking page");
is(gDocElem.currentPage.pageid, PAGEID_CHECKING,
"Page ID should be " + PAGEID_CHECKING);
gNextFunc = test03;
gPageId = PAGEID_FOUND_BASIC;
// This page will automatically go to the updates found basic page after the
// billboard without the billboard attribute loads.
addPageShowListener();
}
/**
* updates found basic page
*/
function test03() {
ok(true, "Entering test03 - updates found basic page");
is(gDocElem.currentPage.pageid, PAGEID_FOUND_BASIC,
"Page ID should be " + PAGEID_FOUND_BASIC);
gNextFunc = test04;
gPageId = PAGEID_MANUAL_UPDATE;
addPageShowListener();
// go forward to the license page which will automatically go to the manual
// update page after the license without the license attribute loads.
gDocElem.getButton("next").click();
}
/**
* manual update page
*/
function test04(aEvent) {
ok(true, "Entering test04 - manual update page");
is(gDocElem.currentPage.pageid, PAGEID_MANUAL_UPDATE,
"Page ID should be " + PAGEID_MANUAL_UPDATE);
gNextFunc = finishTestDefault;
// exit by clicking the finish button
gDocElem.getButton("finish").click();
}
]]>
</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>

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

@ -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("<html><head><meta http-equiv=\"content-type\" content=" +
"\"text/html; charset=utf-8\"></head><body>" + uiURL +
"\"text/html; charset=utf-8\"></head><body" +
remoteType + ">" + params.uiURL +
"<br><br>this is a test mar that will not affect your " +
"build.</body></html>");
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 += "&amp;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 += "&amp;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;

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

@ -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