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

Unified Diff: third_party/WebKit/LayoutTests/fast/events/touch/touch-user-gesture.html

Issue 1956493002: Remove user gestures on touches other than tap in cross-origin iframes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with trunk Created 4 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
Index: third_party/WebKit/LayoutTests/fast/events/touch/touch-user-gesture.html
diff --git a/third_party/WebKit/LayoutTests/fast/events/touch/touch-user-gesture.html b/third_party/WebKit/LayoutTests/fast/events/touch/touch-user-gesture.html
new file mode 100644
index 0000000000000000000000000000000000000000..d07fb5efe9f334001373aa626d0a5753cf9c922f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/touch/touch-user-gesture.html
@@ -0,0 +1,77 @@
+<script src="../../../resources/js-test.js"></script>
+<div id="target">Target</div>
+<div id="description">Test user gesture behavior during touch events.</div>
+<div id="console"></div>
+
+<script>
+
+var openedPopup = undefined;
+function handler(e) {
+ if (openedPopup !== undefined)
+ testFailed("Handler invoked multiple times");
+
+ var w = window.open("about:blank", "_blank");
+ if (w) {
+ w.close();
+ openedPopup = true;
+ } else {
+ openedPopup = false;
+ }
+}
+
+var target = document.getElementById('target');
+
+function testPopupOnEventDuring(eventType, expectPopup, operation) {
+ openedPopup = undefined;
+ target.addEventListener(eventType, handler);
+
+ operation();
+
+ if (openedPopup===undefined)
+ testFailed(eventType + ' handler was not invoked');
+ else if (expectPopup)
+ shouldBeTrue("openedPopup");
+ else
+ shouldBeFalse("openedPopup");
+
+ target.removeEventListener(eventType, handler);
+}
+
+if (window.testRunner) {
+ testRunner.setCloseRemainingWindowsWhenComplete(true);
+ testRunner.setCanOpenWindows();
+ testRunner.setPopupBlockingEnabled(true);
+}
+
+
+var rect = target.getBoundingClientRect();
+var targetX = rect.left + rect.width / 2;
+var targetY = rect.top + rect.height / 2;
+
+debug('touchstart should be a user gesture');
+eventSender.addTouchPoint(targetX, targetY);
+testPopupOnEventDuring('touchstart', true, function() { eventSender.touchStart(); });
+
+debug('touchend for the same gesture should not get a new gesture');
+eventSender.releaseTouchPoint(0);
+testPopupOnEventDuring('touchend', false, function() { eventSender.touchStart(); });
+
+debug('touchmove should be a user gesture');
+eventSender.addTouchPoint(targetX, targetY);
+eventSender.touchStart();
+eventSender.updateTouchPoint(0, targetX + 1, targetY);
+testPopupOnEventDuring('touchmove', true, function() { eventSender.touchMove("movedBeyondSlopRegion"); });
+
+debug('second touchmove for the same gesture should not get a new gesture');
+eventSender.updateTouchPoint(0, targetX + 2, targetY);
+testPopupOnEventDuring('touchmove', false, function() { eventSender.touchMove("movedBeyondSlopRegion"); });
+eventSender.releaseTouchPoint(0);
+eventSender.touchEnd();
+
+debug('touchend should be a user gesture');
+eventSender.addTouchPoint(targetX, targetY);
+eventSender.touchStart();
+eventSender.releaseTouchPoint(0);
+testPopupOnEventDuring('touchend', true, function() { eventSender.touchEnd(); });
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698