зеркало из https://github.com/mozilla/gecko-dev.git
Bug 669913 - Viewing Sync quota blocks the entire Options window. r=rnewman
Part 0: SyncStorageRequest's method should return the request object, onStartRequest should not try to process data from an aborted request.
This commit is contained in:
Родитель
ee3fc8cbda
Коммит
ad244ff27f
|
@ -606,11 +606,14 @@ SyncStorageRequest.prototype = {
|
||||||
this._log.debug("Couldn't set Authentication header: WeaveID not found.");
|
this._log.debug("Couldn't set Authentication header: WeaveID not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
RESTRequest.prototype.dispatch.apply(this, arguments);
|
return RESTRequest.prototype.dispatch.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
onStartRequest: function onStartRequest(channel) {
|
onStartRequest: function onStartRequest(channel) {
|
||||||
RESTRequest.prototype.onStartRequest.call(this, channel);
|
RESTRequest.prototype.onStartRequest.call(this, channel);
|
||||||
|
if (this.status == this.ABORTED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let headers = this.response.headers;
|
let headers = this.response.headers;
|
||||||
// Save the latest server timestamp when possible.
|
// Save the latest server timestamp when possible.
|
||||||
|
|
|
@ -23,12 +23,13 @@ add_test(function test_user_agent_desktop() {
|
||||||
Services.appinfo.appBuildID + ".desktop";
|
Services.appinfo.appBuildID + ".desktop";
|
||||||
|
|
||||||
let request = new SyncStorageRequest("http://localhost:8080/resource");
|
let request = new SyncStorageRequest("http://localhost:8080/resource");
|
||||||
request.get(function (error) {
|
request.onComplete = function onComplete(error) {
|
||||||
do_check_eq(error, null);
|
do_check_eq(error, null);
|
||||||
do_check_eq(this.response.status, 200);
|
do_check_eq(this.response.status, 200);
|
||||||
do_check_eq(handler.request.getHeader("User-Agent"), expectedUA);
|
do_check_eq(handler.request.getHeader("User-Agent"), expectedUA);
|
||||||
server.stop(run_next_test);
|
server.stop(run_next_test);
|
||||||
});
|
};
|
||||||
|
do_check_eq(request.get(), request);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_test(function test_user_agent_mobile() {
|
add_test(function test_user_agent_mobile() {
|
||||||
|
@ -86,6 +87,7 @@ add_test(function test_weave_timestamp() {
|
||||||
do_check_eq(error, null);
|
do_check_eq(error, null);
|
||||||
do_check_eq(this.response.status, 200);
|
do_check_eq(this.response.status, 200);
|
||||||
do_check_eq(SyncStorageRequest.serverTime, TIMESTAMP);
|
do_check_eq(SyncStorageRequest.serverTime, TIMESTAMP);
|
||||||
|
delete SyncStorageRequest.serverTime;
|
||||||
server.stop(run_next_test);
|
server.stop(run_next_test);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -165,3 +167,47 @@ add_test(function test_weave_quota_error() {
|
||||||
server.stop(run_next_test);
|
server.stop(run_next_test);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
add_test(function test_abort() {
|
||||||
|
function handler(request, response) {
|
||||||
|
response.setHeader("X-Weave-Timestamp", "" + TIMESTAMP, false);
|
||||||
|
response.setHeader("X-Weave-Quota-Remaining", '1048576', false);
|
||||||
|
response.setHeader("X-Weave-Backoff", '600', false);
|
||||||
|
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||||
|
}
|
||||||
|
let server = httpd_setup({"/resource": handler});
|
||||||
|
|
||||||
|
let request = new SyncStorageRequest("http://localhost:8080/resource");
|
||||||
|
|
||||||
|
// Aborting a request that hasn't been sent yet is pointless and will throw.
|
||||||
|
do_check_throws(function () {
|
||||||
|
request.abort();
|
||||||
|
});
|
||||||
|
|
||||||
|
function throwy() {
|
||||||
|
do_throw("Shouldn't have gotten here!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Svc.Obs.add("weave:service:backoff:interval", throwy);
|
||||||
|
Svc.Obs.add("weave:service:quota:remaining", throwy);
|
||||||
|
request.onProgress = request.onComplete = throwy;
|
||||||
|
|
||||||
|
request.get();
|
||||||
|
request.abort();
|
||||||
|
do_check_eq(request.status, request.ABORTED);
|
||||||
|
|
||||||
|
// Aborting an already aborted request is pointless and will throw.
|
||||||
|
do_check_throws(function () {
|
||||||
|
request.abort();
|
||||||
|
});
|
||||||
|
|
||||||
|
Utils.nextTick(function () {
|
||||||
|
// Verify that we didn't try to process any of the values.
|
||||||
|
do_check_eq(SyncStorageRequest.serverTime, undefined);
|
||||||
|
|
||||||
|
Svc.Obs.remove("weave:service:backoff:interval", throwy);
|
||||||
|
Svc.Obs.remove("weave:service:quota:remaining", throwy);
|
||||||
|
|
||||||
|
server.stop(run_next_test);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче