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

Unified Diff: chrome/test/data/pdf/gesture_detector_test.js

Issue 2612773006: PDF viewer: Specify that the touchstart listener not be passive. (Closed)
Patch Set: Created 3 years, 11 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 | « chrome/browser/resources/pdf/gesture_detector.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/pdf/gesture_detector_test.js
diff --git a/chrome/test/data/pdf/gesture_detector_test.js b/chrome/test/data/pdf/gesture_detector_test.js
index b73b85aed5bb7ad83fa04638b055c5b8bdc69e58..b238294f46104158a05031333ba6336b12edb937 100644
--- a/chrome/test/data/pdf/gesture_detector_test.js
+++ b/chrome/test/data/pdf/gesture_detector_test.js
@@ -7,21 +7,25 @@ chrome.test.runTests(function() {
class StubElement {
constructor() {
- this.listeners_ = new Map([
+ this.listeners = new Map([
['touchstart', []],
['touchmove', []],
['touchend', []],
['touchcancel', []]
]);
+
+ this.listenerOptions = new Map();
}
- addEventListener(type, listener) {
- if (this.listeners_.has(type))
- this.listeners_.get(type).push(listener);
+ addEventListener(type, listener, options) {
+ if (this.listeners.has(type)) {
+ this.listeners.get(type).push(listener);
+ this.listenerOptions.set(listener, options);
+ }
}
sendEvent(event) {
- for (let l of this.listeners_.get(event.type))
+ for (let l of this.listeners.get(event.type))
l(event);
}
}
@@ -178,6 +182,17 @@ chrome.test.runTests(function() {
let gestureDetector = new GestureDetector(stubElement);
let pinchListener = new PinchListener(gestureDetector);
+ // Ensure that the touchstart listener is not passive, otherwise the
+ // call to preventDefault will be ignored. Since listeners could default
+ // to being passive, we must set the value explicitly
+ // (see crbug.com/675730).
+ for (let l of stubElement.listeners.get('touchstart')) {
+ let options = stubElement.listenerOptions.get(l);
+ chrome.test.assertTrue(!!options &&
+ typeof(options.passive) == 'boolean');
+ chrome.test.assertFalse(options.passive);
+ }
+
let pinchStartEvent = new MockTouchEvent('touchstart', [
{clientX: 0, clientY: 0},
{clientX: 0, clientY: 2}
« no previous file with comments | « chrome/browser/resources/pdf/gesture_detector.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698