mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +00:00
LibWeb: Add ServiceWorker job registration and execution
Now we can register jobs and they will be executed on the event loop "later". This doesn't feel like the right place to execute them, but the spec needs some updates in this regard anyway.
This commit is contained in:
parent
4a43d0ac98
commit
29416befe6
Notes:
github-actions[bot]
2024-10-04 05:09:03 +00:00
Author: https://github.com/ADKaster
Commit: 29416befe6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1622
8 changed files with 281 additions and 20 deletions
|
@ -2,19 +2,22 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
asyncTest(done => {
|
||||
setTimeout(() => {
|
||||
// We need to do this spoofing later in the event loop so that we don't end up
|
||||
// telling the test runner the wrong URL in page_did_finish_loading.
|
||||
spoofCurrentURL("https://example.com/service-worker-register.html");
|
||||
|
||||
spoofCurrentURL("https://example.com/service-worker-register.html");
|
||||
let swPromise = navigator.serviceWorker.register("service-worker.js");
|
||||
|
||||
let swPromise = navigator.serviceWorker.register("service-worker.js");
|
||||
|
||||
swPromise
|
||||
.then(registration => {
|
||||
println(`ServiceWorker registration successful with scope: ${registration.scope}`);
|
||||
done();
|
||||
})
|
||||
.catch(err => {
|
||||
println(`ServiceWorker registration failed: ${err}`);
|
||||
done();
|
||||
});
|
||||
swPromise
|
||||
.then(registration => {
|
||||
println(`ServiceWorker registration successful with scope: ${registration.scope}`);
|
||||
done();
|
||||
})
|
||||
.catch(err => {
|
||||
println(`ServiceWorker registration failed: ${err}`);
|
||||
done();
|
||||
});
|
||||
}, 0);
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue