mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Changes to regression tests for progressive loading
This commit is contained in:
parent
ef423ef30c
commit
6b2c6fc223
9 changed files with 61 additions and 24 deletions
10
src/api.js
10
src/api.js
|
@ -528,11 +528,14 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||
}
|
||||
WorkerTransport.prototype = {
|
||||
destroy: function WorkerTransport_destroy() {
|
||||
if (this.worker)
|
||||
this.worker.terminate();
|
||||
|
||||
this.pageCache = [];
|
||||
this.pagePromises = [];
|
||||
var self = this;
|
||||
this.messageHandler.send('Terminate', null, function () {
|
||||
if (self.worker) {
|
||||
self.worker.terminate();
|
||||
}
|
||||
});
|
||||
},
|
||||
setupFakeWorker: function WorkerTransport_setupFakeWorker() {
|
||||
warn('Setting up fake worker.');
|
||||
|
@ -733,6 +736,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||
},
|
||||
|
||||
fetchDocument: function WorkerTransport_fetchDocument(source) {
|
||||
source.disableAutoFetch = PDFJS.disableAutoFetch;
|
||||
source.chunkedViewerLoading = !!this.pdfDataRangeTransport;
|
||||
this.messageHandler.send('GetDocRequest', {
|
||||
source: source,
|
||||
|
|
|
@ -198,6 +198,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
|||
this.length = length;
|
||||
this.chunkSize = chunkSize;
|
||||
this.url = url;
|
||||
this.disableAutoFetch = args.disableAutoFetch;
|
||||
var msgHandler = this.msgHandler = args.msgHandler;
|
||||
|
||||
if (args.chunkedViewerLoading) {
|
||||
|
@ -382,7 +383,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
|||
|
||||
// If there are no pending requests, automatically fetch the next
|
||||
// unfetched chunk of the PDF
|
||||
if (isEmptyObj(this.requestsByChunk)) {
|
||||
if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
|
||||
var nextEmptyChunk;
|
||||
if (this.stream.numChunksLoaded === 1) {
|
||||
// This is a special optimization so that after fetching the first
|
||||
|
|
|
@ -118,7 +118,8 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() {
|
|||
var params = {
|
||||
msgHandler: msgHandler,
|
||||
httpHeaders: args.httpHeaders,
|
||||
chunkedViewerLoading: args.chunkedViewerLoading
|
||||
chunkedViewerLoading: args.chunkedViewerLoading,
|
||||
disableAutoFetch: args.disableAutoFetch
|
||||
};
|
||||
this.streamManager = new ChunkedStreamManager(args.length, CHUNK_SIZE,
|
||||
args.url, params);
|
||||
|
|
|
@ -292,6 +292,7 @@ var WorkerMessageHandler = {
|
|||
return;
|
||||
}
|
||||
|
||||
pdfManager.requestLoadedStream();
|
||||
pdfManager.onLoadedStream().then(function() {
|
||||
loadDocument(true).then(onSuccess, onFailure);
|
||||
});
|
||||
|
@ -430,6 +431,11 @@ var WorkerMessageHandler = {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
handler.on('Terminate', function wphTerminate(data, promise) {
|
||||
pdfManager.streamManager.networkManager.abortAllRequests();
|
||||
promise.resolve();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue