mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
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:
committed by
Shannon Booth
parent
7722af9772
commit
f44c75a8de
Notes:
github-actions[bot]
2026-02-06 10:49:38 +00:00
Author: https://github.com/CountBleck Commit: https://github.com/LadybirdBrowser/ladybird/commit/f44c75a8de5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7507 Reviewed-by: https://github.com/shannonbooth ✅
@@ -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>
|
||||
@@ -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();
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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");
|
||||
@@ -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>
|
||||
@@ -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();
|
||||
@@ -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>
|
||||
@@ -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();
|
||||
@@ -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>
|
||||
@@ -0,0 +1,9 @@
|
||||
try
|
||||
{
|
||||
importScripts("WorkerBasic.js");
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
result = "Fail";
|
||||
postMessage(result);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
var result = "Fail";
|
||||
|
||||
onmessage = function(evt)
|
||||
{
|
||||
result = "Pass";
|
||||
postMessage(result);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
onmessage = function(evt)
|
||||
{
|
||||
postMessage(evt.data);
|
||||
self.close();
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<foo>sometext</foo>
|
||||
Reference in New Issue
Block a user