mirror of
https://github.com/servo/servo.git
synced 2025-08-13 09:25:32 +01:00
Update web-platform-tests to revision d7afcb8708eac08a614d161d5622a48172daf7e3
This commit is contained in:
parent
6f8bb4dd40
commit
edff458e23
791 changed files with 17647 additions and 10322 deletions
|
@ -0,0 +1,53 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Tests Stale While Revalidate works for scripts</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/utils.js"></script>
|
||||
<body>
|
||||
<script>
|
||||
var last_modified;
|
||||
var last_modified_count = 0;
|
||||
var request_token = token();
|
||||
|
||||
// The script will call report via a uniquely generated ID on the subresource.
|
||||
// If it is a cache hit the ID will be the same and the test will pass.
|
||||
function report(mod) {
|
||||
if (!last_modified) {
|
||||
last_modified = mod;
|
||||
last_modified_count = 1;
|
||||
} else if (last_modified == mod) {
|
||||
last_modified_count++;
|
||||
}
|
||||
}
|
||||
|
||||
async_test(t => {
|
||||
window.onload = t.step_func(() => {
|
||||
step_timeout(() => {
|
||||
var script = document.createElement("script");
|
||||
script.src = "resources/stale-script.py?token=" + request_token;
|
||||
document.body.appendChild(script);
|
||||
script.onload = t.step_func(() => {
|
||||
assert_equals(last_modified_count, 2, "last modified");
|
||||
var checkResult = () => {
|
||||
// We poll because we don't know when the revalidation will occur.
|
||||
fetch("resources/stale-script.py?query&token=" + request_token).then(t.step_func((response) => {
|
||||
var count = response.headers.get("Count");
|
||||
if (count == '2') {
|
||||
t.done();
|
||||
} else {
|
||||
t.step_timeout(checkResult, 25);
|
||||
}
|
||||
}));
|
||||
};
|
||||
t.step_timeout(checkResult, 25);
|
||||
});
|
||||
}, 0);
|
||||
});
|
||||
}, 'Cache returns stale resource');
|
||||
|
||||
var script = document.createElement("script");
|
||||
script.src = "resources/stale-script.py?token=" + request_token;
|
||||
document.body.appendChild(script);
|
||||
</script>
|
||||
</body>
|
Loading…
Add table
Add a link
Reference in a new issue