history-length-fenced-navigations-replace-do-not-contribute-to-joint.https.html (2685B)
1 <!DOCTYPE html> 2 <title>Test history.length in outermost document</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="resources/utils.js"></script> 6 <script src="/common/utils.js"></script> 7 8 <body> 9 <script> 10 promise_test(async () => { 11 const kInnerAssertion = "Navigations inside of a fenced frame are always " + 12 "replacement navigations and never increase " + 13 "`history.length` inside the fence: "; 14 const kOuterAssertion = "Navigations inside of a fenced frame never " + 15 "contribute to joint session history, or increase " + 16 "`history.length` outside the fence: "; 17 // This is used by 18 // `resources/history-length-fenced-navigations-replace-do-not-contribute-to-joint-inner.html` 19 // to let us know once a navigation is complete inside the fence. The inner 20 // page will test its `history.length` and report to us "PASS <frame type>" or 21 // "FAIL <frame type>" (the history length should be unaffected by the 22 // navigation). If the inner test passes, then we will check our 23 // `history.length` and ensure that the inner fenced navigation did not 24 // contribute to the joint session history. 25 const fenced_navigation_complete_key = token(); 26 // This is sent by us to the inner page to let it know that we're finished 27 // observing the effects of the last navigation, and that it should perform 28 // the next one for us to observe. 29 const outer_page_ready_for_next_fenced_navigation_key = token(); 30 31 const level = "top-level-fenced-frame"; 32 33 attachFencedFrame(generateURL( 34 "resources/history-length-fenced-navigations-replace-do-" + 35 "not-contribute-to-joint-inner.html", 36 [fenced_navigation_complete_key, 37 outer_page_ready_for_next_fenced_navigation_key, 38 level])); 39 40 const tests = ["top-level-fenced-frame", "nested-fenced-frame", "nested-iframe"]; 41 for (test_type of tests) { 42 // Wait for the fenced navigations to complete, and then see if they 43 // observable via the outermost `history.length`. 44 let result = await nextValueFromServer(fenced_navigation_complete_key); 45 assert_equals(result, "PASS > " + test_type, kInnerAssertion + test_type); 46 assert_equals(history.length, 1, kOuterAssertion + test_type); 47 48 // Acknowledge the results, and let the fenced frame know that we're ready 49 // to observe more fenced navigations. 50 writeValueToServer(outer_page_ready_for_next_fenced_navigation_key, "READY"); 51 } 52 }, "All fenced navigations should be replace-only and not contribute to joint " + 53 "session history"); 54 </script> 55 </body>