Index: LayoutTests/fast/events/touch/gesture/gesture-tap-result.html |
diff --git a/LayoutTests/fast/events/touch/gesture/gesture-tap-result.html b/LayoutTests/fast/events/touch/gesture/gesture-tap-result.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1c28de953fff446db15fa60304731bacf2934c7a |
--- /dev/null |
+++ b/LayoutTests/fast/events/touch/gesture/gesture-tap-result.html |
@@ -0,0 +1,89 @@ |
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
+<html> |
+<head> |
+<script src="../../../../resources/js-test.js"></script> |
+</head> |
+<body onload="runTest();"> |
+ |
+<input id="input" type="text" value="editable text"> |
+<span id="plain">This is plain text with no handler</span> |
+<span id="consumes">This text consumes events using preventDefault()</span> |
+ |
+<p id="description"></p> |
+<div id="console"></div> |
+ |
+<script> |
+var mouseEventsReceived = 0; |
+var plainResult = null; |
+var consumesResult = null; |
+ |
+function plainCallback() { |
+ mouseEventsReceived++; |
+} |
+ |
+function consumeCallback(event) { |
+ mouseEventsReceived++; |
+ event.preventDefault(); |
+} |
+ |
+// Because we may not have a gesture recognizer, we send a key press |
+// event to end the test without temporal flakiness. |
Rick Byers
2014/06/03 14:41:54
Chrome now always has a "gesture recognizer" (the
donnd
2014/06/03 20:24:57
Sorry about not removing this earlier. I copied s
|
+function quitKeyToEndTest(event) { |
+ endTest(); |
+} |
+ |
+function endTest() { |
+ if (mouseEventsReceived == 0) { |
Rick Byers
2014/06/03 14:41:54
No reason to make this it's own function - just ke
donnd
2014/06/03 20:24:57
It looks like this isn't needed either. Also, tha
|
+ debug('Gesture manager not implemented on this platform.'); |
+ } |
+ // Bail. |
+ isSuccessfullyParsed(); |
+ testRunner.notifyDone(); |
+} |
+ |
+function runTest() { |
+ document.getElementById('input').select(); |
+ var consumes = document.getElementById('consumes'); |
+ consumes.addEventListener("mousedown", consumeCallback, false); |
+ consumes.addEventListener("click", consumeCallback, false); |
+ consumes.addEventListener("dblclick", consumeCallback, false); |
+ consumes.addEventListener("mouseup", consumeCallback, false); |
+ consumes.addEventListener("mousemove", consumeCallback, false); |
+ var plain = document.getElementById('plain'); |
+ plain.addEventListener("mousedown", plainCallback, false); |
+ plain.addEventListener("click", plainCallback, false); |
+ plain.addEventListener("dblclick", plainCallback, false); |
+ plain.addEventListener("mouseup", plainCallback, false); |
+ plain.addEventListener("mousemove", plainCallback, false); |
+ document.addEventListener("keydown", quitKeyToEndTest, false); |
+ |
+ if (window.testRunner) { |
+ testRunner.dumpAsText(); |
+ testRunner.waitUntilDone(); |
+ } |
+ |
+ if (window.eventSender) { |
+ description("This tests Tap events being consumed by a handler."); |
+ |
+ // A 'tap' gesture event should generate a sequence of mouse events, |
+ // which do not affect the selection when consumed. |
+ var consumesRect = document.getElementById('consumes').getBoundingClientRect(); |
+ consumesResult = eventSender.gestureTap(consumesRect.left, consumesRect.top); |
+ shouldBe('consumesResult', 'true'); |
+ shouldNotBe('window.getSelection().toString()', ''); |
+ |
+ // Tapping on plain text does not consume the event, and clears the selection. |
+ var plainRect = document.getElementById('plain').getBoundingClientRect(); |
+ plainResult = eventSender.gestureTap(plainRect.left, plainRect.top); |
+ shouldBe('plainResult', 'false'); |
+ shouldBeEmptyString('window.getSelection().toString()'); |
+ |
+ eventSender.leapForward(10); |
Rick Byers
2014/06/03 14:41:54
Is this necessary? I thought the saved events / l
donnd
2014/06/03 20:24:57
Done.
|
+ eventSender.keyDown(' '); |
+ } else { |
+ debug("This test requires DumpRenderTree. Tap on the text to log.") |
+ } |
+} |
+</script> |
+</body> |
+</html> |