mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-16 05:51:55 +00:00
LibWeb: Fix hanging location.reload() when SHE is populated by fetching
Adds a hack to address spec bug https://github.com/whatwg/html/issues/9869
This commit is contained in:
parent
609a72f7c7
commit
966b042db6
Notes:
sideshowbarker
2024-07-16 23:44:30 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: 966b042db6
Pull-request: https://github.com/SerenityOS/serenity/pull/23720
10 changed files with 158 additions and 8 deletions
|
@ -0,0 +1,42 @@
|
|||
<!DOCTYPE html>
|
||||
<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 = `
|
||||
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' });
|
||||
});
|
||||
`;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.srcdoc = "<script>" + iframeScript + "<\/script>";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue