history-length-outer-page-navigation-not-reflected-in-fenced-inner.html (2624B)
1 <!DOCTYPE html> 2 <script src="utils.js"></script> 3 <title>history-length-outer-page-navigation-not-reflected-in-fenced-inner</title> 4 5 <body> 6 <script> 7 (async () => { 8 // This is a helper file that will servec as the document loaded inside 9 // a fenced frame b 'history-length-outer-page-navigation-not-reflected-in- 10 // fenced' Once loaded, it reports to the observed value of history.length to 11 // the server so that the outer document can assert the value is 1. 12 13 const [fenced_history_length_key, outer_page_ready_for_next_navigation_key, 14 embed_scope, embed_scope_reporting] = 15 parseKeylist(); 16 17 const url = new URL(location.href); 18 19 if (embed_scope == "outer_page::iframe"){ 20 ////////////// BEGIN NAVIGATIONS 21 // This block performs a sequence of 'kNavigationLimit' navigations in: 22 // -- the iframe 23 const kNavigationLimit = 5 24 25 const url = new URL(location.href); 26 27 // First, perform some real navigations as well as history.pushState to 28 // this same page. Normally this would increase `history.length`. 29 if (url.searchParams.get("navigationCount") == null) 30 url.searchParams.append("navigationCount", 1); 31 32 let navigationCount = parseInt(url.searchParams.get("navigationCount")); 33 34 if (navigationCount <= kNavigationLimit) { 35 url.searchParams.set('navigationCount', ++navigationCount); 36 location.href = url; 37 history.pushState({} , ""); 38 return; 39 } 40 ////////////// END 41 writeValueToServer(outer_page_ready_for_next_navigation_key, "READY"); 42 return 43 } 44 45 if (embed_scope == embed_scope_reporting) { 46 // Observe 'history.length' from within the 'embed_scope_reporting', 47 // and report the results back to the outer page. 48 if (history.length == 1) { 49 writeValueToServer(fenced_history_length_key, 50 "PASS > " + " history.length: " + history.length); 51 } else { 52 writeValueToServer(fenced_history_length_key, 53 "FAIL > " + " history.length: " + history.length); 54 } 55 return 56 } 57 58 if (embed_scope_reporting == "outer_page::fenced_frame::iframe") { 59 // Append an iframe to the 'outer_page::fenced_frame' to report 60 // history.length to the outer_page from within the iframe 61 const iframe = document.createElement('iframe'); 62 const embed_scope = "outer_page::fenced_frame::iframe"; 63 iframe.src = generateURL( 64 "history-length-outer-page-navigation-not-reflected-in-fenced-inner.html", 65 [fenced_history_length_key, outer_page_ready_for_next_navigation_key, 66 embed_scope, embed_scope_reporting]); 67 document.body.append(iframe); 68 return 69 } 70 })(); 71 </script> 72 </body>