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

Side by Side Diff: chrome/test/data/pdf/touch_handling_test.js

Issue 2887913002: Reland: Handle long press in PDF documents. (Closed)
Patch Set: Review feedback Created 3 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 unified diff | Download patch
« no previous file with comments | « chrome/test/data/pdf/gesture_detector_test.js ('k') | pdf/out_of_process_instance.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 function sendTouchStart(touches) {
6 var id = 0;
7 let touchList = touches.map(function(xy) {
8 var touchInit = {
9 identifier: id++,
10 target: viewer.plugin_,
11 clientX: xy.x,
12 clientY: xy.y,
13 };
14
15 return new window.Touch(touchInit);
16 });
17
18 viewer.plugin_.dispatchEvent(new TouchEvent('touchstart', {
19 touches: touchList,
20 targetTouches: touchList,
21 changedtouches: touchList
22 }));
23 }
24
25 function createContextMenuEvent() {
26 return new MouseEvent('contextmenu', {
27 cancelable: true,
28 sourceCapabilities: new InputDeviceCapabilities({firesTouchEvents: true})
29 });
30 }
31
32 var tests = [
33 // Test suppression of the context menu on single touch.
34 function testContextMenuSingleTouch() {
35 sendTouchStart([{x: 10, y: 10}]);
36
37 let event = createContextMenuEvent();
38 // Dispatch event will be false if the event is cancellable and one of the
39 // handlers called preventDefault.
40 chrome.test.assertFalse(document.dispatchEvent(event),
41 "Should have called preventDefault() for single touch.");
42 chrome.test.succeed();
43 },
44
45 // Test allowing of context menu on double touch.
46 function testContextMenuDoubleTouch() {
47 sendTouchStart([{x: 10, y: 10}, {x: 15, y: 15}]);
48
49 let event = createContextMenuEvent();
50 chrome.test.assertTrue(document.dispatchEvent(event),
51 "Should not have called preventDefault() for double touch.");
52 chrome.test.succeed();
53 },
54
55 // Test long press selects word. This test flakes out on some bots.
56 // The test passes locally on MacOS, ChromeOS and Linux. Disable until it's
57 // possible to repro the bot issue. https://crbug.com/723632
58 // function testLongPressSelectsText() {
59 // var client = new PDFScriptingAPI(window, window);
60 // sendTouchStart([{x: 336, y: 163}]);
61 // window.setTimeout(function() {
62 // client.getSelectedText(
63 // chrome.test.callbackPass(function(selectedText) {
64 // chrome.test.assertEq('some', selectedText);
65 // })
66 // );
67 // chrome.test.succeed();
68 // // 10k is the value for the action_timeout_ms_ in Chrome test_timeouts.cc
69 // }, 10000);
70 // }
71 ];
72
73 var scriptingAPI = new PDFScriptingAPI(window, window);
74 scriptingAPI.setLoadCallback(function() {
75 chrome.test.runTests(tests);
76 });
OLDNEW
« no previous file with comments | « chrome/test/data/pdf/gesture_detector_test.js ('k') | pdf/out_of_process_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698