mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
LibWeb: Port some manually async tests to use asyncTest
These tests were mostly async tests written in a manual way. This ports them to use the standard asyncTest() infrastructure. This is mostly just to reduce calls to internals.signalTextTestIsDone, which will have a required parameter in an upcoming test.
This commit is contained in:
Notes:
github-actions[bot]
2024-10-03 11:08:43 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/96082d6ae12 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1603 Reviewed-by: https://github.com/awesomekling ✅ Reviewed-by: https://github.com/circl-lastname Reviewed-by: https://github.com/kalenikaliaksandr ✅
@@ -2,26 +2,28 @@
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
let reloaded = false;
|
||||
window.addEventListener('message', event => {
|
||||
switch (event.data.action) {
|
||||
case "loaded":
|
||||
println("iframe is loaded");
|
||||
if (!reloaded) {
|
||||
event.source.postMessage({ action: 'reload' });
|
||||
reloaded = true;
|
||||
} else {
|
||||
internals.signalTextTestIsDone();
|
||||
}
|
||||
break;
|
||||
case "acknowledge-asked-to-reload":
|
||||
println("iframe is going to reload");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
const iframeScript = `
|
||||
asyncTest(done => {
|
||||
window.addEventListener("message", event => {
|
||||
switch (event.data.action) {
|
||||
case "loaded":
|
||||
println("iframe is loaded");
|
||||
if (!reloaded) {
|
||||
event.source.postMessage({ action: "reload" });
|
||||
reloaded = true;
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
break;
|
||||
case "acknowledge-asked-to-reload":
|
||||
println("iframe is going to reload");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
const iframeScript = `
|
||||
window.addEventListener('message', event => {
|
||||
if (event.data && event.data.action === 'reload') {
|
||||
window.parent.postMessage({ action: 'acknowledge-asked-to-reload' });
|
||||
@@ -33,8 +35,7 @@
|
||||
});
|
||||
`;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const iframe = document.createElement('iframe');
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.srcdoc = "<script>" + iframeScript + "<\/script>";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user