| <!DOCTYPE html> |
| <title>Prerendering documents are not focused</title> |
| <meta name="timeout" content="long"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="resources/utils.js"></script> |
| <body> |
| <input type="text" id = "prerenderTextField"> |
| <script> |
| |
| setup(() => assertSpeculationRulesIsSupported()); |
| |
| promise_test(async t => { |
| const bc = new BroadcastChannel('prerender-channel'); |
| |
| document.getElementById('prerenderTextField').focus(); |
| assert_true( |
| document.hasFocus(), |
| 'Initial document should have focus.'); |
| |
| const gotMessage = new Promise(resolve => { |
| bc.addEventListener('message', e => { |
| resolve(e.data); |
| }, {once:true}); |
| }); |
| |
| // Start prerendering a page that accesses the focus state of the page. |
| startPrerendering(`resources/prerender-focus.html`); |
| |
| const result = await gotMessage; |
| assert_true(result.activeElementUpdated); |
| assert_false(result.documentHasFocus); |
| bc.close(); |
| }, 'Prerendering document should update the active element but not have focus'); |
| |
| </script> |
| </body> |