OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../../../resources/js-test.js"></script> |
| 5 </head> |
| 6 <body onload="runTest();"> |
| 7 |
| 8 <input id="input" type="text" value="editable text"><br> |
| 9 <span id="plain">This is plain text with no handler</span><br> |
| 10 <span id="consumes">This text consumes events using preventDefault()</span><br><
br> |
| 11 Clicking or tapping on the "consumes" section should have no effect on the selec
tion, |
| 12 but clicking in the plain section should clear it. |
| 13 |
| 14 <p id="description"></p> |
| 15 <div id="console"></div> |
| 16 |
| 17 <script> |
| 18 var plainResult = null; |
| 19 var consumesResult = null; |
| 20 |
| 21 function plainCallback() { |
| 22 } |
| 23 |
| 24 function consumeCallback(event) { |
| 25 event.preventDefault(); |
| 26 } |
| 27 |
| 28 function runTest() { |
| 29 document.getElementById('input').select(); |
| 30 var consumes = document.getElementById('consumes'); |
| 31 consumes.addEventListener("mousedown", consumeCallback, false); |
| 32 var plain = document.getElementById('plain'); |
| 33 plain.addEventListener("mousedown", plainCallback, false); |
| 34 |
| 35 if (window.testRunner) { |
| 36 testRunner.dumpAsText(); |
| 37 } |
| 38 |
| 39 if (window.eventSender) { |
| 40 description("This tests Tap events being consumed by a handler."); |
| 41 |
| 42 // A 'tap' gesture event should generate a sequence of mouse events, |
| 43 // which do not affect the selection when consumed. |
| 44 var consumesRect = document.getElementById('consumes').getBoundingClient
Rect(); |
| 45 consumesResult = eventSender.gestureTap(consumesRect.left, consumesRect.
top); |
| 46 shouldBe('consumesResult', 'true'); |
| 47 shouldNotBe('window.getSelection().toString()', ''); |
| 48 |
| 49 // Tapping on plain text does not consume the event, and clears the sele
ction. |
| 50 var plainRect = document.getElementById('plain').getBoundingClientRect()
; |
| 51 plainResult = eventSender.gestureTap(plainRect.left, plainRect.top); |
| 52 shouldBe('plainResult', 'false'); |
| 53 shouldBeEmptyString('window.getSelection().toString()'); |
| 54 } else { |
| 55 debug("This test requires DumpRenderTree. Tap on the text to log.") |
| 56 } |
| 57 } |
| 58 </script> |
| 59 </body> |
| 60 </html> |
OLD | NEW |