precommitHandler-uncancelable.html (992B)
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 <body> 6 <script> 7 promise_test(async t => { 8 // Wait for after the load event so that the navigation doesn't get converted 9 // into a replace navigation. 10 await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0)); 11 12 await i.contentWindow.navigation.navigate("#1").finished; 13 14 i.contentWindow.navigation.onnavigate = t.step_func(e => { 15 assert_false(e.cancelable); 16 // intercept() with a precommitHandler is forbidden because e.cancelable is false. 17 let iframe_constructor = i.contentWindow.DOMException; 18 assert_throws_dom("InvalidStateError", iframe_constructor, 19 () => e.intercept({ precommitHandler: async () => {} })); 20 }); 21 await i.contentWindow.navigation.back().finished; 22 }, "precommitHandler for an uncancelable traverse navigation"); 23 </script> 24 </body>