navigate-destination-getState-navigate.html (1042B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script> 5 async_test(t => { 6 // Wait for after the load event so that the navigation doesn't get converted 7 // into a replace navigation. 8 window.onload = () => t.step_timeout(() => { 9 let navState = { statevar: "state" }; 10 navigation.onnavigate = t.step_func_done(e => { 11 assert_equals(e.navigationType, "push"); 12 assert_not_equals(e.destination, null); 13 assert_not_equals(e.destination.getState(), undefined); 14 assert_equals(e.destination.getState().statevar, "state"); 15 assert_not_equals(e.destination.getState(), e.destination.getState()); 16 assert_equals(e.destination.key, ""); 17 assert_equals(e.destination.id, ""); 18 assert_equals(e.destination.index, -1); 19 assert_equals(e.sourceElement, null); 20 }); 21 navigation.navigate("#foo", { state: navState }); 22 }, 0); 23 }, "navigate event destination.getState() should be the state given to navigate()"); 24 </script>