mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge pull request #1840 from yurydelendik/loadpdf-1
Moves loading of the binary PDF data to the worker
This commit is contained in:
commit
b3a603c199
9 changed files with 141 additions and 62 deletions
|
@ -98,7 +98,8 @@ function nextTask() {
|
|||
|
||||
log('Loading file "' + task.file + '"\n');
|
||||
|
||||
getPdf(task.file, function nextTaskGetPdf(data) {
|
||||
var absoluteUrl = combineUrl(window.location.href, task.file);
|
||||
getPdf(absoluteUrl, function nextTaskGetPdf(data) {
|
||||
var failure;
|
||||
function continuation() {
|
||||
task.pageNum = task.firstPage || 1;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
describe('api', function() {
|
||||
// TODO run with worker enabled
|
||||
PDFJS.disableWorker = true;
|
||||
var basicApiUrl = '../pdfs/basicapi.pdf';
|
||||
var basicApiUrl = combineUrl(window.location.href, '../pdfs/basicapi.pdf');
|
||||
function waitsForPromise(promise) {
|
||||
waitsFor(function() {
|
||||
return promise.isResolved || promise.isRejected;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
<script type="text/javascript" src="stream_spec.js"></script>
|
||||
<script type="text/javascript" src="api_spec.js"></script>
|
||||
<script type="text/javascript" src="metadata_spec.js"></script>
|
||||
<script type="text/javascript" src="util_spec.js"></script>
|
||||
<script type="text/javascript">
|
||||
'use strict';
|
||||
|
||||
|
|
51
test/unit/util_spec.js
Normal file
51
test/unit/util_spec.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
'use strict';
|
||||
|
||||
describe('util', function() {
|
||||
|
||||
describe('combineUrl', function() {
|
||||
it('absolute url with protocol stays as is', function() {
|
||||
var baseUrl = 'http://server/index.html';
|
||||
var url = 'http://server2/test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server2/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('absolute url without protocol uses prefix from base', function() {
|
||||
var baseUrl = 'http://server/index.html';
|
||||
var url = '/test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('combines relative url with base', function() {
|
||||
var baseUrl = 'http://server/index.html';
|
||||
var url = 'test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('combines relative url (w/hash) with base', function() {
|
||||
var baseUrl = 'http://server/index.html#!/test';
|
||||
var url = 'test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('combines relative url (w/query) with base', function() {
|
||||
var baseUrl = 'http://server/index.html?search=/test';
|
||||
var url = 'test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue