Update packages

Jasmine had a major version bump and required a few minor changes in our
booting code. Most notably, using `pending` in a `describe` block is no
longer supported, so we can only return early there. On the positive
side, the unit tests now run in a random order by default, which
eliminates any dependencies between unit tests.

Note that upgrading to Webpack 4 is out of scope for this patch since
the bots cannot work well with the newly generated bundles (both
browsers on both bots do not react within 120 seconds). Webpack 4 is not
faster for us than Webpack 3, so for now there is no need to upgrade.
This commit is contained in:
Tim van der Meij 2018-03-17 19:56:39 +01:00
parent db6e316efd
commit 95de23e6e3
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762
6 changed files with 61 additions and 37 deletions

View File

@ -1292,7 +1292,7 @@ gulp.task('dist-pre', ['generic', 'components', 'lib', 'minified'], function() {
license: DIST_LICENSE, license: DIST_LICENSE,
dependencies: { dependencies: {
'node-ensure': '^0.0.0', // shim for node for require.ensure 'node-ensure': '^0.0.0', // shim for node for require.ensure
'worker-loader': '^1.1.0', // used in external/dist/webpack.json 'worker-loader': '^1.1.1', // used in external/dist/webpack.json
}, },
peerDependencies: { peerDependencies: {
'webpack': '^2.0.0 || ^3.0.0', // peerDependency of 'worker-loader' 'webpack': '^2.0.0 || ^3.0.0', // peerDependency of 'worker-loader'

View File

@ -2,15 +2,15 @@
"name": "pdf.js", "name": "pdf.js",
"version": "2.0.0", "version": "2.0.0",
"devDependencies": { "devDependencies": {
"acorn": "^5.3.0", "acorn": "^5.5.3",
"babel-core": "^6.26.0", "babel-core": "^6.26.0",
"babel-loader": "^7.1.2", "babel-loader": "^7.1.4",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-preset-env": "^1.6.1", "babel-preset-env": "^1.6.1",
"core-js": "^2.5.3", "core-js": "^2.5.3",
"escodegen": "^1.9.0", "escodegen": "^1.9.1",
"eslint": "^4.18.1", "eslint": "^4.19.1",
"eslint-plugin-mozilla": "^0.9.0", "eslint-plugin-mozilla": "^0.10.0",
"eslint-plugin-no-unsanitized": "^3.0.0", "eslint-plugin-no-unsanitized": "^3.0.0",
"fancy-log": "^1.3.2", "fancy-log": "^1.3.2",
"gulp": "^3.9.1", "gulp": "^3.9.1",
@ -18,25 +18,25 @@
"gulp-replace": "^0.6.1", "gulp-replace": "^0.6.1",
"gulp-transform": "^3.0.5", "gulp-transform": "^3.0.5",
"gulp-zip": "^4.1.0", "gulp-zip": "^4.1.0",
"jasmine": "^2.9.0", "jasmine": "^3.1.0",
"jasmine-core": "^2.9.1", "jasmine-core": "^3.1.0",
"jsdoc": "^3.5.5", "jsdoc": "^3.5.5",
"merge-stream": "^1.0.1", "merge-stream": "^1.0.1",
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"node-ensure": "^0.0.0", "node-ensure": "^0.0.0",
"rimraf": "^2.6.2", "rimraf": "^2.6.2",
"streamqueue": "^1.1.2", "streamqueue": "^1.1.2",
"systemjs": "^0.20.19", "systemjs": "^0.21.0",
"systemjs-plugin-babel": "^0.0.25", "systemjs-plugin-babel": "^0.0.25",
"ttest": "^1.1.0", "ttest": "^1.1.0",
"typogr": "^0.6.7", "typogr": "^0.6.7",
"uglify-es": "^3.3.9", "uglify-es": "^3.3.9",
"vinyl": "^2.1.0", "vinyl": "^2.1.0",
"vinyl-fs": "^2.4.4", "vinyl-fs": "^3.0.2",
"webpack": "^3.10.0", "webpack": "^3.11.0",
"webpack-stream": "^4.0.0", "webpack-stream": "^4.0.3",
"wintersmith": "^2.4.1", "wintersmith": "^2.4.1",
"yargs": "^9.0.1" "yargs": "^11.0.0"
}, },
"scripts": { "scripts": {
"test": "gulp lint unittestcli externaltest" "test": "gulp lint unittestcli externaltest"

View File

@ -76,9 +76,9 @@ function initializePDFJS(callback) {
}, },
}); });
var catchingExceptions = queryString.getParam('catch'); var stoppingOnSpecFailure = queryString.getParam('failFast');
env.catchExceptions(typeof catchingExceptions === 'undefined' ? env.stopOnSpecFailure(typeof stoppingOnSpecFailure === 'undefined' ?
true : catchingExceptions); false : stoppingOnSpecFailure);
var throwingExpectationFailures = queryString.getParam('throwFailures'); var throwingExpectationFailures = queryString.getParam('throwFailures');
env.throwOnExpectationFailure(throwingExpectationFailures); env.throwOnExpectationFailure(throwingExpectationFailures);
@ -94,8 +94,9 @@ function initializePDFJS(callback) {
// Reporters // Reporters
var htmlReporter = new jasmine.HtmlReporter({ var htmlReporter = new jasmine.HtmlReporter({
env, env,
onRaiseExceptionsClick() { onStopExecutionClick() {
queryString.navigateWithNewParam('catch', !env.catchingExceptions()); queryString.navigateWithNewParam('failFast',
env.stoppingOnSpecFailure());
}, },
onThrowExpectationsClick() { onThrowExpectationsClick() {
queryString.navigateWithNewParam('throwFailures', queryString.navigateWithNewParam('throwFailures',

View File

@ -318,11 +318,11 @@ describe('api', function() {
}); });
describe('PDFWorker', function() { describe('PDFWorker', function() {
if (isNodeJS()) {
pending('Worker is not supported in Node.js.');
}
it('worker created or destroyed', function (done) { it('worker created or destroyed', function (done) {
if (isNodeJS()) {
pending('Worker is not supported in Node.js.');
}
var worker = new PDFWorker({ name: 'test1', }); var worker = new PDFWorker({ name: 'test1', });
worker.promise.then(function () { worker.promise.then(function () {
expect(worker.name).toEqual('test1'); expect(worker.name).toEqual('test1');
@ -340,6 +340,10 @@ describe('api', function() {
}); });
}); });
it('worker created or destroyed by getDocument', function (done) { it('worker created or destroyed by getDocument', function (done) {
if (isNodeJS()) {
pending('Worker is not supported in Node.js.');
}
var loadingTask = getDocument(basicApiGetDocumentParams); var loadingTask = getDocument(basicApiGetDocumentParams);
var worker; var worker;
loadingTask.promise.then(function () { loadingTask.promise.then(function () {
@ -360,6 +364,10 @@ describe('api', function() {
}); });
}); });
it('worker created and can be used in getDocument', function (done) { it('worker created and can be used in getDocument', function (done) {
if (isNodeJS()) {
pending('Worker is not supported in Node.js.');
}
var worker = new PDFWorker({ name: 'test1', }); var worker = new PDFWorker({ name: 'test1', });
var loadingTask = getDocument( var loadingTask = getDocument(
buildGetDocumentParams(basicApiFileName, { buildGetDocumentParams(basicApiFileName, {
@ -385,6 +393,10 @@ describe('api', function() {
}); });
}); });
it('creates more than one worker', function (done) { it('creates more than one worker', function (done) {
if (isNodeJS()) {
pending('Worker is not supported in Node.js.');
}
var worker1 = new PDFWorker({ name: 'test1', }); var worker1 = new PDFWorker({ name: 'test1', });
var worker2 = new PDFWorker({ name: 'test2', }); var worker2 = new PDFWorker({ name: 'test2', });
var worker3 = new PDFWorker({ name: 'test3', }); var worker3 = new PDFWorker({ name: 'test3', });
@ -403,6 +415,10 @@ describe('api', function() {
}); });
}); });
it('gets current workerSrc', function() { it('gets current workerSrc', function() {
if (isNodeJS()) {
pending('Worker is not supported in Node.js.');
}
let workerSrc = PDFWorker.getWorkerSrc(); let workerSrc = PDFWorker.getWorkerSrc();
expect(typeof workerSrc).toEqual('string'); expect(typeof workerSrc).toEqual('string');
expect(workerSrc).toEqual(GlobalWorkerOptions.workerSrc); expect(workerSrc).toEqual(GlobalWorkerOptions.workerSrc);
@ -1190,10 +1206,7 @@ describe('api', function() {
]).then(done); ]).then(done);
}); });
}); });
describe('Multiple PDFJS instances', function() { describe('Multiple `getDocument` instances', function() {
if (isNodeJS()) {
pending('TODO: Support Canvas testing in Node.js.');
}
// Regression test for https://github.com/mozilla/pdf.js/issues/6205 // Regression test for https://github.com/mozilla/pdf.js/issues/6205
// A PDF using the Helvetica font. // A PDF using the Helvetica font.
var pdf1 = buildGetDocumentParams('tracemonkey.pdf'); var pdf1 = buildGetDocumentParams('tracemonkey.pdf');
@ -1247,6 +1260,10 @@ describe('api', function() {
}); });
it('should correctly render PDFs in parallel', function(done) { it('should correctly render PDFs in parallel', function(done) {
if (isNodeJS()) {
pending('TODO: Support Canvas testing in Node.js.');
}
var baseline1, baseline2, baseline3; var baseline1, baseline2, baseline3;
var promiseDone = renderPDF(pdf1).then(function(data1) { var promiseDone = renderPDF(pdf1).then(function(data1) {
baseline1 = data1; baseline1 = data1;
@ -1275,12 +1292,9 @@ describe('api', function() {
}); });
}); });
describe('PDFDataRangeTransport', function () { describe('PDFDataRangeTransport', function () {
if (isNodeJS()) {
pending('XMLHttpRequest is not supported in Node.js.');
}
var pdfPath = new URL('../pdfs/tracemonkey.pdf', window.location).href;
var loadPromise; var loadPromise;
function getDocumentData() { function getDocumentData() {
const pdfPath = new URL('../pdfs/tracemonkey.pdf', window.location).href;
if (loadPromise) { if (loadPromise) {
return loadPromise; return loadPromise;
} }
@ -1299,6 +1313,10 @@ describe('api', function() {
return loadPromise; return loadPromise;
} }
it('should fetch document info and page using ranges', function (done) { it('should fetch document info and page using ranges', function (done) {
if (isNodeJS()) {
pending('XMLHttpRequest is not supported in Node.js.');
}
var transport; var transport;
var initialDataLength = 4000; var initialDataLength = 4000;
var fetches = 0; var fetches = 0;
@ -1333,6 +1351,10 @@ describe('api', function() {
}); });
it('should fetch document info and page using range and streaming', it('should fetch document info and page using range and streaming',
function (done) { function (done) {
if (isNodeJS()) {
pending('XMLHttpRequest is not supported in Node.js.');
}
var transport; var transport;
var initialDataLength = 4000; var initialDataLength = 4000;
var fetches = 0; var fetches = 0;

View File

@ -83,7 +83,7 @@ describe('evaluator', function() {
}); });
}); });
it('should handle one operations', function(done) { it('should handle one operation', function(done) {
var stream = new StringStream('Q'); var stream = new StringStream('Q');
runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(),
function(result) { function(result) {
@ -108,7 +108,7 @@ describe('evaluator', function() {
}); });
}); });
it('should handle tree glued operations', function(done) { it('should handle three glued operations', function(done) {
var stream = new StringStream('fff'); var stream = new StringStream('fff');
runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(),
function (result) { function (result) {

View File

@ -124,9 +124,9 @@ function initializePDFJS(callback) {
}, },
}); });
var catchingExceptions = queryString.getParam('catch'); var stoppingOnSpecFailure = queryString.getParam('failFast');
env.catchExceptions(typeof catchingExceptions === 'undefined' ? env.stopOnSpecFailure(typeof stoppingOnSpecFailure === 'undefined' ?
true : catchingExceptions); false : stoppingOnSpecFailure);
var throwingExpectationFailures = queryString.getParam('throwFailures'); var throwingExpectationFailures = queryString.getParam('throwFailures');
env.throwOnExpectationFailure(throwingExpectationFailures); env.throwOnExpectationFailure(throwingExpectationFailures);
@ -142,8 +142,9 @@ function initializePDFJS(callback) {
// Reporters // Reporters
var htmlReporter = new jasmine.HtmlReporter({ var htmlReporter = new jasmine.HtmlReporter({
env, env,
onRaiseExceptionsClick() { onStopExecutionClick() {
queryString.navigateWithNewParam('catch', !env.catchingExceptions()); queryString.navigateWithNewParam('failFast',
env.stoppingOnSpecFailure());
}, },
onThrowExpectationsClick() { onThrowExpectationsClick() {
queryString.navigateWithNewParam('throwFailures', queryString.navigateWithNewParam('throwFailures',