Skip to content

Commit

Permalink
Merge pull request #10668 from Snuffleupagus/rm-read_with_streaming-test
Browse files Browse the repository at this point in the history
Remove the Firefox-specific 'read with streaming' unit-test
  • Loading branch information
timvandermeij authored Mar 22, 2019
2 parents bce9ff7 + 234c1d2 commit 9b5a937
Showing 1 changed file with 0 additions and 54 deletions.
54 changes: 0 additions & 54 deletions test/unit/network_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import { PDFNetworkStream } from '../../src/display/network';
describe('network', function() {
var pdf1 = new URL('../pdfs/tracemonkey.pdf', window.location).href;
var pdf1Length = 1016315;
var pdf2 = new URL('../pdfs/pdf.pdf', window.location).href;
var pdf2Length = 32472771;

it('read without stream and range', function(done) {
var stream = new PDFNetworkStream({
Expand Down Expand Up @@ -62,58 +60,6 @@ describe('network', function() {
});
});

it('read with streaming', function(done) {
var userAgent = window.navigator.userAgent;
// The test is valid for FF only: the XHR has support of the
// 'moz-chunked-array' response type.
// TODO enable for other browsers, e.g. when fetch/streams API is supported.
var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(userAgent);
if (!m || m[1] < 9) {
expect(true).toEqual(true);
done();
return;
}

var stream = new PDFNetworkStream({
url: pdf2,
rangeChunkSize: 65536,
disableStream: false,
disableRange: false,
});

var fullReader = stream.getFullReader();

var isStreamingSupported, isRangeSupported;
var promise = fullReader.headersReady.then(function () {
isStreamingSupported = fullReader.isStreamingSupported;
isRangeSupported = fullReader.isRangeSupported;
});

var len = 0, count = 0;
var read = function () {
return fullReader.read().then(function (result) {
if (result.done) {
return;
}
count++;
len += result.value.byteLength;
return read();
});
};

var readPromise = Promise.all([read(), promise]);

readPromise.then(function () {
expect(len).toEqual(pdf2Length);
expect(count).toBeGreaterThan(1);
expect(isStreamingSupported).toEqual(true);
expect(isRangeSupported).toEqual(true);
done();
}).catch(function (reason) {
done.fail(reason);
});
});

it('read custom ranges', function (done) {
// We don't test on browsers that don't support range request, so
// requiring this test to pass.
Expand Down

0 comments on commit 9b5a937

Please sign in to comment.