mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
LibWeb: Fix always hanging Navigable::reload()
See spec issue https://github.com/whatwg/html/issues/9869 Previous attempt on fixing reload had to be reverted because it broke Soundcloud and GitHub, but this change does not seem to introduce new crashes.
This commit is contained in:
committed by
Alexander Kalenik
parent
f7e57881ad
commit
91377f3ab9
Notes:
sideshowbarker
2024-07-17 08:42:05 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/91377f3ab9 Pull-request: https://github.com/SerenityOS/serenity/pull/23940
@@ -0,0 +1,41 @@
|
||||
<!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>
|
||||
Reference in New Issue
Block a user