Update CrOS OOBE throbber to MD throbber; delete old asset
[chromium-blink-merge.git] / chrome / test / data / pdf / params_parser_test.js
blob30c27f9cadd534f7f0f014e9974f0e62fbbaa37f
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.
5 var tests = [
6 /**
7 * Test named destinations.
8 */
9 function testParamsParser() {
10 var paramsParser = new OpenPDFParamsParser(function(name) {
11 if (name == 'RU')
12 paramsParser.onNamedDestinationReceived(26);
13 else if (name == 'US')
14 paramsParser.onNamedDestinationReceived(0);
15 else if (name == 'UY')
16 paramsParser.onNamedDestinationReceived(22);
17 else
18 paramsParser.onNamedDestinationReceived(-1);
19 });
21 var url = "http://xyz.pdf";
23 // Checking #nameddest.
24 paramsParser.getViewportFromUrlParams(
25 url + "#RU", function(viewportPosition) {
26 chrome.test.assertEq(viewportPosition.page, 26);
27 });
29 // Checking #nameddest=name.
30 paramsParser.getViewportFromUrlParams(
31 url + "#nameddest=US", function(viewportPosition) {
32 chrome.test.assertEq(viewportPosition.page, 0);
33 });
35 // Checking #page=pagenum nameddest.The document first page has a pagenum
36 // value of 1.
37 paramsParser.getViewportFromUrlParams(
38 url + "#page=6", function(viewportPosition) {
39 chrome.test.assertEq(viewportPosition.page, 5);
40 });
42 // Checking #zoom=scale.
43 paramsParser.getViewportFromUrlParams(
44 url + "#zoom=200", function(viewportPosition) {
45 chrome.test.assertEq(viewportPosition.zoom, 2);
46 });
48 // Checking #zoom=scale,left,top.
49 paramsParser.getViewportFromUrlParams(
50 url + "#zoom=200,100,200", function(viewportPosition) {
51 chrome.test.assertEq(viewportPosition.zoom, 2);
52 chrome.test.assertEq(viewportPosition.position.x, 100);
53 chrome.test.assertEq(viewportPosition.position.y, 200);
54 });
56 // Checking #nameddest=name and zoom=scale.
57 paramsParser.getViewportFromUrlParams(
58 url + "#nameddest=UY&zoom=150", function(viewportPosition) {
59 chrome.test.assertEq(viewportPosition.page, 22);
60 chrome.test.assertEq(viewportPosition.zoom, 1.5);
61 });
63 // Checking #page=pagenum and zoom=scale.
64 paramsParser.getViewportFromUrlParams(
65 url + "#page=2&zoom=250", function(viewportPosition) {
66 chrome.test.assertEq(viewportPosition.page, 1);
67 chrome.test.assertEq(viewportPosition.zoom, 2.5);
68 });
70 // Checking #nameddest=name and zoom=scale,left,top.
71 paramsParser.getViewportFromUrlParams(
72 url + "#nameddest=UY&zoom=150,100,200", function(viewportPosition) {
73 chrome.test.assertEq(viewportPosition.page, 22);
74 chrome.test.assertEq(viewportPosition.zoom, 1.5);
75 chrome.test.assertEq(viewportPosition.position.x, 100);
76 chrome.test.assertEq(viewportPosition.position.y, 200);
77 });
79 // Checking #page=pagenum and zoom=scale,left,top.
80 paramsParser.getViewportFromUrlParams(
81 url + "#page=2&zoom=250,100,200", function(viewportPosition) {
82 chrome.test.assertEq(viewportPosition.page, 1);
83 chrome.test.assertEq(viewportPosition.zoom, 2.5);
84 chrome.test.assertEq(viewportPosition.position.x, 100);
85 chrome.test.assertEq(viewportPosition.position.y, 200);
86 });
87 chrome.test.succeed();
91 var scriptingAPI = new PDFScriptingAPI(window, window);
92 scriptingAPI.setLoadCallback(function() {
93 chrome.test.runTests(tests);
94 });