зеркало из https://github.com/mozilla/gecko-dev.git
Bug 648485 - Second try to fix intermittent failure in content/base/test/test_bug482935.html. r=ehsan
This commit is contained in:
Родитель
d632db752b
Коммит
2ed08c1c21
|
@ -29,25 +29,30 @@ function testCancelInPhase4() {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.addEventListener("readystatechange", function(e) {
|
xhr.addEventListener("readystatechange", function(e) {
|
||||||
if (xhr.readyState >= 4) {
|
if (xhr.readyState >= 4) {
|
||||||
|
xhr.addEventListener("abort", function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
// This request was cancelled, so the responseText should be empty string
|
||||||
|
is(xhr.responseText, "", "Expected empty response to cancelled request");
|
||||||
|
|
||||||
|
// Second request - should be found in cache
|
||||||
|
var xhr2 = new XMLHttpRequest();
|
||||||
|
|
||||||
|
xhr2.addEventListener("load", function() {
|
||||||
|
is(xhr2.responseText, "0", "Received fresh value for second request");
|
||||||
|
testCancelBeforePhase4();
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
xhr2.open("GET", url, false); // note : synch-request
|
||||||
|
xhr2.setRequestHeader("X-Request", "1", false);
|
||||||
|
|
||||||
|
try { xhr2.send(); }
|
||||||
|
catch(e) {
|
||||||
|
is(xhr2.status, "200", "Exception!");
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
}, false);
|
||||||
|
|
||||||
xhr.abort();
|
xhr.abort();
|
||||||
SimpleTest.executeSoon(function() {
|
|
||||||
// This request was cancelled, so the responseText should be empty string
|
|
||||||
is(xhr.responseText, "", "Expected empty response to cancelled request");
|
|
||||||
|
|
||||||
// Second request - should be found in cache
|
|
||||||
var xhr2 = new XMLHttpRequest();
|
|
||||||
xhr2.open("GET", url, false); // note : synch-request
|
|
||||||
xhr2.setRequestHeader("X-Request", "1", false);
|
|
||||||
|
|
||||||
try { xhr2.send(); }
|
|
||||||
catch(e) {
|
|
||||||
is(xhr2.status, "200", "Exception!");
|
|
||||||
}
|
|
||||||
|
|
||||||
is(xhr2.responseText, "0", "Received fresh value for second request");
|
|
||||||
|
|
||||||
testCancelBeforePhase4();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
@ -69,25 +74,30 @@ function testCancelBeforePhase4() {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.addEventListener("readystatechange", function(e) {
|
xhr.addEventListener("readystatechange", function(e) {
|
||||||
if (xhr.readyState == 3) {
|
if (xhr.readyState == 3) {
|
||||||
|
xhr.addEventListener("abort", function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
// This request was cancelled, so the responseText should be empty string
|
||||||
|
is(xhr.responseText, "", "Expected empty response to cancelled request");
|
||||||
|
|
||||||
|
// Second request - should be found in cache
|
||||||
|
var xhr2 = new XMLHttpRequest();
|
||||||
|
|
||||||
|
xhr2.addEventListener("load", function() {
|
||||||
|
is(xhr2.responseText, "1", "Received cached value for second request");
|
||||||
|
SimpleTest.finish();
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
xhr2.open("GET", url, false); // note : synch-request
|
||||||
|
xhr2.setRequestHeader("X-Request", "1", false);
|
||||||
|
|
||||||
|
try { xhr2.send(); }
|
||||||
|
catch(e) {
|
||||||
|
is(xhr2.status, "200", "Exception!");
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
}, false);
|
||||||
|
|
||||||
xhr.abort();
|
xhr.abort();
|
||||||
SimpleTest.executeSoon(function() {
|
|
||||||
// This request was cancelled, so the responseText should be empty string
|
|
||||||
is(xhr.responseText, "", "Expected empty response to cancelled request");
|
|
||||||
|
|
||||||
// Second request - should be found in cache
|
|
||||||
var xhr2 = new XMLHttpRequest();
|
|
||||||
xhr2.open("GET", url, false); // note : synch-request
|
|
||||||
xhr2.setRequestHeader("X-Request", "1", false);
|
|
||||||
|
|
||||||
try { xhr2.send(); }
|
|
||||||
catch(e) {
|
|
||||||
is(xhr2.status, "200", "Exception!");
|
|
||||||
}
|
|
||||||
|
|
||||||
is(xhr2.responseText, "1", "Received cached value for second request");
|
|
||||||
|
|
||||||
SimpleTest.finish();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче