| <!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> |
| <html> |
| <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> |
| <head> |
| <script src="../../../resources/basic-gestures.js"></script> |
| <script src="../../../resources/ui-helper.js"></script> |
| <style> |
| body { |
| margin: 0; |
| } |
| |
| #target { |
| font-size: 100px; |
| } |
| |
| #clickTarget { |
| width: 100px; |
| height: 100px; |
| background-color: green; |
| } |
| </style> |
| <script> |
| if (window.testRunner) { |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| } |
| |
| async function run() |
| { |
| if (!window.testRunner) |
| return; |
| |
| function didChangeSelection() |
| { |
| result.textContent = window.getSelection().toString() |
| } |
| |
| document.addEventListener("selectionchange", didChangeSelection); |
| |
| var clickTarget = document.getElementById("clickTarget"); |
| |
| clickTarget.addEventListener("click", event => { |
| event.preventDefault(); |
| |
| setTimeout(async function () { |
| // The test is done, but we need to tap again to ensure we don't |
| // hang the next test with a double tap. |
| document.removeEventListener("selectionchange", didChangeSelection); |
| await UIHelper.tapAt(10, 500); |
| |
| testRunner.notifyDone(); |
| }, 0); |
| }); |
| |
| var target = document.getElementById("target"); |
| window.getSelection().setBaseAndExtent(target, 0, target, 6); |
| |
| await UIHelper.activateElement(clickTarget); |
| } |
| </script> |
| </head> |
| <body onload="run()"> |
| <div id="target">WebKit</div> |
| <div id="clickTarget"></div> |
| <pre>The selected text is: "<span id="result"></span>"</pre> |
| <p>This test verifies that the DOM selection is not dismissed when tapping on an element that preventDefault()s the click event.</p> |
| </body> |
| </html> |