1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:37:45 +00:00

LibWeb: Update session history when History entry is pushed/replaced

With this change `shared_history_push_replace_state()` starts to
actually add/replace session history entry.
This commit is contained in:
Aliaksandr Kalenik 2023-09-23 23:04:24 +02:00 committed by Andrew Kaster
parent 699ead0939
commit 7cdbd59e92
6 changed files with 55 additions and 13 deletions

View file

@ -0,0 +1 @@
history object length has changed by 1

View file

@ -0,0 +1,20 @@
<script src="../include.js"></script>
<script>
try {
const initialHistoryLength = window.history.length;
history.pushState({}, "hello", "history-pushstate-iframe.html#hello");
if (window.self !== window.top) {
parent.postMessage(
"history object length has changed by " +
(window.history.length - initialHistoryLength),
"*"
);
} else {
test(() => {});
}
} catch (e) {
if (window.self !== window.top) parent.postMessage("ERROR:" + e, "*");
}
</script>

View file

@ -0,0 +1,23 @@
<script src="../include.js"></script>
<iframe id="testIframe" src="about:blank"></iframe>
<script>
asyncTest(async done => {
const iframe = document.getElementById("testIframe");
function navigateIframe(src) {
return new Promise(resolve => {
iframe.addEventListener("load", () => {
resolve();
});
iframe.src = src;
});
}
window.addEventListener("message", event => {
println(event.data);
done();
});
await navigateIframe("./history-pushstate-iframe.html");
});
</script>