reload-info.html (2168B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <iframe id="i" src="/common/blank.html"></iframe> 5 <script> 6 async_test(t => { 7 window.onload = t.step_func(() => { 8 const navState = { key: "value" }; 9 const navInfo = { infoKey: "infoValue" }; 10 i.contentWindow.navigation.navigate("#1", { state: navState }).committed.then(t.step_func(() => { 11 // Make sure that state setting worked 12 assert_equals(i.contentWindow.navigation.currentEntry.getState().key, "value"); 13 assert_not_equals(i.contentWindow.navigation.currentEntry.getState(), navState); 14 15 let start_url = i.contentWindow.location.href; 16 let start_key = i.contentWindow.navigation.currentEntry.key; 17 let start_id = i.contentWindow.navigation.currentEntry.id; 18 let start_state = i.contentWindow.navigation.currentEntry.getState(); 19 let onnavigate_called = false; 20 let promise_settled = false; 21 i.contentWindow.navigation.onnavigate = t.step_func(e => { 22 onnavigate_called = true; 23 assert_equals(e.info, navInfo); 24 assert_equals(e.navigationType, "reload"); 25 assert_equals(e.destination.getState().key, "value"); 26 assert_not_equals(e.destination.getState(), start_state); 27 }); 28 i.contentWindow.navigation.reload({ info: navInfo }).committed.finally(() => { 29 promise_settled = true; 30 }); 31 i.onload = t.step_func(() => { 32 assert_true(onnavigate_called); 33 assert_equals(i.contentWindow.location.href, start_url); 34 assert_equals(i.contentWindow.navigation.currentEntry.key, start_key); 35 assert_equals(i.contentWindow.navigation.currentEntry.id, start_id); 36 assert_equals(i.contentWindow.navigation.currentEntry.getState().key, "value"); 37 assert_not_equals(i.contentWindow.navigation.currentEntry.getState(), start_state); 38 assert_equals(i.contentWindow.navigation.entries().length, 2); 39 40 t.step_timeout(t.step_func_done(() => { 41 assert_equals(promise_settled, false); 42 }), 0); 43 }); 44 })); 45 }); 46 }, "reload() variant with only info"); 47 </script>