Bug 1938866 - Fix intermittent test_rcwn_interrupted.js r=necko-reviewers,sunil
I think this is intermittent if the second request (with RCWN) happens to be opened before the first one. In this change, we only open the second request in the onStartRequest of the first one, thus hopefully eliminating the race. Differential Revision: https://phabricator.services.mozilla.com/D246743
This commit is contained in:
@@ -49,7 +49,6 @@ const responseBody =
|
||||
|
||||
function contentHandler(metadata, response) {
|
||||
response.processAsync();
|
||||
do_timeout(500, () => {
|
||||
response.setHeader("Content-Type", "text/plain");
|
||||
response.setHeader("ETag", "Just testing");
|
||||
response.setHeader("Cache-Control", "max-age=99999");
|
||||
@@ -61,12 +60,33 @@ function contentHandler(metadata, response) {
|
||||
let len = responseBody.length;
|
||||
response.setHeader("Content-Range", "0-" + (len - 1) + "/" + len);
|
||||
}
|
||||
|
||||
do_timeout(500, () => {
|
||||
response.bodyOutputStream.write(responseBody, responseBody.length);
|
||||
|
||||
response.finish();
|
||||
});
|
||||
}
|
||||
|
||||
class CustomChannelListener extends ChannelListener {
|
||||
constructor(closure, ctx, flags) {
|
||||
super(closure, ctx, flags);
|
||||
|
||||
this._onStartPromise = new Promise(resolve => {
|
||||
this._onStartResolve = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
onStartRequest(request) {
|
||||
this._onStartResolve();
|
||||
|
||||
// Call the original ChannelListener's onStartRequest method
|
||||
if (typeof ChannelListener.prototype.onStartRequest === "function") {
|
||||
ChannelListener.prototype.onStartRequest.call(this, request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
// Static check
|
||||
Assert.ok(responseBody.length > 1024);
|
||||
@@ -82,9 +102,12 @@ function run_test() {
|
||||
|
||||
httpProtocolHandler.EnsureHSTSDataReady().then(function () {
|
||||
var chan1 = make_channel(URL + "/content");
|
||||
chan1.asyncOpen(
|
||||
new ChannelListener(firstTimeThrough, null, CL_IGNORE_DELAYS)
|
||||
let chan1listener = new CustomChannelListener(
|
||||
firstTimeThrough,
|
||||
null,
|
||||
CL_IGNORE_DELAYS
|
||||
);
|
||||
chan1listener._onStartPromise.then(() => {
|
||||
var chan2 = make_channel(URL + "/content");
|
||||
chan2
|
||||
.QueryInterface(Ci.nsIRaceCacheWithNetwork)
|
||||
@@ -94,6 +117,8 @@ function run_test() {
|
||||
new ChannelListener(secondTimeThrough, null, CL_IGNORE_DELAYS)
|
||||
);
|
||||
});
|
||||
chan1.asyncOpen(chan1listener);
|
||||
});
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user