mirror of
https://github.com/servo/servo.git
synced 2025-08-21 13:25:34 +01:00
Update web-platform-tests to revision 60220357131c65146444da1f54624d5b54d0975d
This commit is contained in:
parent
c45192614c
commit
775b784f79
2144 changed files with 58115 additions and 29658 deletions
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>iframe used in clientId test</title>
|
||||
<script>
|
||||
|
||||
self.onmessage = async event => {
|
||||
try {
|
||||
if (event.data === 'get_sw_client_id') {
|
||||
// Use the controlling service worker to determine
|
||||
// this client's id according to the Service Worker.
|
||||
const response = await fetch('/clientId');
|
||||
const data = await response.json();
|
||||
window.parent.postMessage(data.clientId, '*');
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data === 'get_lock_client_id') {
|
||||
// Grab a lock, then query the lock manager for state to
|
||||
// determine this client's id according to the lock manager.
|
||||
await navigator.locks.request('lock-name', async lock => {
|
||||
const lock_state = await navigator.locks.query();
|
||||
const held_lock = lock_state.held.filter(l => l.name === lock.name)[0];
|
||||
window.parent.postMessage(held_lock.clientId, '*');
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
window.parent.postMessage(`unknown request: ${event.data}`, '*');
|
||||
} catch (ex) {
|
||||
// In case of test failure, don't leave parent window hanging.
|
||||
window.parent.postMessage(`${ex.name}: ${ex.message}`, '*');
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue