LibWeb: Import WPT tests concerning workers spawning other workers

Note that the importScripts() calls to /resources/testharness.js had to
be manually adjusted to use relative paths.
This commit is contained in:
CountBleck
2026-01-30 12:22:50 -08:00
committed by Shannon Booth
parent 7722af9772
commit f44c75a8de
Notes: github-actions[bot] 2026-02-06 10:49:38 +00:00
22 changed files with 195 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
<!doctype html>
<meta charset=utf-8>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<div id=log></div>
<script>
fetch_tests_from_worker(new Worker("../workers/nested_worker.worker.js"));
</script>

View File

@@ -0,0 +1,11 @@
importScripts("../resources/testharness.js");
async_test(function() {
var worker1 = new Worker("support/WorkerBasic.js");
worker1.postMessage("ping");
worker1.onmessage = this.step_func_done(function(evt) {
assert_equals(evt.data, "Pass");
worker1.terminate();
});
}, "Nested worker");
done();

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Test terminating a nested workers by calling terminate() from its parent worker</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
async_test(function() {
const worker = new Worker("support/parent_of_nested_worker.js");
worker.onmessage = this.step_func_done(function(e) {
assert_equals(e.data, "Pass");
done();
});
worker.postMessage("close");
});
</script>

View File

@@ -0,0 +1,9 @@
<!doctype html>
<meta charset=utf-8>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<div id=log></div>
<script>
fetch_tests_from_worker(new Worker("../workers/nested_worker_close_self.worker.js"));
</script>

View File

@@ -0,0 +1,12 @@
importScripts("../resources/testharness.js");
async_test(function() {
if (!self.Worker)
done();
const worker = new Worker("support/WorkerClose.js");
worker.onmessage = this.step_func_done(function(e) {
assert_equals(e.data, "close");
done();
});
worker.postMessage("close");
}, "Nested work that closes itself");

View File

@@ -0,0 +1,9 @@
<!doctype html>
<meta charset=utf-8>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<div id=log></div>
<script>
fetch_tests_from_worker(new Worker("../workers/nested_worker_importScripts.worker.js"));
</script>

View File

@@ -0,0 +1,11 @@
importScripts("../resources/testharness.js");
async_test(function() {
const worker = new Worker("support/ImportScripts.js");
worker.postMessage("ping");
worker.onmessage = this.step_func_done(function(evt) {
assert_equals(evt.data, "Pass");
worker.terminate();
});
}, "Nested worker that calls importScripts()");
done();

View File

@@ -0,0 +1,9 @@
<!doctype html>
<meta charset=utf-8>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<div id=log></div>
<script>
fetch_tests_from_worker(new Worker("../workers/nested_worker_sync_xhr.worker.js"));
</script>

View File

@@ -0,0 +1,11 @@
importScripts("../resources/testharness.js");
async_test(function() {
const worker = new Worker("support/sync_xhr.js");
worker.postMessage("ping");
worker.onmessage = this.step_func_done(function(evt) {
assert_equals(evt.data, "Pass");
worker.terminate();
});
}, "Nested worker that issues a sync XHR");
done();

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Test terminating a chain of nested workers by calling terminate() from the owning document</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
async_test(function() {
const worker = new Worker("support/parent_of_nested_worker.js");
worker.onmessage = this.step_func_done(function(e) {
assert_equals(e.data, "Pass");
worker.terminate();
});
});
</script>

View File

@@ -0,0 +1,9 @@
try
{
importScripts("WorkerBasic.js");
}
catch(ex)
{
result = "Fail";
postMessage(result);
}

View File

@@ -0,0 +1,7 @@
var result = "Fail";
onmessage = function(evt)
{
result = "Pass";
postMessage(result);
}

View File

@@ -0,0 +1,5 @@
onmessage = function(evt)
{
postMessage(evt.data);
self.close();
}

View File

@@ -0,0 +1,14 @@
try {
var worker = new Worker("WorkerBasic.js");
worker.onmessage = function(e) {
if (e.data == "Pass") {
postMessage("Pass");
} else if (e.data == "close") {
close();
postMessage("Pass");
}
};
worker.postMessage("start");
} catch (e) {
postMessage("Fail: " + e);
}

View File

@@ -0,0 +1,13 @@
try
{
const request = new XMLHttpRequest();
request.open("GET", "sync_xhr_target.xml", false);
request.send();
result = request.responseText == "<foo>sometext</foo>\n" ? "Pass" : "Fail";
postMessage(result);
}
catch(ex)
{
result = "Fail";
postMessage(result);
}

View File

@@ -0,0 +1 @@
<foo>sometext</foo>