Backed out changeset 1e8f83c69e80 (bug 941317) for test failures in B2g Desktop Linux & B2G ICS Emulator Opt

This commit is contained in:
Carsten "Tomcat" Book 2013-12-03 12:53:17 +01:00
Родитель 59349f90ed
Коммит 4deaf8d917
8 изменённых файлов: 47 добавлений и 92 удалений

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

@ -63,7 +63,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm")
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
"resource://gre/modules/commonjs/sdk/core/promise.js");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
@ -408,48 +408,27 @@ this.Download.prototype = {
}
}
// In case the download was restarted while cancellation was in progress,
// but the previous attempt actually succeeded before cancellation could
// be processed, it is possible that the download has already finished.
if (this.succeeded) {
return;
}
try {
// Disallow download if parental controls service restricts it.
if (yield DownloadIntegration.shouldBlockForParentalControls(this)) {
throw new DownloadError({ becauseBlockedByParentalControls: true });
}
// We should check if we have been canceled in the meantime, after all
// the previous asynchronous operations have been executed and just
// before we call the "execute" method of the saver.
if (this._promiseCanceled) {
// The exception will become a cancellation in the "catch" block.
throw undefined;
}
// Execute the actual download through the saver object.
this._saverExecuting = true;
yield this.saver.execute(DS_setProgressBytes.bind(this),
DS_setProperties.bind(this));
// Check for application reputation, which requires the entire file to
// be downloaded. After that, check for the last time if the download
// has been canceled. Both cases require the target file to be deleted,
// thus we process both in the same block of code.
if ((yield DownloadIntegration.shouldBlockForReputationCheck(this)) ||
this._promiseCanceled) {
// be downloaded.
if (yield DownloadIntegration.shouldBlockForReputationCheck(this)) {
// Delete the target file that BackgroundFileSaver already moved
// into place.
try {
yield OS.File.remove(this.target.path);
} catch (ex) {
Cu.reportError(ex);
}
// If this is actually a cancellation, this exception will be changed
// in the catch block below.
throw new DownloadError({ becauseBlockedByReputationCheck: true });
}
// Update the status properties for a successful download.
this.progress = 100;
this.succeeded = true;
@ -479,7 +458,6 @@ this.Download.prototype = {
throw ex;
} finally {
// Any cancellation request has now been processed.
this._saverExecuting = false;
this._promiseCanceled = null;
// Update the status properties, unless a new attempt already started.
@ -565,12 +543,6 @@ this.Download.prototype = {
*/
_promiseCanceled: null,
/**
* True between the call to the "execute" method of the saver and the
* completion of the current download attempt.
*/
_saverExecuting: false,
/**
* Cancels the download.
*
@ -614,12 +586,8 @@ this.Download.prototype = {
this.canceled = true;
this._notifyChange();
// Execute the actual cancellation through the saver object, in case it
// has already started. Otherwise, the cancellation will be handled just
// before the saver is started.
if (this._saverExecuting) {
this.saver.cancel();
}
// Execute the actual cancellation through the saver object.
this.saver.cancel();
}
return this._promiseCanceled;
@ -1392,6 +1360,31 @@ this.DownloadSaver.prototype = {
targetUri);
},
/**
* Return true if the request's response has been blocked by Windows parental
* controls with an HTTP 450 error code.
*
* @param aRequest
* nsIRequest object
* @return True if the response is blocked.
*/
isResponseParentalBlocked: function(aRequest)
{
// If the HTTP status is 450, then Windows Parental Controls have
// blocked this download.
if (aRequest instanceof Ci.nsIHttpChannel &&
aRequest.responseStatus == 450) {
// Cancel the request, but set a flag on the download that can be
// retrieved later when handling the cancellation so that the proper
// blocked by parental controls error can be thrown.
this.download._blockedByParentalControls = true;
aRequest.cancel(Cr.NS_BINDING_ABORTED);
return true;
}
return false;
},
/**
* Returns a static representation of the current object state.
*
@ -1603,14 +1596,7 @@ this.DownloadCopySaver.prototype = {
onStartRequest: function (aRequest, aContext) {
backgroundFileSaver.onStartRequest(aRequest, aContext);
// Check if the request's response has been blocked by Windows
// Parental Controls with an HTTP 450 error code.
if (aRequest instanceof Ci.nsIHttpChannel &&
aRequest.responseStatus == 450) {
// Set a flag that can be retrieved later when handling the
// cancellation so that the proper error can be thrown.
this.download._blockedByParentalControls = true;
aRequest.cancel(Cr.NS_BINDING_ABORTED);
if (this.isResponseParentalBlocked(aRequest)) {
return;
}
@ -1703,13 +1689,6 @@ this.DownloadCopySaver.prototype = {
}.bind(copySaver),
}, null);
// We should check if we have been canceled in the meantime, after
// all the previous asynchronous operations have been executed and
// just before we set the _backgroundFileSaver property.
if (this._canceled) {
throw new DownloadError({ message: "Saver canceled." });
}
// If the operation succeeded, store the object to allow cancellation.
this._backgroundFileSaver = backgroundFileSaver;
} catch (ex) {
@ -1918,6 +1897,10 @@ this.DownloadLegacySaver.prototype = {
ex.result == Cr.NS_ERROR_NOT_RESUMABLE) { }
}
if (this.isResponseParentalBlocked(aRequest)) {
return;
}
// For legacy downloads, we must update the referrer at this time.
if (aRequest instanceof Ci.nsIHttpChannel && aRequest.referrer) {
this.download.source.referrer = aRequest.referrer.spec;

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

@ -46,7 +46,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
#endif
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
"resource://gre/modules/commonjs/sdk/core/promise.js");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",

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

@ -29,7 +29,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
"resource://gre/modules/Downloads.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
"resource://gre/modules/commonjs/sdk/core/promise.js");
////////////////////////////////////////////////////////////////////////////////
//// DownloadLegacyTransfer
@ -89,25 +89,9 @@ DownloadLegacyTransfer.prototype = {
if ((aStateFlags & Ci.nsIWebProgressListener.STATE_START) &&
(aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK)) {
// If the request's response has been blocked by Windows Parental Controls
// with an HTTP 450 error code, we must cancel the request synchronously.
let blockedByParentalControls = aRequest instanceof Ci.nsIHttpChannel &&
aRequest.responseStatus == 450;
if (blockedByParentalControls) {
aRequest.cancel(Cr.NS_BINDING_ABORTED);
}
// The main request has just started. Wait for the associated Download
// object to be available before notifying.
this._deferDownload.promise.then(download => {
// If the request was blocked, now that we have the download object we
// should set a flag that can be retrieved later when handling the
// cancellation so that the proper error can be thrown.
if (blockedByParentalControls) {
download._blockedByParentalControls = true;
}
download.saver.onTransferStarted(
aRequest,
this._cancelable instanceof Ci.nsIHelperAppLauncher);
@ -133,9 +117,9 @@ DownloadLegacyTransfer.prototype = {
// The last file has been received, or the download failed. Wait for the
// associated Download object to be available before notifying.
this._deferDownload.promise.then(download => {
// At this point, the hash has been set and we need to copy it to the
// DownloadSaver.
if (Components.isSuccessCode(aStatus)) {
// At this point, the hash has been set and we need to copy it to the
// DownloadSaver.
if (Components.isSuccessCode(aStatus)) {
download.saver.setSha256Hash(this._sha256Hash);
}
download.saver.onTransferFinished(aRequest, aStatus);

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

@ -37,7 +37,7 @@ const Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
"resource://gre/modules/commonjs/sdk/core/promise.js");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");

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

@ -27,7 +27,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
"resource://gre/modules/commonjs/sdk/core/promise.js");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");

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

@ -36,7 +36,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "DownloadSummary",
XPCOMUtils.defineLazyModuleGetter(this, "DownloadUIHelper",
"resource://gre/modules/DownloadUIHelper.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
"resource://gre/modules/commonjs/sdk/core/promise.js");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");

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

@ -806,10 +806,7 @@ add_task(function test_cancel_immediately_restart_immediately()
continueResponses();
try {
yield promiseAttempt;
// If we get here, it means that the first attempt actually succeeded. In
// fact, this could be a valid outcome, because the cancellation request may
// not have been processed in time before the download finished.
do_print("The download should have been canceled.");
do_throw("The download should have been canceled.");
} catch (ex if ex instanceof Downloads.Error) {
do_check_false(ex.becauseSourceFailed);
do_check_false(ex.becauseTargetFailed);

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

@ -34,7 +34,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
"resource://gre/modules/commonjs/sdk/core/promise.js");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
@ -731,15 +731,6 @@ add_task(function test_common_initialize()
gHttpServer.registerDirectory("/", do_get_file("../data"));
gHttpServer.start(-1);
// Cache locks might prevent concurrent requests to the same resource, and
// this may block tests that use the interruptible handlers.
Services.prefs.setBoolPref("browser.cache.disk.enable", false);
Services.prefs.setBoolPref("browser.cache.memory.enable", false);
do_register_cleanup(function () {
Services.prefs.clearUserPref("browser.cache.disk.enable");
Services.prefs.clearUserPref("browser.cache.memory.enable");
});
registerInterruptibleHandler("/interruptible.txt",
function firstPart(aRequest, aResponse) {
aResponse.setHeader("Content-Type", "text/plain", false);