precommitHandler-window-stop-before-commit.html (1106B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="../navigation-methods/return-value/resources/helpers.js"></script> 5 <body> 6 <script> 7 promise_test(async t => { 8 // Wait for after the load event because window.stop() hangs the test harness 9 // if called before the load event. 10 await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0)); 11 12 navigation.onnavigate = e => { 13 e.intercept({ precommitHandler: async () => {} }); 14 }; 15 16 navigation.onnavigatesuccess = t.unreached_func("navigatesuccess must not fire"); 17 let navigateerror_called = false; 18 navigation.onnavigateerror = t.step_func(() => { 19 navigateerror_called = true; 20 assert_equals(location.hash, ""); 21 }); 22 23 let promises = navigation.navigate("#ShouldNotCommit"); 24 assert_equals(location.hash, ""); 25 26 window.stop(); 27 await assertBothRejectDOM(t, promises, "AbortError"); 28 29 assert_equals(location.hash, ""); 30 assert_true(navigateerror_called); 31 }, " precommitHandler with window.stop() before commit"); 32 </script> 33 </body>