1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:27:35 +00:00

LibWeb: Add basic Navigator send beacon support

This commit is contained in:
Bastiaan van der Plaat 2023-09-18 18:29:51 +02:00 committed by Andrew Kaster
parent d262670729
commit 9939b028c6
9 changed files with 156 additions and 0 deletions

View file

@ -0,0 +1,23 @@
<script src="../include.js"></script>
<script>
test(() => {
let testCounter = 1;
function testPart(part) {
try {
println(`${testCounter}. ${JSON.stringify(part())}`);
} catch (e) {
println(`${testCounter}. Exception: ${e.name}`);
}
testCounter++;
}
// 1. Send beacon
testPart(() => navigator.sendBeacon('https://example.com/') == true);
// 2. Send beacon with wrong URL
testPart(() => navigator.sendBeacon('dsfhdsaklfhdasklf'));
// 3. Send beacon with wrong scheme
testPart(() => navigator.sendBeacon('wss://example.com/'));
});
</script>