mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-15 15:42:52 +00:00
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.
42 lines
1.3 KiB
HTML
42 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
let reloaded = false;
|
|
|
|
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' });
|
|
location.reload();
|
|
}
|
|
});
|
|
window.addEventListener('load', () => {
|
|
window.parent.postMessage({ action: 'loaded' });
|
|
});
|
|
`;
|
|
|
|
const iframe = document.createElement("iframe");
|
|
iframe.srcdoc = "<script>" + iframeScript + "<\/script>";
|
|
document.body.appendChild(iframe);
|
|
});
|
|
</script>
|