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

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

Issue 1359613002: PDF: Prevent left/right arrow shortcuts when a PDF text field is focused. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename variable Created 5 years, 3 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/browser/resources/pdf/pdf.js ('k') | pdf/out_of_process_instance.cc » ('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 2015 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 resetDocument() {
6 window.viewer.viewport.goToPage(0);
7 window.viewer.viewport.setZoom(1);
8 window.viewer.isFormFieldFocused_ = false;
9 }
10
11 function getCurrentPage() {
12 return window.viewer.viewport.getMostVisiblePage();
13 }
14
15 var tests = [
16 /**
17 * Test that the left/right arrows change page back and forth.
18 */
19 function testPageChangesWithArrows() {
20 // Right arrow -> Go to page 2.
21 MockInteractions.pressAndReleaseKeyOn(document, 39);
22 chrome.test.assertEq(1, getCurrentPage());
23
24 // Left arrow -> Back to page 1.
25 MockInteractions.pressAndReleaseKeyOn(document, 37);
26 chrome.test.assertEq(0, getCurrentPage());
27
28 resetDocument();
29 chrome.test.succeed();
30 },
31
32 /**
33 * Test that when a PDF form field is focused, the left/right shortcuts are
34 * disabled. This doesn't test the plugin side of this feature.
35 */
36 function testPageDoesntChangeWhenFormFocused() {
37 // This should be set by a message from plugin -> page when a field is
38 // focused.
39 window.viewer.isFormFieldFocused_ = true;
40
41 // Page should not change when left/right are pressed.
42 MockInteractions.pressAndReleaseKeyOn(document, 39);
43 chrome.test.assertEq(0, getCurrentPage());
44
45 MockInteractions.pressAndReleaseKeyOn(document, 37);
46 chrome.test.assertEq(0, getCurrentPage());
47
48 resetDocument();
49 chrome.test.succeed();
50 },
51
52 /**
53 * Test that when the document is in fit to page, pressing page up/page down
54 * changes page back/forth.
55 */
56 function testPageDownInFitPage() {
57 window.viewer.viewport.fitToPage();
58
59 // Page down -> Go to page 2.
60 MockInteractions.pressAndReleaseKeyOn(document, 34);
61 chrome.test.assertEq(1, getCurrentPage());
62
63 // Page up -> Back to page 1.
64 MockInteractions.pressAndReleaseKeyOn(document, 33);
65 chrome.test.assertEq(0, getCurrentPage());
66
67 resetDocument();
68 chrome.test.succeed();
69 }
70 ];
71
72 importTestHelpers().then(function() {
73 chrome.test.runTests(tests);
74 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | pdf/out_of_process_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698