1 // Copyright 2014 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.
8 * These tests require that the PDF plugin be available to run correctly.
12 * Test that the page is sized to the size of the document.
14 function testPageSize() {
15 // Verify that the initial zoom is less than or equal to 100%.
16 chrome.test.assertTrue(viewer.viewport.zoom <= 1);
18 viewer.viewport.setZoom(1);
19 var sizer = document.getElementById('sizer');
20 chrome.test.assertEq(826, sizer.offsetWidth);
21 chrome.test.assertEq(1066 + viewer.viewport.topToolbarHeight_,
23 chrome.test.succeed();
26 function testAccessibility() {
27 scriptingAPI.getAccessibilityJSON(chrome.test.callbackPass(function(json) {
28 var dict = JSON.parse(json);
29 chrome.test.assertEq(true, dict.copyable);
30 chrome.test.assertEq(true, dict.loaded);
31 chrome.test.assertEq(1, dict.numberOfPages);
35 function testAccessibilityWithPage() {
36 scriptingAPI.getAccessibilityJSON(chrome.test.callbackPass(function(json) {
37 var dict = JSON.parse(json);
38 chrome.test.assertEq(612, dict.width);
39 chrome.test.assertEq(792, dict.height);
40 chrome.test.assertEq(1.0, dict.textBox[0].fontSize);
41 chrome.test.assertEq('text', dict.textBox[0].textNodes[0].type);
42 chrome.test.assertEq('this is some text',
43 dict.textBox[0].textNodes[0].text);
44 chrome.test.assertEq(1.0, dict.textBox[1].fontSize);
45 chrome.test.assertEq('text', dict.textBox[1].textNodes[0].type);
46 chrome.test.assertEq('some more text',
47 dict.textBox[1].textNodes[0].text);
51 function testGetSelectedText() {
52 var client = new PDFScriptingAPI(window, window);
54 client.getSelectedText(chrome.test.callbackPass(function(selectedText) {
55 chrome.test.assertEq('this is some text\nsome more text', selectedText);
60 * Test that the filename is used as the title.pdf.
62 function testHasCorrectTitle() {
63 chrome.test.assertEq('test.pdf', document.title);
65 chrome.test.succeed();
69 * Test that the escape key gets propogated to the outer frame (via the
70 * PDFScriptingAPI) in print preview.
72 function testEscKeyPropogationInPrintPreview() {
73 viewer.isPrintPreview_ = true;
74 scriptingAPI.setKeyEventCallback(chrome.test.callbackPass(function(e) {
75 chrome.test.assertEq(27, e.keyCode);
77 var e = document.createEvent('Event');
78 e.initEvent('keydown');
80 document.dispatchEvent(e);
84 var scriptingAPI = new PDFScriptingAPI(window, window);
85 scriptingAPI.setLoadCallback(function() {
86 chrome.test.runTests(tests);