Browse Source

PDF.js version 1.8.351 - See mozilla/pdf.js@63597cc55620d5816c59a673c3fa262bb87483c6

pdfjsbot 8 years ago
parent
commit
03b9ab01a1

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "1.8.349",
+  "version": "1.8.351",
   "main": [
     "build/pdf.js",
     "build/pdf.worker.js"

+ 6 - 6
build/pdf.combined.js

@@ -12822,8 +12822,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
 }();
 var version, build;
 {
-  exports.version = version = '1.8.349';
-  exports.build = build = '028d3421';
+  exports.version = version = '1.8.351';
+  exports.build = build = '63597cc5';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;
@@ -28229,8 +28229,8 @@ if (!_util.globalScope.PDFJS) {
 }
 var PDFJS = _util.globalScope.PDFJS;
 {
-  PDFJS.version = '1.8.349';
-  PDFJS.build = '028d3421';
+  PDFJS.version = '1.8.351';
+  PDFJS.build = '63597cc5';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {
@@ -43816,8 +43816,8 @@ exports.TilingPattern = TilingPattern;
 "use strict";
 
 
-var pdfjsVersion = '1.8.349';
-var pdfjsBuild = '028d3421';
+var pdfjsVersion = '1.8.351';
+var pdfjsBuild = '63597cc5';
 var pdfjsSharedUtil = __w_pdfjs_require__(0);
 var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
 var pdfjsDisplayAPI = __w_pdfjs_require__(10);

File diff suppressed because it is too large
+ 0 - 0
build/pdf.combined.js.map


+ 8 - 7
build/pdf.js

@@ -2175,7 +2175,8 @@ if (typeof __pdfjsdev_webpack__ === 'undefined') {
   var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load;
   fakeWorkerFilesLoader = useRequireEnsure ? function (callback) {
     require.ensure([], function () {
-      var worker = require('./pdf.worker.js');
+      var worker;
+      worker = require('./pdf.worker.js');
       callback(worker.WorkerMessageHandler);
     });
   } : dynamicLoaderSupported ? function (callback) {
@@ -3529,8 +3530,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
 }();
 var version, build;
 {
-  exports.version = version = '1.8.349';
-  exports.build = build = '028d3421';
+  exports.version = version = '1.8.351';
+  exports.build = build = '63597cc5';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;
@@ -5503,8 +5504,8 @@ if (!_util.globalScope.PDFJS) {
 }
 var PDFJS = _util.globalScope.PDFJS;
 {
-  PDFJS.version = '1.8.349';
-  PDFJS.build = '028d3421';
+  PDFJS.version = '1.8.351';
+  PDFJS.build = '63597cc5';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {
@@ -7999,8 +8000,8 @@ exports.TilingPattern = TilingPattern;
 "use strict";
 
 
-var pdfjsVersion = '1.8.349';
-var pdfjsBuild = '028d3421';
+var pdfjsVersion = '1.8.351';
+var pdfjsBuild = '63597cc5';
 var pdfjsSharedUtil = __w_pdfjs_require__(0);
 var pdfjsDisplayGlobal = __w_pdfjs_require__(9);
 var pdfjsDisplayAPI = __w_pdfjs_require__(3);

File diff suppressed because it is too large
+ 0 - 0
build/pdf.js.map


File diff suppressed because it is too large
+ 0 - 0
build/pdf.min.js


+ 2 - 2
build/pdf.worker.js

@@ -37144,8 +37144,8 @@ exports.Type1Parser = Type1Parser;
 "use strict";
 
 
-var pdfjsVersion = '1.8.349';
-var pdfjsBuild = '028d3421';
+var pdfjsVersion = '1.8.351';
+var pdfjsBuild = '63597cc5';
 var pdfjsCoreWorker = __w_pdfjs_require__(8);
 {
   __w_pdfjs_require__(19);

File diff suppressed because it is too large
+ 0 - 0
build/pdf.worker.js.map


+ 4 - 3
lib/display/api.js

@@ -58,7 +58,8 @@ if (typeof __pdfjsdev_webpack__ === 'undefined') {
   var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load;
   fakeWorkerFilesLoader = useRequireEnsure ? function (callback) {
     require.ensure([], function () {
-      var worker = require('./pdf.worker.js');
+      var worker;
+      worker = require('../pdf.worker.js');
       callback(worker.WorkerMessageHandler);
     });
   } : dynamicLoaderSupported ? function (callback) {
@@ -1412,8 +1413,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
 }();
 var version, build;
 {
-  exports.version = version = '1.8.349';
-  exports.build = build = '028d3421';
+  exports.version = version = '1.8.351';
+  exports.build = build = '63597cc5';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;

+ 2 - 2
lib/display/global.js

@@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) {
 }
 var PDFJS = _util.globalScope.PDFJS;
 {
-  PDFJS.version = '1.8.349';
-  PDFJS.build = '028d3421';
+  PDFJS.version = '1.8.351';
+  PDFJS.build = '63597cc5';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {

+ 2 - 2
lib/pdf.js

@@ -14,8 +14,8 @@
  */
 'use strict';
 
-var pdfjsVersion = '1.8.349';
-var pdfjsBuild = '028d3421';
+var pdfjsVersion = '1.8.351';
+var pdfjsBuild = '63597cc5';
 var pdfjsSharedUtil = require('./shared/util.js');
 var pdfjsDisplayGlobal = require('./display/global.js');
 var pdfjsDisplayAPI = require('./display/api.js');

+ 2 - 2
lib/pdf.worker.js

@@ -14,8 +14,8 @@
  */
 'use strict';
 
-var pdfjsVersion = '1.8.349';
-var pdfjsBuild = '028d3421';
+var pdfjsVersion = '1.8.351';
+var pdfjsBuild = '63597cc5';
 var pdfjsCoreWorker = require('./core/worker.js');
 {
   require('./core/network.js');

+ 122 - 105
lib/test/unit/api_spec.js

@@ -22,18 +22,42 @@ var _dom_utils = require('../../display/dom_utils');
 
 var _api = require('../../display/api');
 
+var _test_utils = require('./test_utils');
+
 var _global = require('../../display/global');
 
+var TEST_PDFS_PATH = {
+  dom: '../pdfs/',
+  node: './test/pdfs/'
+};
+function buildGetDocumentParams(filename, options) {
+  var params = Object.create(null);
+  if ((0, _util.isNodeJS)()) {
+    params.data = _test_utils.NodeFileReaderFactory.fetch({ path: TEST_PDFS_PATH.node + filename });
+  } else {
+    params.url = new URL(TEST_PDFS_PATH.dom + filename, window.location).href;
+  }
+  for (var option in options) {
+    params[option] = options[option];
+  }
+  return params;
+}
 describe('api', function () {
-  var basicApiUrl = new URL('../pdfs/basicapi.pdf', window.location).href;
+  var basicApiFileName = 'basicapi.pdf';
   var basicApiFileLength = 105779;
-  var CanvasFactory;
+  var basicApiGetDocumentParams = buildGetDocumentParams(basicApiFileName);
+  var CanvasFactory = void 0;
   beforeAll(function (done) {
-    CanvasFactory = new _dom_utils.DOMCanvasFactory();
+    if ((0, _util.isNodeJS)()) {
+      _global.PDFJS.pdfjsNext = true;
+    } else {
+      CanvasFactory = new _dom_utils.DOMCanvasFactory();
+    }
     done();
   });
-  afterAll(function () {
+  afterAll(function (done) {
     CanvasFactory = null;
+    done();
   });
   function waitSome(callback) {
     var WAIT_TIMEOUT = 10;
@@ -44,7 +68,10 @@ describe('api', function () {
   describe('PDFJS', function () {
     describe('getDocument', function () {
       it('creates pdf doc from URL', function (done) {
-        var loadingTask = _global.PDFJS.getDocument(basicApiUrl);
+        if ((0, _util.isNodeJS)()) {
+          pending('XMLHttpRequest is not supported in Node.js.');
+        }
+        var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
         var isProgressReportedResolved = false;
         var progressReportedCapability = (0, _util.createPromiseCapability)();
         loadingTask.onProgress = function (progressData) {
@@ -64,7 +91,10 @@ describe('api', function () {
         });
       });
       it('creates pdf doc from URL and aborts before worker initialized', function (done) {
-        var loadingTask = _global.PDFJS.getDocument(basicApiUrl);
+        if ((0, _util.isNodeJS)()) {
+          pending('XMLHttpRequest is not supported in Node.js.');
+        }
+        var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
         var destroyed = loadingTask.destroy();
         loadingTask.promise.then(function (reason) {
           done.fail('shall fail loading');
@@ -74,7 +104,10 @@ describe('api', function () {
         });
       });
       it('creates pdf doc from URL and aborts loading after worker initialized', function (done) {
-        var loadingTask = _global.PDFJS.getDocument(basicApiUrl);
+        if ((0, _util.isNodeJS)()) {
+          pending('XMLHttpRequest is not supported in Node.js.');
+        }
+        var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
         var destroyed = loadingTask._worker.promise.then(function () {
           return loadingTask.destroy();
         });
@@ -86,32 +119,33 @@ describe('api', function () {
         });
       });
       it('creates pdf doc from typed array', function (done) {
-        var nonBinaryRequest = _global.PDFJS.disableWorker;
-        var request = new XMLHttpRequest();
-        request.open('GET', basicApiUrl, false);
-        if (!nonBinaryRequest) {
-          try {
-            request.responseType = 'arraybuffer';
-            nonBinaryRequest = request.responseType !== 'arraybuffer';
-          } catch (e) {
-            nonBinaryRequest = true;
-          }
-        }
-        if (nonBinaryRequest && request.overrideMimeType) {
-          request.overrideMimeType('text/plain; charset=x-user-defined');
-        }
-        request.send(null);
         var typedArrayPdf;
-        if (nonBinaryRequest) {
-          var data = Array.prototype.map.call(request.responseText, function (ch) {
-            return ch.charCodeAt(0) & 0xFF;
-          });
-          typedArrayPdf = new Uint8Array(data);
+        if ((0, _util.isNodeJS)()) {
+          typedArrayPdf = _test_utils.NodeFileReaderFactory.fetch({ path: TEST_PDFS_PATH.node + basicApiFileName });
         } else {
-          typedArrayPdf = new Uint8Array(request.response);
+          var nonBinaryRequest = _global.PDFJS.disableWorker;
+          var request = new XMLHttpRequest();
+          request.open('GET', TEST_PDFS_PATH.dom + basicApiFileName, false);
+          if (!nonBinaryRequest) {
+            try {
+              request.responseType = 'arraybuffer';
+              nonBinaryRequest = request.responseType !== 'arraybuffer';
+            } catch (e) {
+              nonBinaryRequest = true;
+            }
+          }
+          if (nonBinaryRequest && request.overrideMimeType) {
+            request.overrideMimeType('text/plain; charset=x-user-defined');
+          }
+          request.send(null);
+          if (nonBinaryRequest) {
+            typedArrayPdf = (0, _util.stringToBytes)(request.responseText);
+          } else {
+            typedArrayPdf = new Uint8Array(request.response);
+          }
         }
         expect(typedArrayPdf.length).toEqual(basicApiFileLength);
-        var loadingTask = _global.PDFJS.getDocument(typedArrayPdf);
+        var loadingTask = (0, _api.getDocument)(typedArrayPdf);
         loadingTask.promise.then(function (data) {
           expect(data instanceof _api.PDFDocumentProxy).toEqual(true);
           loadingTask.destroy().then(done);
@@ -120,8 +154,7 @@ describe('api', function () {
         });
       });
       it('creates pdf doc from invalid PDF file', function (done) {
-        var url = new URL('../pdfs/bug1020226.pdf', window.location).href;
-        var loadingTask = _global.PDFJS.getDocument(url);
+        var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('bug1020226.pdf'));
         loadingTask.promise.then(function () {
           done.fail('shall fail loading');
         }).catch(function (error) {
@@ -130,8 +163,10 @@ describe('api', function () {
         });
       });
       it('creates pdf doc from non-existent URL', function (done) {
-        var nonExistentUrl = new URL('../pdfs/non-existent.pdf', window.location).href;
-        var loadingTask = _global.PDFJS.getDocument(nonExistentUrl);
+        if ((0, _util.isNodeJS)()) {
+          pending('XMLHttpRequest is not supported in Node.js.');
+        }
+        var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('non-existent.pdf'));
         loadingTask.promise.then(function (error) {
           done.fail('shall fail loading');
         }).catch(function (error) {
@@ -140,8 +175,7 @@ describe('api', function () {
         });
       });
       it('creates pdf doc from PDF file protected with user and owner password', function (done) {
-        var url = new URL('../pdfs/pr6531_1.pdf', window.location).href;
-        var loadingTask = _global.PDFJS.getDocument(url);
+        var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('pr6531_1.pdf'));
         var isPasswordNeededResolved = false;
         var passwordNeededCapability = (0, _util.createPromiseCapability)();
         var isPasswordIncorrectResolved = false;
@@ -170,11 +204,8 @@ describe('api', function () {
         });
       });
       it('creates pdf doc from PDF file protected with only a user password', function (done) {
-        var url = new URL('../pdfs/pr6531_2.pdf', window.location).href;
-        var passwordNeededLoadingTask = _global.PDFJS.getDocument({
-          url: url,
-          password: ''
-        });
+        var filename = 'pr6531_2.pdf';
+        var passwordNeededLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename, { password: '' }));
         var result1 = passwordNeededLoadingTask.promise.then(function () {
           done.fail('shall fail with no password');
           return Promise.reject(new Error('loadingTask should be rejected'));
@@ -183,10 +214,7 @@ describe('api', function () {
           expect(data.code).toEqual(_util.PasswordResponses.NEED_PASSWORD);
           return passwordNeededLoadingTask.destroy();
         });
-        var passwordIncorrectLoadingTask = _global.PDFJS.getDocument({
-          url: url,
-          password: 'qwerty'
-        });
+        var passwordIncorrectLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename, { password: 'qwerty' }));
         var result2 = passwordIncorrectLoadingTask.promise.then(function () {
           done.fail('shall fail with wrong password');
           return Promise.reject(new Error('loadingTask should be rejected'));
@@ -195,10 +223,7 @@ describe('api', function () {
           expect(data.code).toEqual(_util.PasswordResponses.INCORRECT_PASSWORD);
           return passwordIncorrectLoadingTask.destroy();
         });
-        var passwordAcceptedLoadingTask = _global.PDFJS.getDocument({
-          url: url,
-          password: 'asdfasdf'
-        });
+        var passwordAcceptedLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename, { password: 'asdfasdf' }));
         var result3 = passwordAcceptedLoadingTask.promise.then(function (data) {
           expect(data instanceof _api.PDFDocumentProxy).toEqual(true);
           return passwordAcceptedLoadingTask.destroy();
@@ -210,12 +235,9 @@ describe('api', function () {
         });
       });
       it('creates pdf doc from password protected PDF file and aborts/throws ' + 'in the onPassword callback (issue 7806)', function (done) {
-        var url = new URL('../pdfs/issue3371.pdf', window.location).href;
-        var passwordNeededLoadingTask = _global.PDFJS.getDocument(url);
-        var passwordIncorrectLoadingTask = _global.PDFJS.getDocument({
-          url: url,
-          password: 'qwerty'
-        });
+        var filename = 'issue3371.pdf';
+        var passwordNeededLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename));
+        var passwordIncorrectLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename, { password: 'qwerty' }));
         var passwordNeededDestroyed = void 0;
         passwordNeededLoadingTask.onPassword = function (callback, reason) {
           if (reason === _util.PasswordResponses.NEED_PASSWORD) {
@@ -255,6 +277,9 @@ describe('api', function () {
     });
   });
   describe('PDFWorker', function () {
+    if ((0, _util.isNodeJS)()) {
+      pending('Worker is not supported in Node.js.');
+    }
     it('worker created or destroyed', function (done) {
       var worker = new _global.PDFJS.PDFWorker('test1');
       worker.promise.then(function () {
@@ -272,7 +297,7 @@ describe('api', function () {
       });
     });
     it('worker created or destroyed by getDocument', function (done) {
-      var loadingTask = _global.PDFJS.getDocument(basicApiUrl);
+      var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
       var worker;
       loadingTask.promise.then(function () {
         worker = loadingTask._worker;
@@ -292,10 +317,7 @@ describe('api', function () {
     });
     it('worker created and can be used in getDocument', function (done) {
       var worker = new _global.PDFJS.PDFWorker('test1');
-      var loadingTask = _global.PDFJS.getDocument({
-        url: basicApiUrl,
-        worker: worker
-      });
+      var loadingTask = (0, _api.getDocument)(buildGetDocumentParams(basicApiFileName, { worker: worker }));
       loadingTask.promise.then(function () {
         var docWorker = loadingTask._worker;
         expect(!!docWorker).toEqual(false);
@@ -333,7 +355,7 @@ describe('api', function () {
     var loadingTask;
     var doc;
     beforeAll(function (done) {
-      loadingTask = _global.PDFJS.getDocument(basicApiUrl);
+      loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
       loadingTask.promise.then(function (data) {
         doc = data;
         done();
@@ -447,8 +469,7 @@ describe('api', function () {
       });
     });
     it('gets destinations, from /Names (NameTree) dictionary', function (done) {
-      var url = new URL('../pdfs/issue6204.pdf', window.location).href;
-      var loadingTask = _global.PDFJS.getDocument(url);
+      var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('issue6204.pdf'));
       var promise = loadingTask.promise.then(function (pdfDocument) {
         return pdfDocument.getDestinations();
       });
@@ -469,8 +490,7 @@ describe('api', function () {
       });
     });
     it('gets a destination, from /Names (NameTree) dictionary', function (done) {
-      var url = new URL('../pdfs/issue6204.pdf', window.location).href;
-      var loadingTask = _global.PDFJS.getDocument(url);
+      var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('issue6204.pdf'));
       var promise = loadingTask.promise.then(function (pdfDocument) {
         return pdfDocument.getDestination('Page.1');
       });
@@ -485,8 +505,7 @@ describe('api', function () {
       });
     });
     it('gets a non-existent destination, from /Names (NameTree) dictionary', function (done) {
-      var url = new URL('../pdfs/issue6204.pdf', window.location).href;
-      var loadingTask = _global.PDFJS.getDocument(url);
+      var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('issue6204.pdf'));
       var promise = loadingTask.promise.then(function (pdfDocument) {
         return pdfDocument.getDestination('non-existent-named-destination');
       });
@@ -507,23 +526,19 @@ describe('api', function () {
       });
     });
     it('gets page labels', function (done) {
-      var url0 = new URL('../pdfs/bug793632.pdf', window.location).href;
-      var loadingTask0 = _global.PDFJS.getDocument(url0);
+      var loadingTask0 = (0, _api.getDocument)(buildGetDocumentParams('bug793632.pdf'));
       var promise0 = loadingTask0.promise.then(function (pdfDoc) {
         return pdfDoc.getPageLabels();
       });
-      var url1 = new URL('../pdfs/issue1453.pdf', window.location).href;
-      var loadingTask1 = _global.PDFJS.getDocument(url1);
+      var loadingTask1 = (0, _api.getDocument)(buildGetDocumentParams('issue1453.pdf'));
       var promise1 = loadingTask1.promise.then(function (pdfDoc) {
         return pdfDoc.getPageLabels();
       });
-      var url2 = new URL('../pdfs/rotation.pdf', window.location).href;
-      var loadingTask2 = _global.PDFJS.getDocument(url2);
+      var loadingTask2 = (0, _api.getDocument)(buildGetDocumentParams('rotation.pdf'));
       var promise2 = loadingTask2.promise.then(function (pdfDoc) {
         return pdfDoc.getPageLabels();
       });
-      var url3 = new URL('../pdfs/bad-PageLabels.pdf', window.location).href;
-      var loadingTask3 = _global.PDFJS.getDocument(url3);
+      var loadingTask3 = (0, _api.getDocument)(buildGetDocumentParams('bad-PageLabels.pdf'));
       var promise3 = loadingTask3.promise.then(function (pdfDoc) {
         return pdfDoc.getPageLabels();
       });
@@ -547,8 +562,10 @@ describe('api', function () {
       });
     });
     it('gets attachments', function (done) {
-      var url = new URL('../pdfs/bug766138.pdf', window.location).href;
-      var loadingTask = _global.PDFJS.getDocument(url);
+      if ((0, _util.isNodeJS)()) {
+        pending('TODO: Use a non-linked test-case.');
+      }
+      var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('bug766138.pdf'));
       var promise = loadingTask.promise.then(function (pdfDoc) {
         return pdfDoc.getAttachments();
       });
@@ -573,8 +590,7 @@ describe('api', function () {
     });
     var viewerPrintRegExp = /\bprint\s*\(/;
     it('gets javascript with printing instructions (Print action)', function (done) {
-      var pdfUrl = new URL('../pdfs/bug1001080.pdf', window.location).href;
-      var loadingTask = _global.PDFJS.getDocument(pdfUrl);
+      var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('bug1001080.pdf'));
       var promise = loadingTask.promise.then(function (doc) {
         return doc.getJavaScript();
       });
@@ -587,8 +603,7 @@ describe('api', function () {
       });
     });
     it('gets javascript with printing instructions (JS action)', function (done) {
-      var pdfUrl = new URL('../pdfs/issue6106.pdf', window.location).href;
-      var loadingTask = _global.PDFJS.getDocument(pdfUrl);
+      var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('issue6106.pdf'));
       var promise = loadingTask.promise.then(function (doc) {
         return doc.getJavaScript();
       });
@@ -601,8 +616,7 @@ describe('api', function () {
       });
     });
     it('gets non-existent outline', function (done) {
-      var url = new URL('../pdfs/tracemonkey.pdf', window.location).href;
-      var loadingTask = _global.PDFJS.getDocument(url);
+      var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('tracemonkey.pdf'));
       var promise = loadingTask.promise.then(function (pdfDocument) {
         return pdfDocument.getOutline();
       });
@@ -635,8 +649,7 @@ describe('api', function () {
       });
     });
     it('gets outline containing a url', function (done) {
-      var pdfUrl = new URL('../pdfs/issue3214.pdf', window.location).href;
-      var loadingTask = _global.PDFJS.getDocument(pdfUrl);
+      var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('issue3214.pdf'));
       loadingTask.promise.then(function (pdfDocument) {
         pdfDocument.getOutline().then(function (outline) {
           expect(outline instanceof Array).toEqual(true);
@@ -658,6 +671,9 @@ describe('api', function () {
       });
     });
     it('gets metadata', function (done) {
+      if ((0, _util.isNodeJS)()) {
+        pending('Document is not supported in Node.js.');
+      }
       var promise = doc.getMetadata();
       promise.then(function (metadata) {
         expect(metadata.info['Title']).toEqual('Basic API Test');
@@ -700,10 +716,8 @@ describe('api', function () {
       });
     });
     it('checks that fingerprints are unique', function (done) {
-      var url1 = new URL('../pdfs/issue4436r.pdf', window.location).href;
-      var loadingTask1 = _global.PDFJS.getDocument(url1);
-      var url2 = new URL('../pdfs/issue4575.pdf', window.location).href;
-      var loadingTask2 = _global.PDFJS.getDocument(url2);
+      var loadingTask1 = (0, _api.getDocument)(buildGetDocumentParams('issue4436r.pdf'));
+      var loadingTask2 = (0, _api.getDocument)(buildGetDocumentParams('issue4575.pdf'));
       var promises = [loadingTask1.promise, loadingTask2.promise];
       Promise.all(promises).then(function (data) {
         var fingerprint1 = data[0].fingerprint;
@@ -723,7 +737,7 @@ describe('api', function () {
     var loadingTask;
     var pdfDocument, page;
     beforeAll(function (done) {
-      loadingTask = _global.PDFJS.getDocument(basicApiUrl);
+      loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
       loadingTask.promise.then(function (doc) {
         pdfDocument = doc;
         pdfDocument.getPage(1).then(function (data) {
@@ -781,26 +795,20 @@ describe('api', function () {
       });
     });
     it('gets annotations containing relative URLs (bug 766086)', function (done) {
-      var url = new URL('../pdfs/bug766086.pdf', window.location).href;
-      var defaultLoadingTask = _global.PDFJS.getDocument(url);
+      var filename = 'bug766086.pdf';
+      var defaultLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename));
       var defaultPromise = defaultLoadingTask.promise.then(function (pdfDoc) {
         return pdfDoc.getPage(1).then(function (pdfPage) {
           return pdfPage.getAnnotations();
         });
       });
-      var docBaseUrlLoadingTask = _global.PDFJS.getDocument({
-        url: url,
-        docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf'
-      });
+      var docBaseUrlLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename, { docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf' }));
       var docBaseUrlPromise = docBaseUrlLoadingTask.promise.then(function (pdfDoc) {
         return pdfDoc.getPage(1).then(function (pdfPage) {
           return pdfPage.getAnnotations();
         });
       });
-      var invalidDocBaseUrlLoadingTask = _global.PDFJS.getDocument({
-        url: url,
-        docBaseUrl: 'qwerty.pdf'
-      });
+      var invalidDocBaseUrlLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename, { docBaseUrl: 'qwerty.pdf' }));
       var invalidDocBaseUrlPromise = invalidDocBaseUrlLoadingTask.promise.then(function (pdfDoc) {
         return pdfDoc.getPage(1).then(function (pdfPage) {
           return pdfPage.getAnnotations();
@@ -869,6 +877,9 @@ describe('api', function () {
       });
     });
     it('cancels rendering of page', function (done) {
+      if ((0, _util.isNodeJS)()) {
+        pending('TODO: Support Canvas testing in Node.js.');
+      }
       var viewport = page.getViewport(1);
       var canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
       var renderTask = page.render({
@@ -887,13 +898,16 @@ describe('api', function () {
     });
   });
   describe('Multiple PDFJS instances', function () {
-    var pdf1 = new URL('../pdfs/tracemonkey.pdf', window.location).href;
-    var pdf2 = new URL('../pdfs/TAMReview.pdf', window.location).href;
-    var pdf3 = new URL('../pdfs/issue6068.pdf', window.location).href;
+    if ((0, _util.isNodeJS)()) {
+      pending('TODO: Support Canvas testing in Node.js.');
+    }
+    var pdf1 = buildGetDocumentParams('tracemonkey.pdf');
+    var pdf2 = buildGetDocumentParams('TAMReview.pdf');
+    var pdf3 = buildGetDocumentParams('issue6068.pdf');
     var loadingTasks = [];
     var pdfDocuments = [];
     function renderPDF(filename) {
-      var loadingTask = _global.PDFJS.getDocument(filename);
+      var loadingTask = (0, _api.getDocument)(filename);
       loadingTasks.push(loadingTask);
       return loadingTask.promise.then(function (pdf) {
         pdfDocuments.push(pdf);
@@ -947,6 +961,9 @@ describe('api', function () {
     });
   });
   describe('PDFDataRangeTransport', function () {
+    if ((0, _util.isNodeJS)()) {
+      pending('XMLHttpRequest is not supported in Node.js.');
+    }
     var pdfPath = new URL('../pdfs/tracemonkey.pdf', window.location).href;
     var loadPromise;
     function getDocumentData() {
@@ -981,7 +998,7 @@ describe('api', function () {
             transport.onDataRange(begin, data.subarray(begin, end));
           });
         };
-        var loadingTask = _global.PDFJS.getDocument(transport);
+        var loadingTask = (0, _api.getDocument)(transport);
         return loadingTask.promise;
       });
       var pdfDocument;
@@ -1015,7 +1032,7 @@ describe('api', function () {
             transport.onDataRange(begin, data.subarray(begin, end));
           });
         };
-        var loadingTask = _global.PDFJS.getDocument(transport);
+        var loadingTask = (0, _api.getDocument)(transport);
         return loadingTask.promise;
       });
       var pdfDocument;

+ 19 - 1
lib/test/unit/test_utils.js

@@ -17,7 +17,7 @@
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
-exports.NodeCMapReaderFactory = undefined;
+exports.NodeCMapReaderFactory = exports.NodeFileReaderFactory = undefined;
 
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
 
@@ -25,6 +25,23 @@ var _util = require('../../shared/util');
 
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
+var NodeFileReaderFactory = function () {
+  function NodeFileReaderFactory() {
+    _classCallCheck(this, NodeFileReaderFactory);
+  }
+
+  _createClass(NodeFileReaderFactory, null, [{
+    key: 'fetch',
+    value: function fetch(params) {
+      var fs = require('fs');
+      var file = fs.readFileSync(params.path);
+      return new Uint8Array(file);
+    }
+  }]);
+
+  return NodeFileReaderFactory;
+}();
+
 var NodeCMapReaderFactory = function () {
   function NodeCMapReaderFactory(_ref) {
     var _ref$baseUrl = _ref.baseUrl,
@@ -68,4 +85,5 @@ var NodeCMapReaderFactory = function () {
   return NodeCMapReaderFactory;
 }();
 
+exports.NodeFileReaderFactory = NodeFileReaderFactory;
 exports.NodeCMapReaderFactory = NodeCMapReaderFactory;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "1.8.349",
+  "version": "1.8.351",
   "main": "build/pdf.js",
   "description": "Generic build of Mozilla's PDF.js library.",
   "keywords": [

Some files were not shown because too many files changed in this diff