anchor-focus.https.html (1775B)
1 <!DOCTYPE html> 2 <title>Anchor based focusing across a fenced frame boundary</title> 3 <script src="/resources/testdriver.js"></script> 4 <script src="/resources/testdriver-actions.js"></script> 5 <script src="/resources/testdriver-vendor.js"></script> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/common/utils.js"></script> 9 <script src="/common/dispatcher/dispatcher.js"></script> 10 <script src="resources/utils.js"></script> 11 12 <body> 13 <script> 14 function attemptAutofocus(frame) { 15 return frame.execute(async () => { 16 let autofocusInput = document.createElement('input'); 17 autofocusInput.id = "myinput"; 18 document.body.appendChild(autofocusInput); 19 document.location.href = document.location.href + "#myinput"; 20 await new Promise(resolve => requestAnimationFrame(resolve)); 21 return document.activeElement == autofocusInput; 22 }); 23 } 24 25 promise_test(async () => { 26 const frame = attachFencedFrameContext(); 27 let autofocusIsFocused = await attemptAutofocus(frame); 28 assert_false(autofocusIsFocused, 29 "element should not get focus through anchor focusing"); 30 }, "Anchor focusing is blocked on an element in a fenced frame " + 31 "without user activation."); 32 33 promise_test(async () => { 34 const frame = attachFencedFrameContext(); 35 const actions = new test_driver.Actions(); 36 await actions.pointerMove(0, 0, {origin: frame.element}) 37 .pointerDown() 38 .pointerUp() 39 .send(); 40 let autofocusIsFocused = await attemptAutofocus(frame); 41 assert_true(autofocusIsFocused, 42 "element should get focus through anchor focusing"); 43 }, "Anchor focusing is allowed on an element in a fenced frame " + 44 "with user activation."); 45 </script> 46 </body> 47 </html>