Merge pull request #10668 from Snuffleupagus/rm-read_with_streaming-test

Remove the Firefox-specific 'read with streaming' unit-test
This commit is contained in:
Tim van der Meij 2019-03-22 22:54:41 +01:00 committed by GitHub
commit 9b5a937f78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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({
@ -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.