function runTest() { var testFunctions = [
startTest1,
startTest2,
startTest3,
];
function nextTest() {
if (!testFunctions.length) {
SimpleTest.finish();
return;
}
(testFunctions.shift())();
}
nextTest();
var xhr;
function startTest1() {
xhr = new XMLHttpRequest();
xhr.onload = onLoad1;
xhr.open("GET", url);
xhr.send();
}
function onLoad1() {
is(xhr.readyState, xhr.DONE, "readyState should be DONE");
xhr.onabort = onAbort1;
xhr.abort();
function onAbort1(e) {
ok(false, e.type + " event should not be fired!");
}
is(xhr.readyState, xhr.UNSENT, "readyState should be UNSENT");
nextTest();
}
function startTest2() {
xhr = new XMLHttpRequest();
xhr.onloadstart = onAfterSend;
xhr.open("GET", url);
xhr.send();
}
function startTest3() {
xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.send();
onAfterSend();
}
function onAfterSend() {
is(xhr.readyState, xhr.OPENED, "readyState should be OPENED"); var sent = false;
try {
xhr.send();
} catch (e) {
sent = true;
}
ok(sent, "send() flag should be set"); var aborted = false;
xhr.onabort = onAbort2;
xhr.abort();
function onAbort2() {
is(xhr.readyState, xhr.DONE, "readyState should be DONE");
aborted = true;
}
ok(aborted, "abort event should be fired");
is(xhr.readyState, xhr.UNSENT, "readyState should be UNSENT");
nextTest();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.