mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
Update web-platform-tests to revision e8bfc205e36ad699601212cd50083870bad9a75d
This commit is contained in:
parent
65dd6d4340
commit
ccdb0a3458
1428 changed files with 118036 additions and 9786 deletions
|
@ -4,6 +4,7 @@
|
|||
<title>XMLHttpRequest: abort() after send()</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/xmlhttprequest-event-order.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-abort()-method" data-tested-assertations="following-sibling::ol/li[1] following-sibling::ol/li[3] following-sibling::ol/li[4] following-sibling::ol/li[4]/ol/li[1] following-sibling::ol/li[4]/ol/li[3] following-sibling::ol/li[4]/ol/li[4] following-sibling::ol/li[4]/ol/li[5] following-sibling::ol/li[4]/ol/li[6] following-sibling::ol/li[5]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-responsetext-attribute" data-tested-assertations="following::ol/li[3]" />
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-responsexml-attribute" data-tested-assertations="following::ol/li[3]" />
|
||||
|
@ -19,36 +20,26 @@
|
|||
var test = async_test()
|
||||
test.step(function() {
|
||||
var client = new XMLHttpRequest(),
|
||||
control_flag = false,
|
||||
result = [],
|
||||
expected = [1, 4, 'progress', 'abort', 'loadend'] // open() -> 1, abort() -> 4
|
||||
client.onreadystatechange = function() {
|
||||
test.step(function() {
|
||||
result.push(client.readyState)
|
||||
if(client.readyState == 4) {
|
||||
control_flag = true
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.responseText, "")
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
assert_equals(client.getResponseHeader('Content-Type'), null)
|
||||
}
|
||||
})
|
||||
}
|
||||
control_flag = false;
|
||||
prepare_xhr_for_event_order_test(client);
|
||||
client.addEventListener("readystatechange", test.step_func(function() {
|
||||
if(client.readyState == 4) {
|
||||
control_flag = true
|
||||
assert_equals(client.responseXML, null)
|
||||
assert_equals(client.responseText, "")
|
||||
assert_equals(client.status, 0)
|
||||
assert_equals(client.statusText, "")
|
||||
assert_equals(client.getAllResponseHeaders(), "")
|
||||
assert_equals(client.getResponseHeader('Content-Type'), null)
|
||||
}
|
||||
}))
|
||||
client.open("GET", "resources/well-formed.xml", true)
|
||||
client.send(null)
|
||||
client.addEventListener('progress', logEvt)
|
||||
client.addEventListener('abort', logEvt)
|
||||
client.addEventListener('loadend', logEvt)
|
||||
client.abort()
|
||||
assert_true(control_flag)
|
||||
assert_equals(client.readyState, 0)
|
||||
assert_array_equals(result, expected)
|
||||
assert_xhr_event_order_matches([1, "loadstart(0,0,false)", 4, "abort(0,0,false)", "loadend(0,0,false)"])
|
||||
test.done()
|
||||
function logEvt (e) {
|
||||
result.push(e.type)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -7,8 +7,8 @@ test.step(function() {
|
|||
assert_unreached()
|
||||
})
|
||||
}
|
||||
assert_equals(client.readyState, 1, "before abort()")
|
||||
client.abort()
|
||||
assert_equals(client.readyState, 0)
|
||||
assert_throws("InvalidStateError", function() { client.send("test") }, "calling send() after abort()")
|
||||
assert_equals(client.readyState, 1, "after abort()")
|
||||
})
|
||||
test.done()
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
client.open("POST", "resources/delay.py?ms=1000")
|
||||
client.addEventListener("loadend", function(e) {
|
||||
test.step(function() {
|
||||
assert_xhr_event_order_matches([1, "loadstart(0,0,false)", "upload.loadstart(0,9999,true)", 4, "upload.progress(0,0,false)", "upload.abort(0,0,false)", "upload.loadend(0,0,false)", "progress(0,0,false)", "abort(0,0,false)", "loadend(0,0,false)"]);
|
||||
assert_xhr_event_order_matches([1, "loadstart(0,0,false)", "upload.loadstart(0,9999,true)", 4, "upload.abort(0,0,false)", "upload.loadend(0,0,false)", "abort(0,0,false)", "loadend(0,0,false)"]);
|
||||
test.done()
|
||||
})
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-abort()-method" data-tested-assertations="following-sibling::ol/li[4]/ol/li[5]" />
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<title>XMLHttpRequest: The abort() method: do not fire abort event in OPENED state when send() flag is unset. send() throws after abort().</title>
|
||||
<title>XMLHttpRequest: The abort() method: do not fire abort event in OPENED state when send() flag is unset.</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -24,6 +24,7 @@
|
|||
if (xhr.readyState == 1)
|
||||
{
|
||||
xhr.abort();
|
||||
assert_equals(xhr.readyState, 1, "abort() cannot change readyState when readyState is 1 and send() flag is unset")
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -37,7 +38,7 @@
|
|||
};
|
||||
|
||||
xhr.open("GET", "./resources/content.py", true); // This should cause a readystatechange event that calls abort()
|
||||
assert_throws("InvalidStateError", function(){ xhr.send() })
|
||||
xhr.send() // should not throw since abort() was a no-op
|
||||
test.done()
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
{
|
||||
test.step(function()
|
||||
{
|
||||
assert_xhr_event_order_matches([1, "loadstart(0,0,false)", 4, "upload.progress(0,0,false)", "upload.abort(0,0,false)", "upload.loadend(0,0,false)", "progress(0,0,false)", "abort(0,0,false)", "loadend(0,0,false)"]);
|
||||
assert_xhr_event_order_matches([1, "loadstart(0,0,false)", 4, "upload.abort(0,0,false)", "upload.loadend(0,0,false)", "abort(0,0,false)", "loadend(0,0,false)"]);
|
||||
|
||||
assert_equals(xhr.readyState, 0, 'state should be UNSENT');
|
||||
test.done();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
prepare_xhr_for_event_order_test(xhr);
|
||||
xhr.addEventListener("loadend", function() {
|
||||
test.step(function() {
|
||||
assert_xhr_event_order_matches([1, "loadstart(0,0,false)", "upload.loadstart(0,12,true)", 4, "upload.progress(0,0,false)", "upload.timeout(0,0,false)", "upload.loadend(0,0,false)", "progress(0,0,false)", "timeout(0,0,false)", "loadend(0,0,false)"]);
|
||||
assert_xhr_event_order_matches([1, "loadstart(0,0,false)", "upload.loadstart(0,12,true)", 4, "upload.timeout(0,0,false)", "upload.loadend(0,0,false)", "timeout(0,0,false)", "loadend(0,0,false)"]);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
abort_flag = true
|
||||
client.abort()
|
||||
assert_array_equals(result, expected)
|
||||
assert_equals(client.readyState, 1) // abort() should only set state to UNSENT when DONE
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -36,17 +36,20 @@
|
|||
|
||||
* If lengthComputable is true:
|
||||
* Event.total must match Content-length header
|
||||
* event.loaded should be a smaller number while resource is loading
|
||||
and match Content-length when loading is finished
|
||||
* Setting event.loaded to equal event.total for each progress event if the
|
||||
resource is not fully downloaded would be cheating
|
||||
* event.loaded must only ever increase in progress events
|
||||
(and may never repeat its value).
|
||||
* event.loaded must never exceed the Content-length.
|
||||
|
||||
* If lengthComputable is false:
|
||||
* event.total should be 0
|
||||
* event.loaded must only ever increase in progress events
|
||||
(and may never repeat its value).
|
||||
* event.loaded should be the length of the decompressed content, i.e.
|
||||
bigger than Content-length header value when finished loading
|
||||
|
||||
*/
|
||||
var lastTotal;
|
||||
var lastLoaded = -1;
|
||||
client.addEventListener('loadend', test.step_func(function(e){
|
||||
var len = parseInt(client.getResponseHeader('content-length'), 10)
|
||||
if(e.lengthComputable){
|
||||
|
@ -59,14 +62,17 @@
|
|||
test.done();
|
||||
}), false)
|
||||
client.addEventListener('progress', test.step_func(function(e){
|
||||
if(e.lengthComputable && e.total && e.loaded && e.target.readyState < 4){
|
||||
assert_not_equals(e.total, e.loaded, 'total should not equal loaded while download/decode is incomplete')
|
||||
// We should only do this assertation once
|
||||
// it's theoretically possible that all the data would get in
|
||||
// and a progress event fire before the readyState switches from 3 to 4 -
|
||||
// in this case we might report bogus and random failures. Better to remove the event listener again..
|
||||
client.removeEventListener('progress', arguments.callee, false);
|
||||
if(lastTotal === undefined){
|
||||
lastTotal = e.total;
|
||||
}
|
||||
if(e.lengthComputable && e.total && e.loaded){
|
||||
assert_equals(e.total, lastTotal, 'event.total should remain invariant')
|
||||
assert_less_than_equal(e.loaded, lastTotal, 'event.loaded should not exceed content-length')
|
||||
}else{
|
||||
assert_equals(e.total, 0, 'event.total should be 0')
|
||||
}
|
||||
assert_greater_than(e.loaded, lastLoaded, 'event.loaded should only ever increase')
|
||||
lastLoaded = e.loaded;
|
||||
}), false)
|
||||
// image.gif is 165375 bytes compressed. Sending 45000 bytes at a time with 1 second delay will load it in 4 seconds
|
||||
client.open("GET", "resources/image.gif?pipe=gzip|trickle(45000:d1:r2)", true)
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>XMLHttpRequest: send() with document.domain set: loading documents from original origin after setting document.domain</title>
|
||||
<script src="send-after-setting-document-domain-window-helper.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method" data-tested-assertations="following::ol[1]/li[2]/ol[1]/li[3]" />
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
run_test(function() {
|
||||
document.domain = document.domain; // this is not a noop, it does actually change the security context
|
||||
var client = new XMLHttpRequest();
|
||||
client.open("GET", "status.py?content=hello", false);
|
||||
client.send(null);
|
||||
assert_equals(client.responseText, "hello");
|
||||
document.domain = document.domain.replace(/^\w+\./, "");
|
||||
client.open("GET", "status.py?content=hello2", false);
|
||||
client.send(null);
|
||||
assert_equals(client.responseText, "hello2");
|
||||
}, "loading documents from original origin after setting document.domain");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>XMLHttpRequest: send() with document.domain set: loading documents from the origin document.domain was set to should throw</title>
|
||||
<script src="send-after-setting-document-domain-window-helper.js"></script>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method" data-tested-assertations="following::ol[1]/li[2]/ol[1]/li[3]" />
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
run_test(function() {
|
||||
document.domain = document.domain.replace(/^\w+\./, "");
|
||||
var client = new XMLHttpRequest();
|
||||
client.open("GET", location.protocol + "//" + document.domain + location.pathname.replace(/[^\/]*$/, "") + "status.py?content=hello3", false);
|
||||
assert_throws("NetworkError", function() {
|
||||
client.send(null);
|
||||
});
|
||||
}, "loading documents from the origin document.domain was set to should throw");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,29 @@
|
|||
function assert_equals(value, expected) {
|
||||
if (value != expected) {
|
||||
throw "Got wrong value.\nExpected '" + expected + "',\ngot '" + value + "'";
|
||||
}
|
||||
}
|
||||
|
||||
function assert_throws(expected_exc, func) {
|
||||
try {
|
||||
func.call(this);
|
||||
} catch(e) {
|
||||
var actual = e.name || e.type;
|
||||
if (actual != expected_exc) {
|
||||
throw "Got wrong exception.\nExpected '" + expected_exc + "',\ngot '" + actual + "'.";
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw "Expected exception, but none was thrown";
|
||||
}
|
||||
|
||||
function run_test(test, name) {
|
||||
var result = {passed: true, message: null, name: name};
|
||||
try {
|
||||
test();
|
||||
} catch(e) {
|
||||
result.passed = false;
|
||||
result.message = e + "";
|
||||
}
|
||||
opener.postMessage(result, "*");
|
||||
}
|
|
@ -21,13 +21,60 @@
|
|||
}
|
||||
}
|
||||
|
||||
function getNextEvent(arr) {
|
||||
var eventStr = arr.shift();
|
||||
|
||||
// we can only handle strings, numbers (readystates) and undefined
|
||||
if (eventStr === undefined) {
|
||||
return event;
|
||||
}
|
||||
if (typeof eventStr !== "string") {
|
||||
if (Number.isInteger(eventStr)) {
|
||||
eventStr = "readystatechange(" + eventStr + ")";
|
||||
} else {
|
||||
throw "Test error: unexpected event type " + eventStr;
|
||||
}
|
||||
}
|
||||
|
||||
// parse out the general type, loaded and total values
|
||||
var type = eventStr.type = eventStr.split("(")[0].split(".").pop();
|
||||
eventStr.mayFollowOptionalProgressEvents = type == "progress" ||
|
||||
type == "load" || type == "abort" || type == "error";
|
||||
var loadedAndTotal = eventStr.match(/\((\d)+,(\d)+/);
|
||||
if (loadedAndTotal) {
|
||||
eventStr.loaded = parseInt(loadedAndTotal[0]);
|
||||
eventStr.total = parseInt(loadedAndTotal[1]);
|
||||
}
|
||||
|
||||
return eventStr;
|
||||
}
|
||||
|
||||
global.assert_xhr_event_order_matches = function(expected) {
|
||||
try {
|
||||
assert_array_equals(recorded_xhr_events, expected);
|
||||
} catch(e) {
|
||||
e.message += "\nRecorded events were:" + recorded_xhr_events.join(", ");
|
||||
e.message += "\nExpected events were:" + expected.join(", ");
|
||||
throw e;
|
||||
var recorded = recorded_xhr_events;
|
||||
var lastRecordedLoaded = -1;
|
||||
|
||||
while(expected.length && recorded.length) {
|
||||
var currentExpected = getNextEvent(expected),
|
||||
currentRecorded = getNextEvent(recorded);
|
||||
|
||||
// skip to the last progress event if we've hit one
|
||||
while (recorded.length && currentRecorded.type == "progress") {
|
||||
assert_greater(currentRecorded.loaded, lastRecordedLoaded,
|
||||
"progress event 'loaded' values must only increase");
|
||||
lastRecordedLoaded = currentRecorded.loaded;
|
||||
currentRecorded = getNextEvent(recorded);
|
||||
}
|
||||
if (currentRecorded.type == "loadstart") {
|
||||
lastRecordedLoaded = -1;
|
||||
}
|
||||
|
||||
assert_equals(currentRecorded, currentExpected);
|
||||
}
|
||||
if (recorded.length) {
|
||||
throw "\nUnexpected extra events: " + recorded.join(", ");
|
||||
}
|
||||
if (expected.length) {
|
||||
throw "\nExpected more events: " + expected.join(", ");
|
||||
}
|
||||
}
|
||||
}(this));
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
assert_equals(client.responseXML.documentElement.localName, "html", 'localName is html')
|
||||
assert_equals(client.responseXML.documentElement.childNodes.length, 5, 'childNodes is 5')
|
||||
assert_equals(client.responseXML.getElementById("n1").localName, client.responseXML.documentElement.childNodes[1].localName)
|
||||
assert_equals(client.responseXML.getElementById("n2"), client.responseXML.documentElement.childrenNodes[3], 'getElementById("n2")')
|
||||
assert_equals(client.responseXML.getElementById("n2"), client.responseXML.documentElement.childNodes[3], 'getElementById("n2")')
|
||||
assert_equals(client.responseXML.getElementsByTagName("p")[1].namespaceURI, "namespacesarejuststrings", 'namespaceURI')
|
||||
})
|
||||
test(function() {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var timePreXHR = Math.floor(new Date().getTime() / 1000);
|
||||
var timePreXHR = Math.floor(new Date().getTime(new Date().getTime() - 3000) / 1000); // three seconds ago, in case there's clock drift
|
||||
var client = new XMLHttpRequest()
|
||||
client.open("GET", "resources/well-formed.xml", false)
|
||||
client.send(null)
|
||||
|
@ -45,7 +45,7 @@
|
|||
|
||||
test(function() {
|
||||
var lastModified = Math.floor(new Date(client.responseXML.lastModified).getTime() / 1000);
|
||||
var now = Math.floor(new Date().getTime(new Date().getTime() + 2000) / 1000); // two seconds from now, in case there's clock drift
|
||||
var now = Math.floor(new Date().getTime(new Date().getTime() + 3000) / 1000); // three seconds from now, in case there's clock drift
|
||||
assert_greater_than_equal(lastModified, timePreXHR);
|
||||
assert_less_than_equal(lastModified, now);
|
||||
}, 'lastModified set to time of response if no HTTP header provided')
|
||||
|
|
|
@ -4,35 +4,36 @@
|
|||
<title>XMLHttpRequest: send() with document.domain set</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<!-- The spec doesn't seem to explicitly cover this case (as of June 2013) -->
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method" data-tested-assertations="following::ol[1]/li[2]/ol[1]/li[3]" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
// first make sure we actually run off a domain with at least three parts, in order to be able to shorten it..
|
||||
if (location.hostname.split(/\./).length < 3) {
|
||||
location.href = location.protocol+'//www2.'+location.host+location.pathname
|
||||
}
|
||||
var test_base_url = location.protocol+'//www2.'+location.host+"/XMLHttpRequest/resources/",
|
||||
test_windows = [
|
||||
window.open(test_base_url + "send-after-setting-document-domain-window-1.htm"),
|
||||
window.open(test_base_url + "send-after-setting-document-domain-window-2.htm"),
|
||||
],
|
||||
num_tests_left = test_windows.length;
|
||||
|
||||
test(function() {
|
||||
document.domain = document.domain // this is not a noop, it does actually change the security context
|
||||
var client = new XMLHttpRequest()
|
||||
client.open("GET", "resources/status.py?content=hello", false)
|
||||
client.send(null)
|
||||
assert_equals(client.responseText, "hello")
|
||||
document.domain = document.domain.replace(/^\w+\./, '')
|
||||
client.open("GET", "resources/status.py?content=hello2", false)
|
||||
client.send(null)
|
||||
assert_equals(client.responseText, "hello2")
|
||||
}, "loading documents from original origin after setting document.domain")
|
||||
// try to load a document from the origin document.domain was set to
|
||||
test(function () {
|
||||
var client = new XMLHttpRequest()
|
||||
client.open("GET", location.protocol + '//' + document.domain + location.pathname.replace(/[^\/]*$/, '') + "resources/status.py?content=hello3", false)
|
||||
// AFAIK this should throw
|
||||
assert_throws('NetworkError', function(){client.send(null)})
|
||||
}, "loading documents from the origin document.domain was set to should throw")
|
||||
async_test(function(wrapper_test) {
|
||||
window.addEventListener("message", function(evt) {
|
||||
// run a shadow test that just forwards the results
|
||||
async_test(function(test) {
|
||||
assert_true(evt.data.passed, evt.data.message);
|
||||
test.done();
|
||||
}, evt.data.name);
|
||||
|
||||
// after last result comes in, close all test
|
||||
// windows and complete the wrapper test.
|
||||
if (--num_tests_left == 0) {
|
||||
for (var i=0; i<test_windows.length; ++i) {
|
||||
test_windows[i].close();
|
||||
}
|
||||
wrapper_test.done();
|
||||
}
|
||||
}, false);
|
||||
}, "All tests ran");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -20,17 +20,19 @@
|
|||
["invalid mime type", new Blob(["data"], {type: "Invalid \r\n mime \r\n type"})]
|
||||
];
|
||||
|
||||
blobTests.forEach(function(item){
|
||||
function doSyncTest(testItem, method) {
|
||||
test(function() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "./resources/content.py", false);
|
||||
xhr.send(item[1]);
|
||||
xhr.open(method, "./resources/content.py", false);
|
||||
xhr.send(testItem[1]);
|
||||
|
||||
assert_equals(xhr.getResponseHeader("X-Request-Content-Length"), "4");
|
||||
assert_equals(xhr.getResponseHeader("X-Request-Content-Type"), "NO");
|
||||
}, "Synchronous blob loading with " + item[0]);
|
||||
}, "Synchronous blob loading with " + testItem[0] + " [" + method + "]");
|
||||
}
|
||||
|
||||
var atest = async_test("Asynchronous blob loading with " + item[0]);
|
||||
function doAsyncTest(testItem, method) {
|
||||
var atest = async_test("Asynchronous blob loading with " + testItem[0] + " [" + method + "]");
|
||||
atest.step(function() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function() {
|
||||
|
@ -42,9 +44,17 @@
|
|||
atest.done();
|
||||
}
|
||||
}
|
||||
xhr.open("POST", "./resources/content.py", true);
|
||||
xhr.send(item[1]);
|
||||
xhr.open(method, "./resources/content.py", true);
|
||||
xhr.send(testItem[1]);
|
||||
});
|
||||
}
|
||||
|
||||
blobTests.forEach(function(item){
|
||||
doSyncTest(item, "POST");
|
||||
doAsyncTest(item, "POST");
|
||||
|
||||
doSyncTest(item, "PUT");
|
||||
doAsyncTest(item, "PUT");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -17,9 +17,8 @@
|
|||
client.abort();
|
||||
}}
|
||||
client.open('POST', 'resources/content.py')
|
||||
assert_throws("InvalidStateError", function(){
|
||||
client.send(objAbortsOnStringification)
|
||||
})
|
||||
client.send(objAbortsOnStringification)
|
||||
assert_equals(client.readyState, 1)
|
||||
test1.done()
|
||||
});
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<link rel="help" href="https://xhr.spec.whatwg.org/#switch-done" data-tested-assertations="following::ol[1]/li[3] following::ol[1]/li[4] following::ol[1]/li[5] following::ol[1]/li[6] following::ol[1]/li[7]" />
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/xmlhttprequest-event-order.js"></script>
|
||||
<title>XMLHttpRequest: The send() method: event order when synchronous flag is unset</title>
|
||||
</head>
|
||||
|
||||
|
@ -24,38 +25,12 @@
|
|||
test.step(function()
|
||||
{
|
||||
var xhr = new XMLHttpRequest();
|
||||
var expect = ["loadstart", "upload.loadstart", "upload.progress", "upload.load", "upload.loadend", "progress", 4, "load", "loadend"];
|
||||
var actual = [];
|
||||
prepare_xhr_for_event_order_test(xhr);
|
||||
|
||||
xhr.onreadystatechange = function()
|
||||
{
|
||||
test.step(function()
|
||||
{
|
||||
if (xhr.readyState == 4)
|
||||
{
|
||||
actual.push(xhr.readyState);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
xhr.onloadstart = function(e){ actual.push(e.type); };
|
||||
xhr.onload = function(e){ actual.push(e.type); };
|
||||
xhr.onloadend = function(e){ actual.push(e.type); VerifyResult()};
|
||||
xhr.onprogress = function(e){ actual.push(e.type);};
|
||||
|
||||
xhr.upload.onloadstart = function(e){ actual.push("upload." + e.type); };
|
||||
xhr.upload.onload = function(e){ actual.push("upload." + e.type); };
|
||||
xhr.upload.onloadend = function(e){ actual.push("upload." + e.type);};
|
||||
xhr.upload.onprogress = function(e){ actual.push("upload." + e.type);};
|
||||
|
||||
function VerifyResult()
|
||||
{
|
||||
test.step(function()
|
||||
{
|
||||
assert_array_equals(actual, expect);
|
||||
test.done();
|
||||
});
|
||||
};
|
||||
xhr.addEventListener("loadend", test.step_func(function() {
|
||||
assert_xhr_event_order_matches([1, "loadstart(0,0,false)", "upload.loadstart(0,12,true)", "upload.progress(12,12,true)", "upload.load(12,12,true)", "upload.loadend(12,12,true)", 2, 3, "progress(12,12,true)", 4, "load(12,12,true)", "loadend(12,12,true)"]);
|
||||
test.done();
|
||||
}));
|
||||
|
||||
xhr.open("POST", "./resources/content.py", true);
|
||||
xhr.send("Test Message");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue