Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / gesture / gesture-tap-result.html
blob326fab20adfdbb78c57a911249776aa50094f449
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();">
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 selection,
12 but clicking in the plain section should clear it.
14 <p id="description"></p>
15 <div id="console"></div>
17 <script>
18 var plainResult = null;
19 var consumesResult = null;
21 function plainCallback() {
24 function consumeCallback(event) {
25 event.preventDefault();
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);
35 if (window.testRunner) {
36 testRunner.dumpAsText();
39 if (window.eventSender) {
40 description("This tests Tap events being consumed by a handler.");
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').getBoundingClientRect();
45 consumesResult = eventSender.gestureTap(consumesRect.left, consumesRect.top);
46 shouldBe('consumesResult', 'true');
47 shouldNotBe('window.getSelection().toString()', '');
49 // Tapping on plain text does not consume the event, and clears the selection.
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.")
58 </script>
59 </body>
60 </html>