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, sizer
.offsetHeight
);
22 chrome
.test
.succeed();
25 function testAccessibility() {
26 scriptingAPI
.getAccessibilityJSON(chrome
.test
.callbackPass(function(json
) {
27 var dict
= JSON
.parse(json
);
28 chrome
.test
.assertEq(true, dict
.copyable
);
29 chrome
.test
.assertEq(true, dict
.loaded
);
30 chrome
.test
.assertEq(1, dict
.numberOfPages
);
34 function testAccessibilityWithPage() {
35 scriptingAPI
.getAccessibilityJSON(chrome
.test
.callbackPass(function(json
) {
36 var dict
= JSON
.parse(json
);
37 chrome
.test
.assertEq(612, dict
.width
);
38 chrome
.test
.assertEq(792, dict
.height
);
39 chrome
.test
.assertEq(1.0, dict
.textBox
[0].fontSize
);
40 chrome
.test
.assertEq('text', dict
.textBox
[0].textNodes
[0].type
);
41 chrome
.test
.assertEq('this is some text',
42 dict
.textBox
[0].textNodes
[0].text
);
43 chrome
.test
.assertEq(1.0, dict
.textBox
[1].fontSize
);
44 chrome
.test
.assertEq('text', dict
.textBox
[1].textNodes
[0].type
);
45 chrome
.test
.assertEq('some more text',
46 dict
.textBox
[1].textNodes
[0].text
);
50 function testGetSelectedText() {
51 var client
= new PDFScriptingAPI(window
, window
);
53 client
.getSelectedText(chrome
.test
.callbackPass(function(selectedText
) {
54 chrome
.test
.assertEq('this is some text\nsome more text', selectedText
);
59 var scriptingAPI
= new PDFScriptingAPI(window
, window
);
60 scriptingAPI
.setLoadCallback(function() {
61 chrome
.test
.runTests(tests
);