summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/pdf/basic_plugin_test.js
blob: 8413c52e1bd1d9837825fa3214d5fd470e98b6c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * These tests require that the PDF plugin be available to run correctly.
 */
var tests = [
  /**
   * Test that the page is sized to the size of the document.
   */
  function testPageSize() {
    // Verify that the initial zoom is 100%.
    chrome.test.assertEq(1, viewer.viewport.zoom);

    var sizer = document.getElementById('sizer');
    chrome.test.assertEq(826, sizer.offsetWidth);
    chrome.test.assertEq(1066, sizer.offsetHeight);
    chrome.test.succeed();
  },

  function testAccessibility() {
    var client = new PDFScriptingAPI(window, window.location.origin);
    client.setDestinationWindow(window);
    client.getAccessibilityJSON(chrome.test.callbackPass(function(json) {
      chrome.test.assertEq('{"copyable":true,"loaded":true,"numberOfPages":1}',
                           json);
    }));
  },

  function testAccessibilityWithPage() {
    var client = new PDFScriptingAPI(window, window.location.origin);
    client.setDestinationWindow(window);
    client.getAccessibilityJSON(chrome.test.callbackPass(function(json) {
      var dict = JSON.parse(json);
      chrome.test.assertEq(612, dict.width);
      chrome.test.assertEq(792, dict.height);
      chrome.test.assertEq(1.0, dict.textBox[0].fontSize);
      chrome.test.assertEq('text', dict.textBox[0].textNodes[0].type);
      chrome.test.assertEq('this is some text',
                           dict.textBox[0].textNodes[0].text);
      chrome.test.assertEq(1.0, dict.textBox[1].fontSize);
      chrome.test.assertEq('text', dict.textBox[1].textNodes[0].type);
      chrome.test.assertEq('some more text',
                           dict.textBox[1].textNodes[0].text);
    }), 0);
  }
];

window.addEventListener('pdfload', function() {
  chrome.test.runTests(tests);
});