intercept-history-pushState.html (927B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script> 5 async_test(t => { 6 let start_length = history.length; 7 8 let onpopstate_fired = false; 9 window.onpopstate = e => onpopstate_fired = true; 10 11 navigation.onnavigate = t.step_func(e => { 12 e.intercept({ handler: async () => { 13 await new Promise(r => t.step_timeout(r, 0)); 14 t.step_timeout(t.step_func_done(() => { 15 assert_equals(location.hash, "#1"); 16 assert_equals(history.state, "update"); 17 assert_equals(history.length, start_length + 1); 18 assert_false(onpopstate_fired); 19 }, 0)); 20 }}); 21 }); 22 23 history.pushState("update", "", "#1"); 24 assert_equals(location.hash, "#1"); 25 assert_equals(history.state, "update"); 26 assert_equals(history.length, start_length + 1); 27 }, "event.intercept() should proceed if the given promise resolves"); 28 </script>