mirror of
https://github.com/servo/servo.git
synced 2025-09-04 12:08:21 +01:00
Update web-platform-tests to revision 9a5d71b326166e12784bdd9d161772e20f87c1fd
This commit is contained in:
parent
f7630dad87
commit
4ae3d09ff3
86 changed files with 2739 additions and 640 deletions
|
@ -13,7 +13,9 @@
|
|||
window.onload = test.step_func(function() {
|
||||
var client = new XMLHttpRequest();
|
||||
var abortFired = false;
|
||||
var sync = true;
|
||||
client.onabort = test.step_func(function (e) {
|
||||
assert_false(sync);
|
||||
assert_equals(e.type, 'abort');
|
||||
abortFired = true;
|
||||
});
|
||||
|
@ -24,6 +26,7 @@
|
|||
test.done();
|
||||
}, 200);
|
||||
window.stop();
|
||||
sync = false;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -9,27 +9,69 @@
|
|||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var test = async_test()
|
||||
test.step(function() {
|
||||
test(function(t) {
|
||||
var client = new XMLHttpRequest(),
|
||||
result = [],
|
||||
expected = [1, 4, 1] // open() -> 1,
|
||||
// abort() -> 4, open() -> 1
|
||||
client.onreadystatechange = function() {
|
||||
test.step(function() {
|
||||
result.push(client.readyState)
|
||||
})
|
||||
}
|
||||
expected = [
|
||||
'readystatechange', 0, 1, // open()
|
||||
'readystatechange', 2, 4, // abort()
|
||||
'abort', 2, 4, // abort()
|
||||
'loadend', 2, 4, // abort()
|
||||
'readystatechange', 3, 1, // open()
|
||||
]
|
||||
|
||||
var state = 0
|
||||
|
||||
client.onreadystatechange = t.step_func(function() {
|
||||
result.push('readystatechange', state, client.readyState)
|
||||
})
|
||||
client.onabort = t.step_func(function() {
|
||||
// abort event must be fired synchronously from abort().
|
||||
assert_equals(state, 2)
|
||||
|
||||
// readystatechange should be fired before abort.
|
||||
assert_array_equals(result, [
|
||||
'readystatechange', 0, 1, // open()
|
||||
'readystatechange', 2, 4, // abort()
|
||||
])
|
||||
|
||||
// readyState should be set to unsent (0) at the very end of abort(),
|
||||
// after this (and onloadend) is called.
|
||||
assert_equals(client.readyState, 4)
|
||||
|
||||
result.push('abort', state, client.readyState)
|
||||
})
|
||||
client.onloadend = t.step_func(function() {
|
||||
// abort event must be fired synchronously from abort().
|
||||
assert_equals(state, 2)
|
||||
|
||||
// readystatechange should be fired before abort.
|
||||
assert_array_equals(result, [
|
||||
'readystatechange', 0, 1, // open()
|
||||
'readystatechange', 2, 4, // abort()
|
||||
'abort', 2, 4, // abort()
|
||||
])
|
||||
|
||||
// readyState should be set to unsent (0) at the very end of abort(),
|
||||
// after this is called.
|
||||
assert_equals(client.readyState, 4)
|
||||
|
||||
result.push('loadend', state, client.readyState)
|
||||
})
|
||||
|
||||
client.open("GET", "resources/well-formed.xml")
|
||||
assert_equals(client.readyState, 1)
|
||||
|
||||
state = 1
|
||||
client.send(null)
|
||||
state = 2
|
||||
client.abort()
|
||||
assert_equals(client.readyState, 0)
|
||||
state = 3
|
||||
client.open("GET", "resources/well-formed.xml")
|
||||
assert_equals(client.readyState, 1)
|
||||
assert_array_equals(result, expected)
|
||||
})
|
||||
test.done()
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
43
tests/wpt/web-platform-tests/xhr/open-after-stop.window.js
Normal file
43
tests/wpt/web-platform-tests/xhr/open-after-stop.window.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
// window.stop() below prevents the load event from firing, so wait until it is
|
||||
// fired to start the test.
|
||||
setup({explicit_done: true });
|
||||
|
||||
onload = () => {
|
||||
async_test(function(t) {
|
||||
const client = new XMLHttpRequest();
|
||||
|
||||
const result = [];
|
||||
const expected = [
|
||||
'readystatechange', 0, 1, // open()
|
||||
];
|
||||
|
||||
let state = 0;
|
||||
|
||||
client.onreadystatechange = t.step_func(() => {
|
||||
result.push('readystatechange', state, client.readyState);
|
||||
});
|
||||
client.onabort = t.unreached_func("abort should not be fired after window.stop() and open()");
|
||||
client.onloadend = t.unreached_func("loadend should not be fired after window.stop() and open()");
|
||||
|
||||
client.open("GET", "resources/well-formed.xml");
|
||||
assert_equals(client.readyState, 1);
|
||||
|
||||
state = 1;
|
||||
client.send(null);
|
||||
state = 2;
|
||||
window.stop();
|
||||
// Unlike client.abort(), window.stop() does not change readyState
|
||||
// immediately, rather through a task...
|
||||
assert_equals(client.readyState, 1);
|
||||
state = 3;
|
||||
// ... which is then canceled when we open a new request anyway.
|
||||
client.open("GET", "resources/well-formed.xml");
|
||||
assert_equals(client.readyState, 1);
|
||||
assert_array_equals(result, expected);
|
||||
|
||||
// Give the abort and loadend events a chance to fire (erroneously) before
|
||||
// calling this a success.
|
||||
t.step_timeout(t.step_func_done(), 1000);
|
||||
}, "open() after window.stop()");
|
||||
done();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue