Bug 554561 - Failed partial not handled properly in UI. r=dtownsend

This commit is contained in:
Robert Strong 2010-03-25 21:37:06 -07:00
parent 2d1f0ba03a
commit 00365c20d2
4 changed files with 72 additions and 17 deletions

View file

@ -191,7 +191,7 @@
</vbox>
</wizardpage>
<wizardpage id="downloading" pageid="downloading" next="finished"
<wizardpage id="downloading" pageid="downloading"
object="gDownloadingPage" onextra1="gDownloadingPage.onHide();"
onpageshow="gDownloadingPage.onPageShow();">
<updateheader label="&downloadPage.title;"/>

View file

@ -62,9 +62,12 @@ SimpleTest.waitForExplicitFinish();
function test01() {
ok(true, "Entering test01 - test preparation");
// Specify the url to update.sjs with a slowDownloadMar param so the ui can
// load before the download completes.
var slowDownloadURL = URL_UPDATE + "?slowDownloadMar=1";
var patches = getLocalPatchString("partial", null, null, null, null, null,
STATE_PENDING) +
getLocalPatchString("complete");
getLocalPatchString("complete", slowDownloadURL);
var updates = getLocalUpdateString(patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
@ -100,20 +103,32 @@ function test02() {
ok(gDocElem.getButton("cancel").disabled, "cancel button should be disabled");
gNextFunc = test03;
gPageId = PAGEID_DOWNLOADING;
addPageShowListener();
// go forward to the downloading page
gDocElem.getButton("next").click();
}
/**
* downloading page
*/
function test03() {
ok(true, "Entering test12 - downloading page");
is(gDocElem.currentPage.pageid, PAGEID_DOWNLOADING,
"Page ID should be " + PAGEID_DOWNLOADING);
gNextFunc = test04;
gPageId = PAGEID_FINISHED;
addPageShowListener();
// Clicking next will immediately go forward to the finished page if the
// download has already finished or it will go to downloading page and then
// automatically go forward to the finished page after the download has
// finished.
gDocElem.getButton("next").click();
// The downloading page will automatically go to the finish page.
}
/**
* finished page
*/
function test03() {
ok(true, "Entering test03 - finished page");
function test04() {
ok(true, "Entering test04 - finished page");
is(gDocElem.currentPage.pageid, PAGEID_FINISHED,
"Page ID should be " + PAGEID_FINISHED);

View file

@ -62,9 +62,12 @@ SimpleTest.waitForExplicitFinish();
function test01() {
ok(true, "Entering test01 - test preparation");
// Specify the url to update.sjs with a slowDownloadMar param so the ui can
// load before the download completes.
var slowDownloadURL = URL_UPDATE + "?slowDownloadMar=1";
var patches = getLocalPatchString("partial", null, null, null, null, null,
STATE_PENDING) +
getLocalPatchString("complete", null, "MD5",
getLocalPatchString("complete", slowDownloadURL, "MD5",
"1234cd43a1c77e30191c53a329a3f99d");
var updates = getLocalUpdateString(patches);
@ -102,20 +105,32 @@ function test02() {
ok(gDocElem.getButton("cancel").disabled, "cancel button should be disabled");
gNextFunc = test03;
gPageId = PAGEID_DOWNLOADING;
addPageShowListener();
// go forward to the downloading page
gDocElem.getButton("next").click();
}
/**
* downloading page
*/
function test03() {
ok(true, "Entering test12 - downloading page");
is(gDocElem.currentPage.pageid, PAGEID_DOWNLOADING,
"Page ID should be " + PAGEID_DOWNLOADING);
gNextFunc = test04;
gPageId = PAGEID_ERRORS;
addPageShowListener();
// Clicking next will go forward to the finished page if the download has
// already finished or it will go to the downloading page and then
// automatically go forward to the finished page after the download has
// finished.
gDocElem.getButton("next").click();
// The downloading page will automatically go to the errors page.
}
/**
* errors page
*/
function test03() {
ok(true, "Entering test03 - errors page");
function test04() {
ok(true, "Entering test04 - errors page");
is(gDocElem.currentPage.pageid, PAGEID_ERRORS,
"Page ID should be " + PAGEID_ERRORS);

View file

@ -19,6 +19,31 @@ function handleRequest(request, response) {
response.setStatusLine(request.httpVersion, statusCode, statusReason);
response.setHeader("Cache-Control", "no-cache", false);
// When a mar download is started by the update service it can finish
// downloading before the ui has loaded. By specifying a serviceURL for the
// update patch that points to this file and has a slowDownloadMar param the
// mar will be downloaded asynchronously which will allow the ui to load
// before the download completes.
if (params.slowDownloadMar) {
response.processAsync();
response.setHeader("Content-Length", "775");
var marFile = AUS_Cc["@mozilla.org/file/directory_service;1"].
getService(AUS_Ci.nsIProperties).
get("CurWorkD", AUS_Ci.nsILocalFile);
var path = URL_PATH + "empty.mar";
var pathParts = path.split("/");
for(var i = 0; i < pathParts.length; ++i)
marFile.append(pathParts[i]);
var contents = readFileBytes(marFile);
var timer = AUS_Cc["@mozilla.org/timer;1"].
createInstance(AUS_Ci.nsITimer);
timer.initWithCallback(function() {
response.write(contents);
response.finish();
}, 2000, AUS_Ci.nsITimer.TYPE_ONE_SHOT);
return;
}
if (params.uiURL) {
var remoteType = "";
if (!params.remoteNoTypeAttr &&