navigate-ancestor-by-name.https.html (2238B)
1 <!DOCTYPE html> 2 <title>Test named frame navigation of ancestors.</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/utils.js"></script> 6 <script src="/common/dispatcher/dispatcher.js"></script> 7 <script src="resources/utils.js"></script> 8 9 <body> 10 <script> 11 promise_test(async () => { 12 // This test uses the following layout: 13 // A: Top-level frame 14 // B: iframe 15 // C: fencedframe 16 // D: fencedframe 17 // E: iframe 18 // 19 // The purpose is to test that name resolution of navigation targets ignores 20 // ancestors beyond fence boundaries. 21 22 // Create an iframe B. 23 const B = attachIFrameContext(); 24 await B.execute(async () => { 25 window.name = "B"; 26 27 // Create a fenced frame C inside of it. 28 window.C = attachFencedFrameContext(); 29 await window.C.execute(async () => { 30 window.name = "C"; 31 32 // Navigate the target "B" from inside the fenced frame. 33 // It should open in a new tab due to fenced name lookup. 34 window.open("resources/dummy.html", "B"); 35 }); 36 }); 37 38 // Observe that it created a new window, and the frame B is still here. 39 await B.execute(async () => { 40 // Create a nested iframe and fenced frame. 41 await window.C.execute(async () => { 42 window.D = attachFencedFrameContext(); 43 window.E = attachIFrameContext(); 44 45 // Navigate the target "C" from inside the nested fenced frame. 46 // It should open in a new tab due to fenced name lookup. 47 await window.D.execute(async () => { 48 window.open("resources/dummy.html", "C"); 49 }); 50 }); 51 // Observe that it created a new window, and the frame C is still here. 52 await window.C.execute(async () => { 53 // Now attempt to navigate the target "C" from inside the iframe. 54 // It should open in a new tab with a console error, because sandboxed 55 // iframes (inherited from the fenced frame) are not allowed to navigate 56 // their ancestors. 57 await window.E.execute(() => { 58 window.open("resources/dummy.html", "C"); 59 }); 60 }); 61 62 // Observe that C is still here. 63 await window.C.execute(() => {}); 64 }); 65 }, 'navigate named ancestors'); 66 </script> 67 </body>