navigate-history-back-after-fragment.html (1252B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script> 5 async_test(t => { 6 window.onload = () => t.step_timeout(() => { 7 let start_length = history.length; 8 let start_index = navigation.currentEntry.index; 9 let target_key = navigation.currentEntry.key; 10 let target_id = navigation.currentEntry.id; 11 location.hash = "#1"; 12 assert_equals(history.length, start_length + 1); 13 14 navigation.onnavigate = t.step_func_done(e => { 15 assert_equals(e.navigationType, "traverse"); 16 assert_true(e.cancelable); 17 assert_true(e.canIntercept); 18 assert_false(e.userInitiated); 19 assert_true(e.hashChange); 20 assert_equals(e.downloadRequest, null); 21 assert_equals(new URL(e.destination.url).hash, ""); 22 assert_true(e.destination.sameDocument); 23 assert_equals(e.destination.key, target_key); 24 assert_equals(e.destination.id, target_id); 25 assert_equals(e.destination.index, start_index); 26 assert_equals(e.formData, null); 27 assert_equals(e.sourceElement, null); 28 }); 29 30 history.back(); 31 }, 0); 32 }, "history.back() fires the navigate event and sets hashChange when reversing a fragment navigation"); 33 </script>