mirror of
https://github.com/servo/servo.git
synced 2025-08-20 12:55:33 +01:00
Update web-platform-tests to revision 3cb5a99e5521936fb8819de8aaba806050b84184
This commit is contained in:
parent
1d2c0ba0bc
commit
c700482629
204 changed files with 5112 additions and 1445 deletions
|
@ -18,6 +18,33 @@ const StepStatus = {
|
|||
|
||||
var steps_map = new Map();
|
||||
|
||||
function poll_for_result(request_token, step_name, expect_success) {
|
||||
test.step(() => {
|
||||
var iteration = 5;
|
||||
var checkResult = () => {
|
||||
fetch("resources/beacon.py?query&token=" + request_token).then(test.step_func((response) => {
|
||||
var count = response.headers.get("Count");
|
||||
if (count != '0') {
|
||||
// If the server received something we can terminate polling.
|
||||
if (expect_success) {
|
||||
step_success(step_name);
|
||||
} else {
|
||||
step_fail(step_name);
|
||||
}
|
||||
} else if (!expect_success && count == '0' && iteration == 0) {
|
||||
// When we are out of iterations and we aren't expecting success, declare this step complete.
|
||||
// Should be 125 ms looking to make sure server didn't see the request.
|
||||
step_success(step_name);
|
||||
} else {
|
||||
iteration--;
|
||||
test.step_timeout(checkResult, 25);
|
||||
}
|
||||
}));
|
||||
};
|
||||
test.step_timeout(checkResult, 25);
|
||||
});
|
||||
}
|
||||
|
||||
function add_step(name) {
|
||||
steps_map[name] = StepStatus.ADDED;
|
||||
total_steps++;
|
||||
|
@ -46,4 +73,3 @@ test.step_timeout(() => {
|
|||
}, 1000);
|
||||
|
||||
</script>
|
||||
|
||||
|
|
25
tests/wpt/web-platform-tests/lifecycle/resources/beacon.py
Normal file
25
tests/wpt/web-platform-tests/lifecycle/resources/beacon.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
def main(request, response):
|
||||
|
||||
# |token| should be a unique UUID request parameter for the duration of this
|
||||
# request. It will get stored in the server stash and will be used later in
|
||||
# a query request.
|
||||
# |query| should be a request parameter indicating the request would like
|
||||
# to know how many times the server has seen the request (with the
|
||||
# same token).
|
||||
token = request.GET.first("token", None)
|
||||
is_query = request.GET.first("query", None) is not None
|
||||
with request.server.stash.lock:
|
||||
value = request.server.stash.take(token)
|
||||
count = 0
|
||||
if value is not None:
|
||||
count = int(value)
|
||||
if is_query:
|
||||
request.server.stash.put(token, count)
|
||||
else:
|
||||
count += 1
|
||||
request.server.stash.put(token, count)
|
||||
|
||||
headers = []
|
||||
if is_query:
|
||||
headers = [("Count", count)]
|
||||
return (200, headers, "")
|
|
@ -1 +0,0 @@
|
|||
Sample test file for fetch inside onfreeze.
|
|
@ -3,6 +3,7 @@
|
|||
<head><title>Frozen Window</title></head>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="/common/utils.js"></script>
|
||||
<body>
|
||||
<h1>This window will be frozen</h1>
|
||||
<script>
|
||||
|
@ -10,22 +11,23 @@
|
|||
const freezingStepName = 'testOnFreeze';
|
||||
|
||||
function testFetch(keepalive) {
|
||||
var request_token = token();
|
||||
var name = 'testfetch' + (keepalive ? 'with' : 'without') + 'keepalive';
|
||||
window.opener.add_step(name);
|
||||
|
||||
function handler(expected) {
|
||||
if (expected == true)
|
||||
window.opener.step_success(name);
|
||||
else
|
||||
window.opener.step_fail(name);
|
||||
function handler() {
|
||||
window.opener.step_fail(name);
|
||||
}
|
||||
|
||||
fetch('foo.txt', {
|
||||
fetch('beacon.py?token=' + request_token, {
|
||||
keepalive: keepalive
|
||||
}).then(() => handler(keepalive)).catch(() => handler(!keepalive));
|
||||
}).then(() => handler()).catch(() => handler());
|
||||
|
||||
window.opener.poll_for_result(request_token, name, keepalive);
|
||||
}
|
||||
|
||||
function testXHR(async) {
|
||||
var request_token = token();
|
||||
var name = 'test' + (async ? 'Async' : 'Sync') + 'XHR';
|
||||
window.opener.add_step(name);
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
@ -37,21 +39,26 @@ function testXHR(async) {
|
|||
window.opener.step_fail(name);
|
||||
}
|
||||
}
|
||||
xhr.open('GET', 'foo.txt', async);
|
||||
xhr.open('GET', 'beacon.py?token=' + request_token, async);
|
||||
try {
|
||||
xhr.send(null);
|
||||
if (async) {
|
||||
window.opener.poll_for_result(request_token, name, false);
|
||||
}
|
||||
} catch {
|
||||
window.opener.step_success(name);
|
||||
};
|
||||
}
|
||||
|
||||
function testSendBeacon() {
|
||||
var request_token = token();
|
||||
var name = 'testSendBeacon';
|
||||
window.opener.add_step(name);
|
||||
if (navigator.sendBeacon("foo.txt", "data=1"))
|
||||
window.opener.step_success(name);
|
||||
else
|
||||
if (navigator.sendBeacon("beacon.py?token=" + request_token, "")) {
|
||||
window.opener.poll_for_result(request_token, name, true);
|
||||
} else {
|
||||
window.opener.step_fail(name);
|
||||
}
|
||||
}
|
||||
|
||||
window.document.addEventListener("freeze", () => {
|
||||
|
@ -73,4 +80,4 @@ onload = function() {
|
|||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue