mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
Update web-platform-tests to revision 7a767a52741f628430ffbbed46e7f3df68ba3534
Fixes #15648.
This commit is contained in:
parent
a1e4c547f0
commit
4fadf9b0b6
1184 changed files with 22551 additions and 9856 deletions
|
@ -0,0 +1,93 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>Dispatching idle callbacks should be able to be suspended and then resumed</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
function withEventListener(target, event, handler) {
|
||||
handler = handler || (e => e);
|
||||
return new Promise(resolve => {
|
||||
let wrapper = function(e) {
|
||||
let result = handler(e);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(result);
|
||||
}
|
||||
target.addEventListener(event, wrapper, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
function makePostBackUrl(name) {
|
||||
return new URL('resources/post_name_on_load.html?name=' + name,
|
||||
window.location).href;
|
||||
}
|
||||
|
||||
function waitForMessage(message, handler) {
|
||||
return withEventListener(window, 'message', e => (e.data === message) && handler(e));;
|
||||
}
|
||||
|
||||
function withWindow(name) {
|
||||
let win = window.open(makePostBackUrl(name))
|
||||
return waitForMessage(name, _ => win);
|
||||
}
|
||||
|
||||
function navigateWindow(win, name) {
|
||||
win.location = makePostBackUrl(name);
|
||||
return waitForMessage(name, _ => win);
|
||||
}
|
||||
|
||||
function waitDuration(delay) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, delay);
|
||||
})
|
||||
}
|
||||
|
||||
function goBack(win) {
|
||||
var p = withEventListener(win, 'pagehide');
|
||||
win.history.back();
|
||||
return p;
|
||||
}
|
||||
|
||||
promise_test(t => {
|
||||
let idleCalled = false;
|
||||
let running = true;
|
||||
return withWindow('foo')
|
||||
.then(win => {
|
||||
let callback = function(d) {
|
||||
idleCalled = true;
|
||||
if (running) {
|
||||
win.requestIdleCallback(callback);
|
||||
}
|
||||
};
|
||||
|
||||
win.requestIdleCallback(callback);
|
||||
|
||||
return navigateWindow(win, 'bar')
|
||||
.then(_ => idleCalled = false)
|
||||
.then(_ => waitDuration(2000))
|
||||
.then(_ => {
|
||||
assert_false(idleCalled, "idle callback shouldn't have been called yet");
|
||||
return goBack(win);
|
||||
})
|
||||
.then(_ => Promise.race([
|
||||
// At this point it's a matter of having bfcache ...
|
||||
waitDuration(2000)
|
||||
.then(_ => {
|
||||
assert_true(idleCalled, "idle callback should've been called by now");
|
||||
running = false;
|
||||
}),
|
||||
// ... or not. If not, we expect a load event.
|
||||
waitForMessage("foo")
|
||||
]))
|
||||
.then(_ => win.close())
|
||||
.catch(e => {
|
||||
win.close();
|
||||
throw e;
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
|
@ -23,4 +23,10 @@
|
|||
t.done();
|
||||
}, 2000);
|
||||
}, "A cancelled callback is never invoked");
|
||||
|
||||
async_test(function (t) {
|
||||
var handle = requestIdleCallback(t.step_func_done(function () {
|
||||
cancelIdleCallback(handle);
|
||||
}));
|
||||
}, "Cancelling the currently executing idle callback should be allowed");
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<!doctype html>
|
||||
<script>
|
||||
addEventListener('load', _ => {
|
||||
let params = new URLSearchParams(window.location.search);
|
||||
window.opener.postMessage(params.get('name'), '*');
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue