OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * These tests require that the PDF plugin be available to run correctly. | 6 * These tests require that the PDF plugin be available to run correctly. |
7 */ | 7 */ |
8 var tests = [ | 8 var tests = [ |
9 /** | 9 /** |
10 * Test that the page is sized to the size of the document. | 10 * Test that the page is sized to the size of the document. |
11 */ | 11 */ |
12 function testPageSize() { | 12 function testPageSize() { |
13 // Verify that the initial zoom is less than or equal to 100%. | 13 // Verify that the initial zoom is 100%. |
14 chrome.test.assertTrue(viewer.viewport.zoom <= 1); | 14 chrome.test.assertEq(1, viewer.viewport.zoom); |
15 | 15 |
16 viewer.viewport.zoom = 1; | |
17 var sizer = document.getElementById('sizer'); | 16 var sizer = document.getElementById('sizer'); |
18 chrome.test.assertEq(826, sizer.offsetWidth); | 17 chrome.test.assertEq(826, sizer.offsetWidth); |
19 chrome.test.assertEq(1066, sizer.offsetHeight); | 18 chrome.test.assertEq(1066, sizer.offsetHeight); |
20 chrome.test.succeed(); | 19 chrome.test.succeed(); |
21 }, | 20 }, |
22 | 21 |
23 function testAccessibility() { | 22 function testAccessibility() { |
24 var client = new PDFScriptingAPI(window, window.location.origin); | 23 var client = new PDFScriptingAPI(window, window.location.origin); |
25 client.setDestinationWindow(window); | 24 client.setDestinationWindow(window); |
26 client.getAccessibilityJSON(chrome.test.callbackPass(function(json) { | 25 client.getAccessibilityJSON(chrome.test.callbackPass(function(json) { |
27 chrome.test.assertEq('{"copyable":true,"loaded":true,"numberOfPages":1}', | 26 chrome.test.assertEq('{"copyable":true,"loaded":true,"numberOfPages":1}', |
28 json); | 27 json); |
29 })); | 28 })); |
30 }, | 29 }, |
31 | 30 |
32 function testAccessibilityWithPage() { | 31 function testAccessibilityWithPage() { |
33 var client = new PDFScriptingAPI(window, window.location.origin); | 32 var client = new PDFScriptingAPI(window, window.location.origin); |
34 client.setDestinationWindow(window); | 33 client.setDestinationWindow(window); |
35 client.getAccessibilityJSON(chrome.test.callbackPass(function(json) { | 34 client.getAccessibilityJSON(chrome.test.callbackPass(function(json) { |
36 var dict = JSON.parse(json); | 35 var dict = JSON.parse(json); |
37 chrome.test.assertEq(612, dict.width); | 36 chrome.test.assertEq(612, dict.width); |
38 chrome.test.assertEq(792, dict.height); | 37 chrome.test.assertEq(792, dict.height); |
39 if (dict.textBox[0] && dict.textBox[1]) { | 38 chrome.test.assertEq(1.0, dict.textBox[0].fontSize); |
40 chrome.test.assertEq(1.0, dict.textBox[0].fontSize); | 39 chrome.test.assertEq('text', dict.textBox[0].textNodes[0].type); |
41 chrome.test.assertEq('text', dict.textBox[0].textNodes[0].type); | 40 chrome.test.assertEq('this is some text', |
42 chrome.test.assertEq('this is some text', | 41 dict.textBox[0].textNodes[0].text); |
43 dict.textBox[0].textNodes[0].text); | 42 chrome.test.assertEq(1.0, dict.textBox[1].fontSize); |
44 chrome.test.assertEq(1.0, dict.textBox[1].fontSize); | 43 chrome.test.assertEq('text', dict.textBox[1].textNodes[0].type); |
45 chrome.test.assertEq('text', dict.textBox[1].textNodes[0].type); | 44 chrome.test.assertEq('some more text', |
46 chrome.test.assertEq('some more text', | 45 dict.textBox[1].textNodes[0].text); |
47 dict.textBox[1].textNodes[0].text); | |
48 } else { | |
49 // TODO(raymes): Investigate the flakiness that's occuring with | |
50 // returning accessibility information in this test: crbug.com/378091. | |
51 console.error( | |
52 'Expected text boxes of accessibility data to be returned'); | |
53 } | |
54 }), 0); | 46 }), 0); |
55 } | 47 } |
56 ]; | 48 ]; |
57 | 49 |
58 window.addEventListener('pdfload', function() { | 50 window.addEventListener('pdfload', function() { |
59 chrome.test.runTests(tests); | 51 chrome.test.runTests(tests); |
60 }); | 52 }); |
OLD | NEW |