LibWeb/Tests: Add a basic test for a blob URL given to a Worker

This commit is contained in:
Shannon Booth 2024-05-05 20:57:35 +12:00 committed by Andrew Kaster
parent 53eb9af42f
commit 5a0f7c5f63
Notes: sideshowbarker 2024-07-17 02:28:18 +09:00
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1 @@
Message received from worker: "WHF! :^)"

View File

@ -0,0 +1,21 @@
<script src="../include.js"></script>
<script>
asyncTest((done) => {
const workerScript = `
self.onmessage = function(evt) {
self.postMessage('WHF! :^)');
};
`;
const blob = new Blob([workerScript], { type: 'application/javascript' });
const workerScriptURL = URL.createObjectURL(blob);
const worker = new Worker(workerScriptURL);
worker.onmessage = function(evt) {
println('Message received from worker: ' + JSON.stringify(evt.data));
done();
};
// Send a message to the worker
worker.postMessage('Hello from main script');
});
</script>