going-back.sub.https.html (2242B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Parent is origin-keyed, child1 is site-keyed, child1 navigates to a different site, child2 gets inserted and is origin-keyed, child1 navigates back</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 7 <div id="log"></div> 8 9 <script type="module"> 10 import { 11 insertIframe, 12 navigateIframe, 13 waitForIframe, 14 setBothDocumentDomains, 15 testDifferentAgentClusters, 16 testSameAgentCluster, 17 } from "./resources/helpers.mjs"; 18 19 let frame1; 20 promise_setup(async () => { 21 frame1 = await insertIframe("{{hosts[][www]}}"); 22 }); 23 24 // Since they're different-origin, the parent's origin-keying request is 25 // respected, as is the child's non-request. So the parent ends up in the 26 // origin-keyed agent cluster and the child ends up in the site-keyed one. 27 testDifferentAgentClusters([self, 0], "Before navigation: parent to child1"); 28 29 // Navigate the iframe to a different site. These, of course, must not be in the 30 // same agent cluster. 31 32 promise_test(async () => { 33 await navigateIframe(frame1, "{{hosts[alt][]}}"); 34 }, "Navigation"); 35 36 // Now insert a second iframe, pointing to the same place as the first one 37 // originally did, but this time with origin-keying requested. Because of the 38 // historical map of agent cluster keys for the browsing context group, the new 39 // iframe should still end up in the site-keyed agent cluster. 40 41 promise_test(async () => { 42 await insertIframe("{{hosts[][www]}}", "?1"); 43 }, "Inserting a second iframe"); 44 45 testDifferentAgentClusters([self, 1], "After navigation: parent to child2"); 46 47 // Now navigate the first iframe back. The resulting Document should be put in 48 // the site-keyed agent cluster, together with the second iframe's Document. 49 50 promise_test(async () => { 51 const waitPromise = waitForIframe(frame1); 52 history.back(); 53 await waitPromise; 54 55 await setBothDocumentDomains(frames[0]); 56 }, "Going back in history (navigating back the first iframe)"); 57 58 testDifferentAgentClusters([self, 0], "After back: parent to child1"); 59 testDifferentAgentClusters([self, 1], "After back: parent to child2"); 60 testSameAgentCluster([0, 1], "child1 to child2"); 61 testSameAgentCluster([1, 0], "child2 to child1"); 62 </script>