Skip to content

Commit

Permalink
LibWeb/Tests: Add a basic test for a blob URL given to a Worker
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonbooth committed May 5, 2024
1 parent b90c51a commit e5433bc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions Tests/LibWeb/Text/expected/Worker/Worker-blob.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Message received from worker: "WHF! :^)"
21 changes: 21 additions & 0 deletions Tests/LibWeb/Text/input/Worker/Worker-blob.html
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit e5433bc

Please sign in to comment.