mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
LibWeb: Align Navigable::reload() with the specification
This commit is contained in:
committed by
Shannon Booth
parent
dc649a7e46
commit
5060a61081
Notes:
github-actions[bot]
2026-02-14 19:23:15 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/5060a610815 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7875 Reviewed-by: https://github.com/shannonbooth ✅
@@ -0,0 +1,39 @@
|
||||
<!doctype html>
|
||||
<script src="../../resources/testharness.js"></script>
|
||||
<script src="../../resources/testharnessreport.js"></script>
|
||||
<iframe id="i" src="../../common/blank.html"></iframe>
|
||||
<script>
|
||||
async_test(t => {
|
||||
window.onload = t.step_func(() => {
|
||||
const navState = { key: "value" };
|
||||
const navInfo = { infoKey: "infoValue" };
|
||||
i.contentWindow.navigation.navigate("#1", { state: navState }).committed.then(t.step_func(() => {
|
||||
// Make sure that state setting worked
|
||||
assert_equals(i.contentWindow.navigation.currentEntry.getState().key, "value");
|
||||
assert_not_equals(i.contentWindow.navigation.currentEntry.getState(), navState);
|
||||
|
||||
let start_url = i.contentWindow.location.href;
|
||||
let start_key = i.contentWindow.navigation.currentEntry.key;
|
||||
let start_id = i.contentWindow.navigation.currentEntry.id;
|
||||
let onnavigate_called = false;
|
||||
let promise_settled = false;
|
||||
i.contentWindow.navigation.onnavigate = t.step_func(e => {
|
||||
e.intercept();
|
||||
onnavigate_called = true;
|
||||
assert_equals(e.info, navInfo);
|
||||
assert_equals(e.navigationType, "reload");
|
||||
assert_equals(e.destination.getState().key, "value", "destination.getState()");
|
||||
assert_not_equals(e.destination.getState(), navState);
|
||||
});
|
||||
i.contentWindow.navigation.reload({ info: navInfo, state: undefined }).committed.then(t.step_func_done(() => {
|
||||
assert_true(onnavigate_called);
|
||||
assert_equals(i.contentWindow.location.href, start_url);
|
||||
assert_equals(i.contentWindow.navigation.currentEntry.key, start_key);
|
||||
assert_equals(i.contentWindow.navigation.currentEntry.id, start_id);
|
||||
assert_equals(i.contentWindow.navigation.currentEntry.getState().key, "value", "destination.getState()");
|
||||
assert_not_equals(i.contentWindow.navigation.currentEntry.getState(), navState);
|
||||
}));
|
||||
}));
|
||||
});
|
||||
}, "reload() variant with info and state: undefined counts the same as not present (because of Web IDL dictionary semantics), so preserves the state");
|
||||
</script>
|
||||
Reference in New Issue
Block a user