Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the Firefox-specific 'read with streaming' unit-test #10668

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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