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

Unified Diff: chrome/test/data/pdf/params_parser_test.js

Issue 918953002: Fix for PDFs with lots of named destinations take a long time to load. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/pdf/navigator_test.js ('k') | pdf/out_of_process_instance.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/pdf/params_parser_test.js
diff --git a/chrome/test/data/pdf/params_parser_test.js b/chrome/test/data/pdf/params_parser_test.js
index 34bccf59f57302197b71015dc1b44143dd97b293..30c27f9cadd534f7f0f014e9974f0e62fbbaa37f 100644
--- a/chrome/test/data/pdf/params_parser_test.js
+++ b/chrome/test/data/pdf/params_parser_test.js
@@ -7,66 +7,83 @@ var tests = [
* Test named destinations.
*/
function testParamsParser() {
- var paramsParser = new OpenPDFParamsParser();
- // Assigning page number for #nameddests.
- paramsParser.namedDestinations['RU'] = 26;
- paramsParser.namedDestinations['US'] = 0;
- paramsParser.namedDestinations['UY'] = 22;
+ var paramsParser = new OpenPDFParamsParser(function(name) {
+ if (name == 'RU')
+ paramsParser.onNamedDestinationReceived(26);
+ else if (name == 'US')
+ paramsParser.onNamedDestinationReceived(0);
+ else if (name == 'UY')
+ paramsParser.onNamedDestinationReceived(22);
+ else
+ paramsParser.onNamedDestinationReceived(-1);
+ });
var url = "http://xyz.pdf";
// Checking #nameddest.
- var urlParams = paramsParser.getViewportFromUrlParams(url + "#RU");
- chrome.test.assertEq(urlParams.page, 26);
+ paramsParser.getViewportFromUrlParams(
+ url + "#RU", function(viewportPosition) {
+ chrome.test.assertEq(viewportPosition.page, 26);
+ });
// Checking #nameddest=name.
- urlParams = paramsParser.getViewportFromUrlParams(url + "#nameddest=US");
- chrome.test.assertEq(urlParams.page, 0);
+ paramsParser.getViewportFromUrlParams(
+ url + "#nameddest=US", function(viewportPosition) {
+ chrome.test.assertEq(viewportPosition.page, 0);
+ });
// Checking #page=pagenum nameddest.The document first page has a pagenum
// value of 1.
- urlParams = paramsParser.getViewportFromUrlParams(url + "#page=6");
- chrome.test.assertEq(urlParams.page, 5);
+ paramsParser.getViewportFromUrlParams(
+ url + "#page=6", function(viewportPosition) {
+ chrome.test.assertEq(viewportPosition.page, 5);
+ });
// Checking #zoom=scale.
- urlParams = paramsParser.getViewportFromUrlParams(url + "#zoom=200");
- chrome.test.assertEq(urlParams.zoom, 2);
+ paramsParser.getViewportFromUrlParams(
+ url + "#zoom=200", function(viewportPosition) {
+ chrome.test.assertEq(viewportPosition.zoom, 2);
+ });
// Checking #zoom=scale,left,top.
- urlParams = paramsParser.getViewportFromUrlParams(url +
- "#zoom=200,100,200");
- chrome.test.assertEq(urlParams.zoom, 2);
- chrome.test.assertEq(urlParams.position.x, 100);
- chrome.test.assertEq(urlParams.position.y, 200);
+ paramsParser.getViewportFromUrlParams(
+ url + "#zoom=200,100,200", function(viewportPosition) {
+ chrome.test.assertEq(viewportPosition.zoom, 2);
+ chrome.test.assertEq(viewportPosition.position.x, 100);
+ chrome.test.assertEq(viewportPosition.position.y, 200);
+ });
// Checking #nameddest=name and zoom=scale.
- urlParams = paramsParser.getViewportFromUrlParams(url +
- "#nameddest=UY&zoom=150");
- chrome.test.assertEq(urlParams.page, 22);
- chrome.test.assertEq(urlParams.zoom, 1.5);
+ paramsParser.getViewportFromUrlParams(
+ url + "#nameddest=UY&zoom=150", function(viewportPosition) {
+ chrome.test.assertEq(viewportPosition.page, 22);
+ chrome.test.assertEq(viewportPosition.zoom, 1.5);
+ });
// Checking #page=pagenum and zoom=scale.
- urlParams = paramsParser.getViewportFromUrlParams(url +
- "#page=2&zoom=250");
- chrome.test.assertEq(urlParams.page, 1);
- chrome.test.assertEq(urlParams.zoom, 2.5);
+ paramsParser.getViewportFromUrlParams(
+ url + "#page=2&zoom=250", function(viewportPosition) {
+ chrome.test.assertEq(viewportPosition.page, 1);
+ chrome.test.assertEq(viewportPosition.zoom, 2.5);
+ });
// Checking #nameddest=name and zoom=scale,left,top.
- urlParams = paramsParser.getViewportFromUrlParams(url +
- "#nameddest=UY&zoom=150,100,200");
- chrome.test.assertEq(urlParams.page, 22);
- chrome.test.assertEq(urlParams.zoom, 1.5);
- chrome.test.assertEq(urlParams.position.x, 100);
- chrome.test.assertEq(urlParams.position.y, 200);
+ paramsParser.getViewportFromUrlParams(
+ url + "#nameddest=UY&zoom=150,100,200", function(viewportPosition) {
+ chrome.test.assertEq(viewportPosition.page, 22);
+ chrome.test.assertEq(viewportPosition.zoom, 1.5);
+ chrome.test.assertEq(viewportPosition.position.x, 100);
+ chrome.test.assertEq(viewportPosition.position.y, 200);
+ });
// Checking #page=pagenum and zoom=scale,left,top.
- urlParams = paramsParser.getViewportFromUrlParams(url +
- "#page=2&zoom=250,100,200");
- chrome.test.assertEq(urlParams.page, 1);
- chrome.test.assertEq(urlParams.zoom, 2.5);
- chrome.test.assertEq(urlParams.position.x, 100);
- chrome.test.assertEq(urlParams.position.y, 200);
-
+ paramsParser.getViewportFromUrlParams(
+ url + "#page=2&zoom=250,100,200", function(viewportPosition) {
+ chrome.test.assertEq(viewportPosition.page, 1);
+ chrome.test.assertEq(viewportPosition.zoom, 2.5);
+ chrome.test.assertEq(viewportPosition.position.x, 100);
+ chrome.test.assertEq(viewportPosition.position.y, 200);
+ });
chrome.test.succeed();
}
];
« no previous file with comments | « chrome/test/data/pdf/navigator_test.js ('k') | pdf/out_of_process_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698