Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Unified Diff: LayoutTests/fast/events/touch/gesture/gesture-tap-result.html

Issue 267313008: First-cut at fixing unhandled Tap event returns in Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add Layout tests, and remove unit tests. Cleanup EventHandler. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/events/touch/gesture/gesture-tap-result-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | LayoutTests/fast/events/touch/gesture/gesture-tap-result-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698