Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: chrome/test/data/pdf/basic_plugin_test.js

Issue 823813002: Modify pdf_scripting_api.js to support postMessage using BrowserPlugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/pdf/pdf_scripting_api.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 var scriptingAPI;
6
5 /** 7 /**
6 * These tests require that the PDF plugin be available to run correctly. 8 * These tests require that the PDF plugin be available to run correctly.
7 */ 9 */
8 var tests = [ 10 var tests = [
9 /** 11 /**
10 * Test that the page is sized to the size of the document. 12 * Test that the page is sized to the size of the document.
11 */ 13 */
12 function testPageSize() { 14 function testPageSize() {
13 // Verify that the initial zoom is less than or equal to 100%. 15 // Verify that the initial zoom is less than or equal to 100%.
14 chrome.test.assertTrue(viewer.viewport.zoom <= 1); 16 chrome.test.assertTrue(viewer.viewport.zoom <= 1);
15 17
16 viewer.viewport.setZoom(1); 18 viewer.viewport.setZoom(1);
17 var sizer = document.getElementById('sizer'); 19 var sizer = document.getElementById('sizer');
18 chrome.test.assertEq(826, sizer.offsetWidth); 20 chrome.test.assertEq(826, sizer.offsetWidth);
19 chrome.test.assertEq(1066, sizer.offsetHeight); 21 chrome.test.assertEq(1066, sizer.offsetHeight);
20 chrome.test.succeed(); 22 chrome.test.succeed();
21 }, 23 },
22 24
23 function testAccessibility() { 25 function testAccessibility() {
24 var client = new PDFScriptingAPI(window, window.location.origin); 26 scriptingAPI.getAccessibilityJSON(chrome.test.callbackPass(function(json) {
25 client.setDestinationWindow(window);
26 client.getAccessibilityJSON(chrome.test.callbackPass(function(json) {
27 var dict = JSON.parse(json); 27 var dict = JSON.parse(json);
28 chrome.test.assertEq(true, dict.copyable); 28 chrome.test.assertEq(true, dict.copyable);
29 chrome.test.assertEq(true, dict.loaded); 29 chrome.test.assertEq(true, dict.loaded);
30 chrome.test.assertEq(1, dict.numberOfPages); 30 chrome.test.assertEq(1, dict.numberOfPages);
31 })); 31 }));
32 }, 32 },
33 33
34 function testAccessibilityWithPage() { 34 function testAccessibilityWithPage() {
35 var client = new PDFScriptingAPI(window, window.location.origin); 35 scriptingAPI.getAccessibilityJSON(chrome.test.callbackPass(function(json) {
36 client.setDestinationWindow(window);
37 client.getAccessibilityJSON(chrome.test.callbackPass(function(json) {
38 var dict = JSON.parse(json); 36 var dict = JSON.parse(json);
39 chrome.test.assertEq(612, dict.width); 37 chrome.test.assertEq(612, dict.width);
40 chrome.test.assertEq(792, dict.height); 38 chrome.test.assertEq(792, dict.height);
41 chrome.test.assertEq(1.0, dict.textBox[0].fontSize); 39 chrome.test.assertEq(1.0, dict.textBox[0].fontSize);
42 chrome.test.assertEq('text', dict.textBox[0].textNodes[0].type); 40 chrome.test.assertEq('text', dict.textBox[0].textNodes[0].type);
43 chrome.test.assertEq('this is some text', 41 chrome.test.assertEq('this is some text',
44 dict.textBox[0].textNodes[0].text); 42 dict.textBox[0].textNodes[0].text);
45 chrome.test.assertEq(1.0, dict.textBox[1].fontSize); 43 chrome.test.assertEq(1.0, dict.textBox[1].fontSize);
46 chrome.test.assertEq('text', dict.textBox[1].textNodes[0].type); 44 chrome.test.assertEq('text', dict.textBox[1].textNodes[0].type);
47 chrome.test.assertEq('some more text', 45 chrome.test.assertEq('some more text',
48 dict.textBox[1].textNodes[0].text); 46 dict.textBox[1].textNodes[0].text);
49 }), 0); 47 }), 0);
50 } 48 }
51 ]; 49 ];
52 50
53 if (viewer.loaded) { 51 var scriptingAPI = new PDFScriptingAPI(window, window);
52 scriptingAPI.setLoadCallback(function() {
54 chrome.test.runTests(tests); 53 chrome.test.runTests(tests);
55 } else { 54 });
56 window.addEventListener('pdfload', function() {
57 chrome.test.runTests(tests);
58 });
59 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/pdf_scripting_api.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698