| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../../resources/js-test.js"></script> |
| <script src="../../../../resources/ui-helper.js"></script> |
| <style> |
| html, body { |
| width: 100%; |
| height: 100%; |
| margin: 0; |
| } |
| |
| iframe { |
| width: 320px; |
| height: 320px; |
| } |
| </style> |
| <script> |
| jsTestIsAsync = true; |
| |
| description("Verifies that focus doesn't move into the subframe when preventDefault() is invoked on touchstart. To test manually, tap the button and check that the top level frame does not lose focus."); |
| |
| addEventListener("blur", () => testFailed("Top level frame lost focus.")); |
| addEventListener("load", async () => { |
| document.body.addEventListener("touchstart", e => e.preventDefault(), { passive: false }); |
| if (!window.testRunner || !testRunner.runUIScript) |
| return; |
| |
| await UIHelper.activateElement(document.querySelector("iframe")); |
| shouldBe("document.activeElement", "document.body"); |
| finishJSTest(); |
| }); |
| </script> |
| </head> |
| <body> |
| <iframe srcdoc=" |
| <style> |
| body, html, button { |
| width: 100%; |
| height: 100%; |
| } |
| </style> |
| <body> |
| <button>Tap here</button> |
| </body> |
| <script> |
| document.body.addEventListener('touchstart', e => e.preventDefault(), { passive: false }); |
| </script> |
| "></iframe> |
| <pre id="description"></pre> |
| <pre id="console"></pre> |
| </body> |
| </html> |