Browse Source

PDF.js version 2.0.265 - See mozilla/pdf.js@a7cb560f170ed6ace1fb758129972eb0daed3eb4

master v2.0.265
pdfjsbot 7 years ago
parent
commit
504cd5f68b
  1. 2
      bower.json
  2. 785
      build/pdf.combined.js
  3. 2
      build/pdf.combined.js.map
  4. 559
      build/pdf.js
  5. 2
      build/pdf.js.map
  6. 2
      build/pdf.min.js
  7. 508
      build/pdf.worker.js
  8. 2
      build/pdf.worker.js.map
  9. 2
      build/pdf.worker.min.js
  10. 10
      lib/core/worker.js
  11. 6
      lib/display/api.js
  12. 4
      lib/display/global.js
  13. 8
      lib/display/svg.js
  14. 4
      lib/examples/node/domstubs.js
  15. 7
      lib/pdf.js
  16. 4
      lib/pdf.worker.js
  17. 17
      lib/shared/compatibility.js
  18. 28
      lib/shared/is_node.js
  19. 6
      lib/shared/util.js
  20. 32
      lib/test/unit/api_spec.js
  21. 12
      lib/test/unit/cmap_spec.js
  22. 12
      lib/test/unit/custom_spec.js
  23. 22
      lib/test/unit/display_svg_spec.js
  24. 10
      lib/test/unit/dom_utils_spec.js
  25. 8
      lib/test/unit/node_stream_spec.js
  26. 8
      lib/test/unit/test_utils.js
  27. 12
      lib/test/unit/ui_utils_spec.js
  28. 2
      package.json

2
bower.json

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

785
build/pdf.combined.js

File diff suppressed because it is too large Load Diff

2
build/pdf.combined.js.map

File diff suppressed because one or more lines are too long

559
build/pdf.js

File diff suppressed because it is too large Load Diff

2
build/pdf.js.map

File diff suppressed because one or more lines are too long

2
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

508
build/pdf.worker.js vendored

File diff suppressed because it is too large Load Diff

2
build/pdf.worker.js.map vendored

File diff suppressed because one or more lines are too long

2
build/pdf.worker.min.js vendored

File diff suppressed because one or more lines are too long

10
lib/core/worker.js

@ -34,8 +34,14 @@ var _util = require('../shared/util'); @@ -34,8 +34,14 @@ var _util = require('../shared/util');
var _pdf_manager = require('./pdf_manager');
var _is_node = require('../shared/is_node');
var _is_node2 = _interopRequireDefault(_is_node);
var _primitives = require('./primitives');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var WorkerTask = function WorkerTaskClosure() {
function WorkerTask(name) {
this.name = name;
@ -217,7 +223,7 @@ var WorkerMessageHandler = { @@ -217,7 +223,7 @@ var WorkerMessageHandler = {
var cancelXHRs = null;
var WorkerTasks = [];
var apiVersion = docParams.apiVersion;
var workerVersion = '2.0.263';
var workerVersion = '2.0.265';
if (apiVersion !== null && apiVersion !== workerVersion) {
throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
}
@ -598,7 +604,7 @@ var WorkerMessageHandler = { @@ -598,7 +604,7 @@ var WorkerMessageHandler = {
function isMessagePort(maybePort) {
return typeof maybePort.postMessage === 'function' && 'onmessage' in maybePort;
}
if (typeof window === 'undefined' && !(0, _util.isNodeJS)() && typeof self !== 'undefined' && isMessagePort(self)) {
if (typeof window === 'undefined' && !(0, _is_node2.default)() && typeof self !== 'undefined' && isMessagePort(self)) {
WorkerMessageHandler.initializeFromPort(self);
}
exports.WorkerTask = WorkerTask;

6
lib/display/api.js

@ -178,7 +178,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { @@ -178,7 +178,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
if (worker.destroyed) {
return Promise.reject(new Error('Worker was destroyed'));
}
var apiVersion = '2.0.263';
var apiVersion = '2.0.265';
source.disableRange = (0, _dom_utils.getDefaultSetting)('disableRange');
source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch');
source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream');
@ -1551,8 +1551,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() { @@ -1551,8 +1551,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
}();
var version, build;
{
exports.version = version = '2.0.263';
exports.build = build = 'ba0a3aeb';
exports.version = version = '2.0.265';
exports.build = build = 'a7cb560f';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;

4
lib/display/global.js

@ -51,8 +51,8 @@ if (!_global_scope2.default.PDFJS) { @@ -51,8 +51,8 @@ if (!_global_scope2.default.PDFJS) {
}
var PDFJS = _global_scope2.default.PDFJS;
{
PDFJS.version = '2.0.263';
PDFJS.build = 'ba0a3aeb';
PDFJS.version = '2.0.265';
PDFJS.build = 'a7cb560f';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {

8
lib/display/svg.js

@ -30,6 +30,12 @@ var _util = require('../shared/util'); @@ -30,6 +30,12 @@ var _util = require('../shared/util');
var _dom_utils = require('./dom_utils');
var _is_node = require('../shared/is_node');
var _is_node2 = _interopRequireDefault(_is_node);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var SVGGraphics = function SVGGraphics() {
throw new Error('Not implemented: SVGGraphics');
};
@ -94,7 +100,7 @@ var SVGGraphics = function SVGGraphics() { @@ -94,7 +100,7 @@ var SVGGraphics = function SVGGraphics() {
return b << 16 | a;
}
function deflateSync(literals) {
if (!(0, _util.isNodeJS)()) {
if (!(0, _is_node2.default)()) {
return deflateSyncUncompressed(literals);
}
try {

4
lib/examples/node/domstubs.js

@ -192,9 +192,6 @@ DOMElementSerializer.prototype = { @@ -192,9 +192,6 @@ DOMElementSerializer.prototype = {
}
}
};
function btoa(chars) {
return Buffer.from(chars, 'binary').toString('base64');
}
var document = {
childNodes: [],
get currentScript() {
@ -232,7 +229,6 @@ Image.prototype = { @@ -232,7 +229,6 @@ Image.prototype = {
}
}
};
exports.btoa = btoa;
exports.document = document;
exports.Image = Image;
var exported_symbols = Object.keys(exports);

7
lib/pdf.js

@ -21,8 +21,8 @@ @@ -21,8 +21,8 @@
*/
'use strict';
var pdfjsVersion = '2.0.263';
var pdfjsBuild = 'ba0a3aeb';
var pdfjsVersion = '2.0.265';
var pdfjsBuild = 'a7cb560f';
var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayGlobal = require('./display/global.js');
var pdfjsDisplayAPI = require('./display/api.js');
@ -31,7 +31,8 @@ var pdfjsDisplayAnnotationLayer = require('./display/annotation_layer.js'); @@ -31,7 +31,8 @@ var pdfjsDisplayAnnotationLayer = require('./display/annotation_layer.js');
var pdfjsDisplayDOMUtils = require('./display/dom_utils.js');
var pdfjsDisplaySVG = require('./display/svg.js');
{
if (pdfjsSharedUtil.isNodeJS()) {
var isNodeJS = require('./shared/is_node.js');
if (isNodeJS()) {
var PDFNodeStream = require('./display/node_stream.js').PDFNodeStream;
pdfjsDisplayAPI.setPDFNetworkStreamClass(PDFNodeStream);
} else if (typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream !== 'undefined') {

4
lib/pdf.worker.js vendored

@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
*/
'use strict';
var pdfjsVersion = '2.0.263';
var pdfjsBuild = 'ba0a3aeb';
var pdfjsVersion = '2.0.265';
var pdfjsBuild = 'a7cb560f';
var pdfjsCoreWorker = require('./core/worker.js');
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

17
lib/shared/compatibility.js

@ -25,6 +25,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol @@ -25,6 +25,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
var globalScope = require('./global_scope');
var isNodeJS = require('./is_node');
var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
var isAndroid = /Android/.test(userAgent);
var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
@ -36,6 +37,22 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) { @@ -36,6 +37,22 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
globalScope.PDFJS = {};
}
PDFJS.compatibilityChecked = true;
(function checkNodeBtoa() {
if (globalScope.btoa || !isNodeJS()) {
return;
}
globalScope.btoa = function (chars) {
return Buffer.from(chars, 'binary').toString('base64');
};
})();
(function checkNodeAtob() {
if (globalScope.atob || !isNodeJS()) {
return;
}
globalScope.atob = function (input) {
return Buffer.from(input, 'base64').toString('binary');
};
})();
(function checkOnBlobSupport() {
if (isIE || isIOSChrome) {
PDFJS.disableCreateObjectURL = true;

28
lib/shared/is_node.js

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
/**
* @licstart The following is the entire license notice for the
* Javascript code in this page
*
* Copyright 2017 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @licend The above is the entire license notice for the
* Javascript code in this page
*/
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
module.exports = function isNodeJS() {
return (typeof process === 'undefined' ? 'undefined' : _typeof(process)) === 'object' && process + '' === '[object process]';
};

6
lib/shared/util.js

@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.loadJpegStream = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isNodeJS = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VERBOSITY_LEVELS = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.loadJpegStream = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VERBOSITY_LEVELS = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
@ -818,9 +818,6 @@ function isArrayBuffer(v) { @@ -818,9 +818,6 @@ function isArrayBuffer(v) {
function isSpace(ch) {
return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
}
function isNodeJS() {
return (typeof process === 'undefined' ? 'undefined' : _typeof(process)) === 'object' && process + '' === '[object process]';
}
function createPromiseCapability() {
var capability = {};
capability.promise = new Promise(function (resolve, reject) {
@ -1317,7 +1314,6 @@ exports.isEmptyObj = isEmptyObj; @@ -1317,7 +1314,6 @@ exports.isEmptyObj = isEmptyObj;
exports.isNum = isNum;
exports.isString = isString;
exports.isSpace = isSpace;
exports.isNodeJS = isNodeJS;
exports.isSameOrigin = isSameOrigin;
exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
exports.isLittleEndian = isLittleEndian;

32
lib/test/unit/api_spec.js

@ -31,15 +31,21 @@ var _dom_utils = require('../../display/dom_utils'); @@ -31,15 +31,21 @@ var _dom_utils = require('../../display/dom_utils');
var _api = require('../../display/api');
var _is_node = require('../../shared/is_node');
var _is_node2 = _interopRequireDefault(_is_node);
var _global = require('../../display/global');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
describe('api', function () {
var basicApiFileName = 'basicapi.pdf';
var basicApiFileLength = 105779;
var basicApiGetDocumentParams = (0, _test_utils.buildGetDocumentParams)(basicApiFileName);
var CanvasFactory = void 0;
beforeAll(function (done) {
if ((0, _util.isNodeJS)()) {} else {
if ((0, _is_node2.default)()) {} else {
CanvasFactory = new _dom_utils.DOMCanvasFactory();
}
done();
@ -57,7 +63,7 @@ describe('api', function () { @@ -57,7 +63,7 @@ describe('api', function () {
describe('PDFJS', function () {
describe('getDocument', function () {
it('creates pdf doc from URL', function (done) {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('XMLHttpRequest is not supported in Node.js.');
}
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
@ -80,7 +86,7 @@ describe('api', function () { @@ -80,7 +86,7 @@ describe('api', function () {
});
});
it('creates pdf doc from URL and aborts before worker initialized', function (done) {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('XMLHttpRequest is not supported in Node.js.');
}
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
@ -93,7 +99,7 @@ describe('api', function () { @@ -93,7 +99,7 @@ describe('api', function () {
});
});
it('creates pdf doc from URL and aborts loading after worker initialized', function (done) {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('XMLHttpRequest is not supported in Node.js.');
}
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
@ -109,7 +115,7 @@ describe('api', function () { @@ -109,7 +115,7 @@ describe('api', function () {
});
it('creates pdf doc from typed array', function (done) {
var typedArrayPdf;
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
typedArrayPdf = _test_utils.NodeFileReaderFactory.fetch({ path: _test_utils.TEST_PDFS_PATH.node + basicApiFileName });
} else {
var nonBinaryRequest = _global.PDFJS.disableWorker;
@ -152,7 +158,7 @@ describe('api', function () { @@ -152,7 +158,7 @@ describe('api', function () {
});
});
it('creates pdf doc from non-existent URL', function (done) {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('XMLHttpRequest is not supported in Node.js.');
}
var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)('non-existent.pdf'));
@ -266,7 +272,7 @@ describe('api', function () { @@ -266,7 +272,7 @@ describe('api', function () {
});
});
describe('PDFWorker', function () {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('Worker is not supported in Node.js.');
}
it('worker created or destroyed', function (done) {
@ -570,7 +576,7 @@ describe('api', function () { @@ -570,7 +576,7 @@ describe('api', function () {
});
});
it('gets attachments', function (done) {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('TODO: Use a non-linked test-case.');
}
var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)('bug766138.pdf'));
@ -740,7 +746,7 @@ describe('api', function () { @@ -740,7 +746,7 @@ describe('api', function () {
describe('Cross-origin', function () {
var loadingTask;
function _checkCanLoad(expectSuccess, filename, options) {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('Cannot simulate cross-origin requests in Node.js');
}
var params = (0, _test_utils.buildGetDocumentParams)(filename, options);
@ -952,7 +958,7 @@ describe('api', function () { @@ -952,7 +958,7 @@ describe('api', function () {
});
});
it('cancels rendering of page', function (done) {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('TODO: Support Canvas testing in Node.js.');
}
var viewport = page.getViewport(1);
@ -972,7 +978,7 @@ describe('api', function () { @@ -972,7 +978,7 @@ describe('api', function () {
});
});
it('multiple render() on the same canvas', function (done) {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('TODO: Support Canvas testing in Node.js.');
}
var viewport = page.getViewport(1);
@ -993,7 +999,7 @@ describe('api', function () { @@ -993,7 +999,7 @@ describe('api', function () {
});
});
describe('Multiple PDFJS instances', function () {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('TODO: Support Canvas testing in Node.js.');
}
var pdf1 = (0, _test_utils.buildGetDocumentParams)('tracemonkey.pdf');
@ -1056,7 +1062,7 @@ describe('api', function () { @@ -1056,7 +1062,7 @@ describe('api', function () {
});
});
describe('PDFDataRangeTransport', function () {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('XMLHttpRequest is not supported in Node.js.');
}
var pdfPath = new URL('../pdfs/tracemonkey.pdf', window.location).href;

12
lib/test/unit/cmap_spec.js

@ -25,7 +25,9 @@ var _cmap = require('../../core/cmap'); @@ -25,7 +25,9 @@ var _cmap = require('../../core/cmap');
var _dom_utils = require('../../display/dom_utils');
var _util = require('../../shared/util');
var _is_node = require('../../shared/is_node');
var _is_node2 = _interopRequireDefault(_is_node);
var _primitives = require('../../core/primitives');
@ -33,6 +35,8 @@ var _test_utils = require('./test_utils'); @@ -33,6 +35,8 @@ var _test_utils = require('./test_utils');
var _stream = require('../../core/stream');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var cMapUrl = {
dom: '../../external/bcmaps/',
node: './external/bcmaps/'
@ -42,7 +46,7 @@ describe('cmap', function () { @@ -42,7 +46,7 @@ describe('cmap', function () {
var fetchBuiltInCMap;
beforeAll(function (done) {
var CMapReaderFactory;
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
CMapReaderFactory = new _test_utils.NodeCMapReaderFactory({
baseUrl: cMapUrl.node,
isCompressed: cMapPacked
@ -251,7 +255,7 @@ describe('cmap', function () { @@ -251,7 +255,7 @@ describe('cmap', function () {
});
it('attempts to load a built-in CMap without the necessary API parameters', function (done) {
function tmpFetchBuiltInCMap(name) {
var CMapReaderFactory = (0, _util.isNodeJS)() ? new _test_utils.NodeCMapReaderFactory({}) : new _dom_utils.DOMCMapReaderFactory({});
var CMapReaderFactory = (0, _is_node2.default)() ? new _test_utils.NodeCMapReaderFactory({}) : new _dom_utils.DOMCMapReaderFactory({});
return CMapReaderFactory.fetch({ name: name });
}
var cmapPromise = _cmap.CMapFactory.create({
@ -270,7 +274,7 @@ describe('cmap', function () { @@ -270,7 +274,7 @@ describe('cmap', function () {
it('attempts to load a built-in CMap with inconsistent API parameters', function (done) {
function tmpFetchBuiltInCMap(name) {
var CMapReaderFactory = void 0;
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
CMapReaderFactory = new _test_utils.NodeCMapReaderFactory({
baseUrl: cMapUrl.node,
isCompressed: false

12
lib/test/unit/custom_spec.js

@ -27,7 +27,11 @@ var _dom_utils = require('../../display/dom_utils'); @@ -27,7 +27,11 @@ var _dom_utils = require('../../display/dom_utils');
var _api = require('../../display/api');
var _util = require('../../shared/util');
var _is_node = require('../../shared/is_node');
var _is_node2 = _interopRequireDefault(_is_node);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getTopLeftPixel(canvasContext) {
var imgData = canvasContext.getImageData(0, 0, 1, 1);
@ -44,7 +48,7 @@ describe('custom canvas rendering', function () { @@ -44,7 +48,7 @@ describe('custom canvas rendering', function () {
var loadingTask = void 0;
var page = void 0;
beforeAll(function (done) {
if ((0, _util.isNodeJS)()) {} else {
if ((0, _is_node2.default)()) {} else {
CanvasFactory = new _dom_utils.DOMCanvasFactory();
}
loadingTask = (0, _api.getDocument)(transparentGetDocumentParams);
@ -63,7 +67,7 @@ describe('custom canvas rendering', function () { @@ -63,7 +67,7 @@ describe('custom canvas rendering', function () {
loadingTask.destroy().then(done);
});
it('renders to canvas with a default white background', function (done) {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('TODO: Support Canvas testing in Node.js.');
}
var viewport = page.getViewport(1);
@ -89,7 +93,7 @@ describe('custom canvas rendering', function () { @@ -89,7 +93,7 @@ describe('custom canvas rendering', function () {
});
});
it('renders to canvas with a custom background', function (done) {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('TODO: Support Canvas testing in Node.js.');
}
var viewport = page.getViewport(1);

22
lib/test/unit/display_svg_spec.js

@ -21,25 +21,31 @@ @@ -21,25 +21,31 @@
*/
'use strict';
var _util = require('../../shared/util');
var _domstubs = require('../../examples/node/domstubs');
var _test_utils = require('./test_utils');
var _api = require('../../display/api');
var _is_node = require('../../shared/is_node');
var _is_node2 = _interopRequireDefault(_is_node);
var _util = require('../../shared/util');
var _svg = require('../../display/svg');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var XLINK_NS = 'http://www.w3.org/1999/xlink';
function withZlib(isZlibRequired, callback) {
if (isZlibRequired) {
if (!(0, _util.isNodeJS)()) {
if (!(0, _is_node2.default)()) {
throw new Error('zlib test can only be run in Node.js');
}
return callback();
}
if (!(0, _util.isNodeJS)()) {
if (!(0, _is_node2.default)()) {
return callback();
}
var zlib = require('zlib');
@ -87,14 +93,14 @@ describe('SVGGraphics', function () { @@ -87,14 +93,14 @@ describe('SVGGraphics', function () {
}
};
var xobjectObjId = 'img_p0_1';
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
(0, _domstubs.setStubs)(global);
}
try {
var imgData = svgGfx.objs.get(xobjectObjId);
svgGfx.paintInlineImageXObject(imgData, elementContainer);
} finally {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
(0, _domstubs.unsetStubs)(global);
}
}
@ -106,14 +112,14 @@ describe('SVGGraphics', function () { @@ -106,14 +112,14 @@ describe('SVGGraphics', function () {
require('zlib');
}
expect(testFunc.toString()).toMatch(/\srequire\(["']zlib["']\)/);
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
expect(testFunc).not.toThrow();
} else {
expect(testFunc).toThrow();
}
});
it('should produce a reasonably small svg:image', function (done) {
if (!(0, _util.isNodeJS)()) {
if (!(0, _is_node2.default)()) {
pending('zlib.deflateSync is not supported in non-Node environments.');
}
withZlib(true, getSVGImage).then(function (svgImg) {

10
lib/test/unit/dom_utils_spec.js

@ -23,10 +23,14 @@ @@ -23,10 +23,14 @@
var _dom_utils = require('../../display/dom_utils');
var _util = require('../../shared/util');
var _is_node = require('../../shared/is_node');
var _is_node2 = _interopRequireDefault(_is_node);
var _global = require('../../display/global');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
describe('dom_utils', function () {
describe('DOMSVGFactory', function () {
var svgFactory = void 0;
@ -46,7 +50,7 @@ describe('dom_utils', function () { @@ -46,7 +50,7 @@ describe('dom_utils', function () {
}).toThrow(new Error('Invalid SVG dimensions'));
});
it('`create` should return an SVG element if the dimensions are valid', function () {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('Document is not supported in Node.js.');
}
var svg = svgFactory.create(20, 40);
@ -63,7 +67,7 @@ describe('dom_utils', function () { @@ -63,7 +67,7 @@ describe('dom_utils', function () {
}).toThrow(new Error('Invalid SVG element type'));
});
it('`createElement` should return an SVG element if the type is valid', function () {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('Document is not supported in Node.js.');
}
var svg = svgFactory.createElement('svg:rect');

8
lib/test/unit/node_stream_spec.js

@ -25,9 +25,15 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = [ @@ -25,9 +25,15 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = [
var _util = require('../../shared/util');
var _is_node = require('../../shared/is_node');
var _is_node2 = _interopRequireDefault(_is_node);
var _node_stream = require('../../display/node_stream');
(0, _util.assert)((0, _util.isNodeJS)());
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
(0, _util.assert)((0, _is_node2.default)());
var path = require('path');
var url = require('url');
var http = require('http');

8
lib/test/unit/test_utils.js

@ -30,8 +30,14 @@ var _createClass = function () { function defineProperties(target, props) { for @@ -30,8 +30,14 @@ var _createClass = function () { function defineProperties(target, props) { for
var _util = require('../../shared/util');
var _is_node = require('../../shared/is_node');
var _is_node2 = _interopRequireDefault(_is_node);
var _primitives = require('../../core/primitives');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var NodeFileReaderFactory = function () {
@ -57,7 +63,7 @@ var TEST_PDFS_PATH = { @@ -57,7 +63,7 @@ var TEST_PDFS_PATH = {
};
function buildGetDocumentParams(filename, options) {
var params = Object.create(null);
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
params.data = NodeFileReaderFactory.fetch({ path: TEST_PDFS_PATH.node + filename });
} else {
params.url = new URL(TEST_PDFS_PATH.dom + filename, window.location).href;

12
lib/test/unit/ui_utils_spec.js

@ -25,6 +25,12 @@ var _ui_utils = require('../../web/ui_utils'); @@ -25,6 +25,12 @@ var _ui_utils = require('../../web/ui_utils');
var _util = require('../../shared/util');
var _is_node = require('../../shared/is_node');
var _is_node2 = _interopRequireDefault(_is_node);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
describe('ui_utils', function () {
describe('binary search', function () {
function isTrue(boolean) {
@ -99,7 +105,7 @@ describe('ui_utils', function () { @@ -99,7 +105,7 @@ describe('ui_utils', function () {
expect((0, _ui_utils.getPDFFileNameFromURL)('ftp://www.example.com/file4.pdf')).toEqual('file4.pdf');
});
it('gets PDF filename from query string appended to "blob:" URL', function () {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('Blob in not supported in Node.js.');
}
var typedArray = new Uint8Array([1, 2, 3, 4, 5]);
@ -258,7 +264,7 @@ describe('ui_utils', function () { @@ -258,7 +264,7 @@ describe('ui_utils', function () {
Promise.all([invalidTarget, invalidName, invalidDelay]).then(done, done.fail);
});
it('should resolve on event, using the DOM', function (done) {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('Document in not supported in Node.js.');
}
var button = document.createElement('button');
@ -274,7 +280,7 @@ describe('ui_utils', function () { @@ -274,7 +280,7 @@ describe('ui_utils', function () {
}, done.fail);
});
it('should resolve on timeout, using the DOM', function (done) {
if ((0, _util.isNodeJS)()) {
if ((0, _is_node2.default)()) {
pending('Document in not supported in Node.js.');
}
var button = document.createElement('button');

2
package.json

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

Loading…
Cancel
Save