navigate-form-traverse.html (1820B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <iframe id="iframe" name="i" src="/common/blank.html"></iframe> 5 <form id="form" action="/common/blank.html?1" method="post" target="i"></form> 6 <script> 7 async_test(t => { 8 window.onload = t.step_func(() => { 9 navigation.onnavigate = t.step_func_done(() => { 10 assert_unreached("onnavigate should not have fired in source window"); 11 }); 12 iframe.contentWindow.navigation.onnavigate = t.step_func(e => { 13 assert_equals(e.navigationType, "push"); 14 assert_not_equals(e.formData, null); 15 assert_equals(e.sourceElement, form); 16 17 iframe.onload = t.step_func(() => { 18 // Avoid the replace behavior that occurs if you navigate during the load handler 19 t.step_timeout(() => { 20 iframe.contentWindow.navigation.onnavigate = t.step_func(e => { 21 assert_equals(e.navigationType, "push"); 22 assert_equals(e.formData, null); 23 }); 24 25 iframe.contentWindow.onhashchange = t.step_func(() => { 26 iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => { 27 assert_equals(e.navigationType, "traverse"); 28 assert_equals(e.formData, null); 29 }); 30 31 // 3: go back 32 iframe.contentWindow.history.back(); 33 }); 34 35 // 2: navigate from /common/blank.html?1-with-form-data to /common/blank.html?1#1-with-form-data 36 iframe.contentWindow.location.hash = "#1"; 37 }, 0); 38 }); 39 }); 40 41 // 1: submit the form, navigating from /common/blank.html to /common/blank.html?1-with-form-data 42 form.submit(); 43 }); 44 }, "reloading a page created from form submission results in formData of null, not the original form data"); 45 </script>