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

Base+LibWeb: Add test case for Workers on welcome homepage

This commit is contained in:
serenitydev 2022-02-14 16:45:55 -05:00 committed by Andreas Kling
parent ae346cff6b
commit b5d891ed6a
3 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Worker</title>
</head>
<body>
<h2>Worker Test</h2>
<div id="output"></div>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function () {
console.log("Page Loaded. Sending message");
console.log("Parent Keys: ", JSON.stringify(Object.keys(this)));
var work = new Worker("worker.js");
work.onmessage = (evt) => {
console.log("Got message from worker:", evt.data);
};
document
.getElementById("btn_hello")
.addEventListener("click", function() {
console.log("Sending Message");
work.postMessage("Hey buddy!");
});
});
</script>
<button id="btn_hello">
Say Hello!
</button>
</body>
</html>