diff --git a/toolkit/mozapps/update/content/updates.xul b/toolkit/mozapps/update/content/updates.xul index 140375b04d2d..561fe9ed03f1 100644 --- a/toolkit/mozapps/update/content/updates.xul +++ b/toolkit/mozapps/update/content/updates.xul @@ -191,7 +191,7 @@ - diff --git a/toolkit/mozapps/update/test/chrome/test_0083_error_patchApplyFailure_partial_complete.xul b/toolkit/mozapps/update/test/chrome/test_0083_error_patchApplyFailure_partial_complete.xul index b56de4a9f0f3..c03fe3104cc1 100644 --- a/toolkit/mozapps/update/test/chrome/test_0083_error_patchApplyFailure_partial_complete.xul +++ b/toolkit/mozapps/update/test/chrome/test_0083_error_patchApplyFailure_partial_complete.xul @@ -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); diff --git a/toolkit/mozapps/update/test/chrome/test_0084_error_patchApplyFailure_verify_failed.xul b/toolkit/mozapps/update/test/chrome/test_0084_error_patchApplyFailure_verify_failed.xul index 9b1055193965..653211801c6a 100644 --- a/toolkit/mozapps/update/test/chrome/test_0084_error_patchApplyFailure_verify_failed.xul +++ b/toolkit/mozapps/update/test/chrome/test_0084_error_patchApplyFailure_verify_failed.xul @@ -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); diff --git a/toolkit/mozapps/update/test/chrome/update.sjs b/toolkit/mozapps/update/test/chrome/update.sjs index 16465fa1020d..442523f99997 100644 --- a/toolkit/mozapps/update/test/chrome/update.sjs +++ b/toolkit/mozapps/update/test/chrome/update.sjs @@ -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 &&