Browse Source

PDF.js version 1.8.587 - See mozilla/pdf.js@ec916566d7c4a8332abb466efb5f1b697df40bfe

master v1.8.587
pdfjsbot 8 years ago
parent
commit
e1869c7d7c
  1. 2
      bower.json
  2. 12
      build/pdf.combined.js
  3. 2
      build/pdf.combined.js.map
  4. 12
      build/pdf.js
  5. 2
      build/pdf.js.map
  6. 4
      build/pdf.min.js
  7. 4
      build/pdf.worker.js
  8. 2
      build/pdf.worker.js.map
  9. 4
      lib/display/api.js
  10. 4
      lib/display/global.js
  11. 4
      lib/pdf.js
  12. 4
      lib/pdf.worker.js
  13. 104
      lib/test/unit/annotation_spec.js
  14. 57
      lib/test/unit/colorspace_spec.js
  15. 12
      lib/test/unit/evaluator_spec.js
  16. 32
      lib/test/unit/primitives_spec.js
  17. 44
      lib/test/unit/test_utils.js
  18. 2
      package.json

2
bower.json

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

12
build/pdf.combined.js

@ -7071,8 +7071,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.585'; exports.version = version = '1.8.587';
exports.build = build = '783d42ec'; exports.build = build = 'ec916566';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;
@ -28157,8 +28157,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.585'; PDFJS.version = '1.8.587';
PDFJS.build = '783d42ec'; PDFJS.build = 'ec916566';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {
@ -47629,8 +47629,8 @@ exports.PDFDataTransportStream = PDFDataTransportStream;
"use strict"; "use strict";
var pdfjsVersion = '1.8.585'; var pdfjsVersion = '1.8.587';
var pdfjsBuild = '783d42ec'; var pdfjsBuild = 'ec916566';
var pdfjsSharedUtil = __w_pdfjs_require__(0); var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(24); var pdfjsDisplayGlobal = __w_pdfjs_require__(24);
var pdfjsDisplayAPI = __w_pdfjs_require__(7); var pdfjsDisplayAPI = __w_pdfjs_require__(7);

2
build/pdf.combined.js.map

File diff suppressed because one or more lines are too long

12
build/pdf.js

@ -3322,8 +3322,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.585'; exports.version = version = '1.8.587';
exports.build = build = '783d42ec'; exports.build = build = 'ec916566';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;
@ -6033,8 +6033,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.585'; PDFJS.version = '1.8.587';
PDFJS.build = '783d42ec'; PDFJS.build = 'ec916566';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {
@ -12311,8 +12311,8 @@ exports.PDFDataTransportStream = PDFDataTransportStream;
"use strict"; "use strict";
var pdfjsVersion = '1.8.585'; var pdfjsVersion = '1.8.587';
var pdfjsBuild = '783d42ec'; var pdfjsBuild = 'ec916566';
var pdfjsSharedUtil = __w_pdfjs_require__(0); var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(8); var pdfjsDisplayGlobal = __w_pdfjs_require__(8);
var pdfjsDisplayAPI = __w_pdfjs_require__(2); var pdfjsDisplayAPI = __w_pdfjs_require__(2);

2
build/pdf.js.map

File diff suppressed because one or more lines are too long

4
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

4
build/pdf.worker.js vendored

@ -39932,8 +39932,8 @@ exports.Type1Parser = Type1Parser;
"use strict"; "use strict";
var pdfjsVersion = '1.8.585'; var pdfjsVersion = '1.8.587';
var pdfjsBuild = '783d42ec'; var pdfjsBuild = 'ec916566';
var pdfjsCoreWorker = __w_pdfjs_require__(17); var pdfjsCoreWorker = __w_pdfjs_require__(17);
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler; exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

2
build/pdf.worker.js.map vendored

File diff suppressed because one or more lines are too long

4
lib/display/api.js

@ -1567,8 +1567,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.585'; exports.version = version = '1.8.587';
exports.build = build = '783d42ec'; exports.build = build = 'ec916566';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;

4
lib/display/global.js

@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.585'; PDFJS.version = '1.8.587';
PDFJS.build = '783d42ec'; PDFJS.build = 'ec916566';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {

4
lib/pdf.js

@ -14,8 +14,8 @@
*/ */
'use strict'; 'use strict';
var pdfjsVersion = '1.8.585'; var pdfjsVersion = '1.8.587';
var pdfjsBuild = '783d42ec'; var pdfjsBuild = 'ec916566';
var pdfjsSharedUtil = require('./shared/util.js'); var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayGlobal = require('./display/global.js'); var pdfjsDisplayGlobal = require('./display/global.js');
var pdfjsDisplayAPI = require('./display/api.js'); var pdfjsDisplayAPI = require('./display/api.js');

4
lib/pdf.worker.js vendored

@ -14,7 +14,7 @@
*/ */
'use strict'; 'use strict';
var pdfjsVersion = '1.8.585'; var pdfjsVersion = '1.8.587';
var pdfjsBuild = '783d42ec'; var pdfjsBuild = 'ec916566';
var pdfjsCoreWorker = require('./core/worker.js'); var pdfjsCoreWorker = require('./core/worker.js');
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler; exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

104
lib/test/unit/annotation_spec.js

@ -24,27 +24,9 @@ var _parser = require('../../core/parser');
var _stream = require('../../core/stream'); var _stream = require('../../core/stream');
var _test_utils = require('./test_utils');
describe('annotation', function () { describe('annotation', function () {
function XRefMock(array) {
this.map = Object.create(null);
for (var elem in array) {
var obj = array[elem];
var ref = obj.ref,
data = obj.data;
this.map[ref.toString()] = data;
}
}
XRefMock.prototype = {
fetch: function fetch(ref) {
return this.map[ref.toString()];
},
fetchIfRef: function fetchIfRef(obj) {
if (!(0, _primitives.isRef)(obj)) {
return obj;
}
return this.fetch(obj);
}
};
function PDFManagerMock(params) { function PDFManagerMock(params) {
this.docBaseUrl = params.docBaseUrl || null; this.docBaseUrl = params.docBaseUrl || null;
} }
@ -77,7 +59,7 @@ describe('annotation', function () {
annotationDict.set('Type', _primitives.Name.get('Annot')); annotationDict.set('Type', _primitives.Name.get('Annot'));
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
var annotationRef = new _primitives.Ref(10, 0); var annotationRef = new _primitives.Ref(10, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -90,7 +72,7 @@ describe('annotation', function () {
var annotationDict = new _primitives.Dict(); var annotationDict = new _primitives.Dict();
annotationDict.set('Type', _primitives.Name.get('Annot')); annotationDict.set('Type', _primitives.Name.get('Annot'));
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
var xref = new XRefMock(); var xref = new _test_utils.XRefMock();
var idFactory = new IdFactoryMock({ var idFactory = new IdFactoryMock({
prefix: 'p0_', prefix: 'p0_',
startObjId: 0 startObjId: 0
@ -108,7 +90,7 @@ describe('annotation', function () {
var annotationDict = new _primitives.Dict(); var annotationDict = new _primitives.Dict();
annotationDict.set('Type', _primitives.Name.get('Annot')); annotationDict.set('Type', _primitives.Name.get('Annot'));
var annotationRef = new _primitives.Ref(1, 0); var annotationRef = new _primitives.Ref(1, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -274,7 +256,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('A', actionDict); annotationDict.set('A', actionDict);
var annotationRef = new _primitives.Ref(820, 0); var annotationRef = new _primitives.Ref(820, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -295,7 +277,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('A', actionDict); annotationDict.set('A', actionDict);
var annotationRef = new _primitives.Ref(353, 0); var annotationRef = new _primitives.Ref(353, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -316,7 +298,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('A', actionDict); annotationDict.set('A', actionDict);
var annotationRef = new _primitives.Ref(8, 0); var annotationRef = new _primitives.Ref(8, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -337,7 +319,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('A', actionDict); annotationDict.set('A', actionDict);
var annotationRef = new _primitives.Ref(798, 0); var annotationRef = new _primitives.Ref(798, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -360,7 +342,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('A', actionDict); annotationDict.set('A', actionDict);
var annotationRef = new _primitives.Ref(489, 0); var annotationRef = new _primitives.Ref(489, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -383,7 +365,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('A', actionDict); annotationDict.set('A', actionDict);
var annotationRef = new _primitives.Ref(489, 0); var annotationRef = new _primitives.Ref(489, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -406,7 +388,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('A', actionDict); annotationDict.set('A', actionDict);
var annotationRef = new _primitives.Ref(495, 0); var annotationRef = new _primitives.Ref(495, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -429,7 +411,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('A', actionDict); annotationDict.set('A', actionDict);
var annotationRef = new _primitives.Ref(489, 0); var annotationRef = new _primitives.Ref(489, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -456,7 +438,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('A', actionDict); annotationDict.set('A', actionDict);
var annotationRef = new _primitives.Ref(88, 0); var annotationRef = new _primitives.Ref(88, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -484,7 +466,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('A', actionDict); annotationDict.set('A', actionDict);
var annotationRef = new _primitives.Ref(46, 0); var annotationRef = new _primitives.Ref(46, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -525,7 +507,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('A', actionDict); annotationDict.set('A', actionDict);
var annotationRef = new _primitives.Ref(12, 0); var annotationRef = new _primitives.Ref(12, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -542,7 +524,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('Dest', _primitives.Name.get('LI0')); annotationDict.set('Dest', _primitives.Name.get('LI0'));
var annotationRef = new _primitives.Ref(583, 0); var annotationRef = new _primitives.Ref(583, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -559,7 +541,7 @@ describe('annotation', function () {
annotationDict.set('Subtype', _primitives.Name.get('Link')); annotationDict.set('Subtype', _primitives.Name.get('Link'));
annotationDict.set('Dest', [new _primitives.Ref(17, 0), _primitives.Name.get('XYZ'), 0, 841.89, null]); annotationDict.set('Dest', [new _primitives.Ref(17, 0), _primitives.Name.get('XYZ'), 0, 841.89, null]);
var annotationRef = new _primitives.Ref(10, 0); var annotationRef = new _primitives.Ref(10, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: annotationRef, ref: annotationRef,
data: annotationDict data: annotationDict
}]); }]);
@ -587,7 +569,7 @@ describe('annotation', function () {
}); });
it('should handle unknown field names', function () { it('should handle unknown field names', function () {
var widgetRef = new _primitives.Ref(20, 0); var widgetRef = new _primitives.Ref(20, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: widgetRef, ref: widgetRef,
data: widgetDict data: widgetDict
}]); }]);
@ -599,7 +581,7 @@ describe('annotation', function () {
it('should construct the field name when there are no ancestors', function () { it('should construct the field name when there are no ancestors', function () {
widgetDict.set('T', 'foo'); widgetDict.set('T', 'foo');
var widgetRef = new _primitives.Ref(21, 0); var widgetRef = new _primitives.Ref(21, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: widgetRef, ref: widgetRef,
data: widgetDict data: widgetDict
}]); }]);
@ -617,7 +599,7 @@ describe('annotation', function () {
widgetDict.set('Parent', secondParent); widgetDict.set('Parent', secondParent);
widgetDict.set('T', 'baz'); widgetDict.set('T', 'baz');
var widgetRef = new _primitives.Ref(22, 0); var widgetRef = new _primitives.Ref(22, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: widgetRef, ref: widgetRef,
data: widgetDict data: widgetDict
}]); }]);
@ -633,7 +615,7 @@ describe('annotation', function () {
widgetDict.set('Parent', parentDict); widgetDict.set('Parent', parentDict);
widgetDict.set('T', 'bar'); widgetDict.set('T', 'bar');
var widgetRef = new _primitives.Ref(22, 0); var widgetRef = new _primitives.Ref(22, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: widgetRef, ref: widgetRef,
data: widgetDict data: widgetDict
}]); }]);
@ -657,7 +639,7 @@ describe('annotation', function () {
}); });
it('should handle unknown text alignment, maximum length and flags', function () { it('should handle unknown text alignment, maximum length and flags', function () {
var textWidgetRef = new _primitives.Ref(124, 0); var textWidgetRef = new _primitives.Ref(124, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: textWidgetRef, ref: textWidgetRef,
data: textWidgetDict data: textWidgetDict
}]); }]);
@ -675,7 +657,7 @@ describe('annotation', function () {
textWidgetDict.set('MaxLen', 'five'); textWidgetDict.set('MaxLen', 'five');
textWidgetDict.set('Ff', 'readonly'); textWidgetDict.set('Ff', 'readonly');
var textWidgetRef = new _primitives.Ref(43, 0); var textWidgetRef = new _primitives.Ref(43, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: textWidgetRef, ref: textWidgetRef,
data: textWidgetDict data: textWidgetDict
}]); }]);
@ -693,7 +675,7 @@ describe('annotation', function () {
textWidgetDict.set('MaxLen', 20); textWidgetDict.set('MaxLen', 20);
textWidgetDict.set('Ff', _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.MULTILINE); textWidgetDict.set('Ff', _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.MULTILINE);
var textWidgetRef = new _primitives.Ref(84, 0); var textWidgetRef = new _primitives.Ref(84, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: textWidgetRef, ref: textWidgetRef,
data: textWidgetDict data: textWidgetDict
}]); }]);
@ -708,7 +690,7 @@ describe('annotation', function () {
it('should reject comb fields without a maximum length', function () { it('should reject comb fields without a maximum length', function () {
textWidgetDict.set('Ff', _util.AnnotationFieldFlag.COMB); textWidgetDict.set('Ff', _util.AnnotationFieldFlag.COMB);
var textWidgetRef = new _primitives.Ref(46, 0); var textWidgetRef = new _primitives.Ref(46, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: textWidgetRef, ref: textWidgetRef,
data: textWidgetDict data: textWidgetDict
}]); }]);
@ -721,7 +703,7 @@ describe('annotation', function () {
textWidgetDict.set('MaxLen', 20); textWidgetDict.set('MaxLen', 20);
textWidgetDict.set('Ff', _util.AnnotationFieldFlag.COMB); textWidgetDict.set('Ff', _util.AnnotationFieldFlag.COMB);
var textWidgetRef = new _primitives.Ref(46, 0); var textWidgetRef = new _primitives.Ref(46, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: textWidgetRef, ref: textWidgetRef,
data: textWidgetDict data: textWidgetDict
}]); }]);
@ -737,7 +719,7 @@ describe('annotation', function () {
textWidgetDict.set('MaxLen', 20); textWidgetDict.set('MaxLen', 20);
textWidgetDict.set('Ff', flags); textWidgetDict.set('Ff', flags);
var textWidgetRef = new _primitives.Ref(93, 0); var textWidgetRef = new _primitives.Ref(93, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: textWidgetRef, ref: textWidgetRef,
data: textWidgetDict data: textWidgetDict
}]); }]);
@ -767,7 +749,7 @@ describe('annotation', function () {
it('should handle checkboxes', function () { it('should handle checkboxes', function () {
buttonWidgetDict.set('V', _primitives.Name.get('1')); buttonWidgetDict.set('V', _primitives.Name.get('1'));
var buttonWidgetRef = new _primitives.Ref(124, 0); var buttonWidgetRef = new _primitives.Ref(124, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: buttonWidgetRef, ref: buttonWidgetRef,
data: buttonWidgetDict data: buttonWidgetDict
}]); }]);
@ -789,7 +771,7 @@ describe('annotation', function () {
buttonWidgetDict.set('Parent', parentDict); buttonWidgetDict.set('Parent', parentDict);
buttonWidgetDict.set('AP', appearanceStatesDict); buttonWidgetDict.set('AP', appearanceStatesDict);
var buttonWidgetRef = new _primitives.Ref(124, 0); var buttonWidgetRef = new _primitives.Ref(124, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: buttonWidgetRef, ref: buttonWidgetRef,
data: buttonWidgetDict data: buttonWidgetDict
}]); }]);
@ -809,7 +791,7 @@ describe('annotation', function () {
buttonWidgetDict.set('Ff', _util.AnnotationFieldFlag.RADIO); buttonWidgetDict.set('Ff', _util.AnnotationFieldFlag.RADIO);
buttonWidgetDict.set('AP', appearanceStatesDict); buttonWidgetDict.set('AP', appearanceStatesDict);
var buttonWidgetRef = new _primitives.Ref(124, 0); var buttonWidgetRef = new _primitives.Ref(124, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: buttonWidgetRef, ref: buttonWidgetRef,
data: buttonWidgetDict data: buttonWidgetDict
}]); }]);
@ -836,7 +818,7 @@ describe('annotation', function () {
}); });
it('should handle missing option arrays', function () { it('should handle missing option arrays', function () {
var choiceWidgetRef = new _primitives.Ref(122, 0); var choiceWidgetRef = new _primitives.Ref(122, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: choiceWidgetRef, ref: choiceWidgetRef,
data: choiceWidgetDict data: choiceWidgetDict
}]); }]);
@ -860,7 +842,7 @@ describe('annotation', function () {
}]; }];
choiceWidgetDict.set('Opt', options); choiceWidgetDict.set('Opt', options);
var choiceWidgetRef = new _primitives.Ref(123, 0); var choiceWidgetRef = new _primitives.Ref(123, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: choiceWidgetRef, ref: choiceWidgetRef,
data: choiceWidgetDict data: choiceWidgetDict
}, { }, {
@ -888,7 +870,7 @@ describe('annotation', function () {
}]; }];
choiceWidgetDict.set('Opt', options); choiceWidgetDict.set('Opt', options);
var choiceWidgetRef = new _primitives.Ref(981, 0); var choiceWidgetRef = new _primitives.Ref(981, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: choiceWidgetRef, ref: choiceWidgetRef,
data: choiceWidgetDict data: choiceWidgetDict
}, { }, {
@ -913,7 +895,7 @@ describe('annotation', function () {
parentDict.set('Opt', options); parentDict.set('Opt', options);
choiceWidgetDict.set('Parent', parentDict); choiceWidgetDict.set('Parent', parentDict);
var choiceWidgetRef = new _primitives.Ref(123, 0); var choiceWidgetRef = new _primitives.Ref(123, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: choiceWidgetRef, ref: choiceWidgetRef,
data: choiceWidgetDict data: choiceWidgetDict
}]); }]);
@ -926,7 +908,7 @@ describe('annotation', function () {
var fieldValue = ['Foo', 'Bar']; var fieldValue = ['Foo', 'Bar'];
choiceWidgetDict.set('V', fieldValue); choiceWidgetDict.set('V', fieldValue);
var choiceWidgetRef = new _primitives.Ref(968, 0); var choiceWidgetRef = new _primitives.Ref(968, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: choiceWidgetRef, ref: choiceWidgetRef,
data: choiceWidgetDict data: choiceWidgetDict
}]); }]);
@ -939,7 +921,7 @@ describe('annotation', function () {
var fieldValue = 'Foo'; var fieldValue = 'Foo';
choiceWidgetDict.set('V', fieldValue); choiceWidgetDict.set('V', fieldValue);
var choiceWidgetRef = new _primitives.Ref(978, 0); var choiceWidgetRef = new _primitives.Ref(978, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: choiceWidgetRef, ref: choiceWidgetRef,
data: choiceWidgetDict data: choiceWidgetDict
}]); }]);
@ -950,7 +932,7 @@ describe('annotation', function () {
}); });
it('should handle unknown flags', function () { it('should handle unknown flags', function () {
var choiceWidgetRef = new _primitives.Ref(166, 0); var choiceWidgetRef = new _primitives.Ref(166, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: choiceWidgetRef, ref: choiceWidgetRef,
data: choiceWidgetDict data: choiceWidgetDict
}]); }]);
@ -964,7 +946,7 @@ describe('annotation', function () {
it('should not set invalid flags', function () { it('should not set invalid flags', function () {
choiceWidgetDict.set('Ff', 'readonly'); choiceWidgetDict.set('Ff', 'readonly');
var choiceWidgetRef = new _primitives.Ref(165, 0); var choiceWidgetRef = new _primitives.Ref(165, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: choiceWidgetRef, ref: choiceWidgetRef,
data: choiceWidgetDict data: choiceWidgetDict
}]); }]);
@ -978,7 +960,7 @@ describe('annotation', function () {
it('should set valid flags', function () { it('should set valid flags', function () {
choiceWidgetDict.set('Ff', _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.COMBO + _util.AnnotationFieldFlag.MULTISELECT); choiceWidgetDict.set('Ff', _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.COMBO + _util.AnnotationFieldFlag.MULTISELECT);
var choiceWidgetRef = new _primitives.Ref(512, 0); var choiceWidgetRef = new _primitives.Ref(512, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: choiceWidgetRef, ref: choiceWidgetRef,
data: choiceWidgetDict data: choiceWidgetDict
}]); }]);
@ -997,7 +979,7 @@ describe('annotation', function () {
lineDict.set('Subtype', _primitives.Name.get('Line')); lineDict.set('Subtype', _primitives.Name.get('Line'));
lineDict.set('L', [1, 2, 3, 4]); lineDict.set('L', [1, 2, 3, 4]);
var lineRef = new _primitives.Ref(122, 0); var lineRef = new _primitives.Ref(122, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: lineRef, ref: lineRef,
data: lineDict data: lineDict
}]); }]);
@ -1029,7 +1011,7 @@ describe('annotation', function () {
fileAttachmentDict.set('FS', fileSpecRef); fileAttachmentDict.set('FS', fileSpecRef);
fileAttachmentDict.set('T', 'Topic'); fileAttachmentDict.set('T', 'Topic');
fileAttachmentDict.set('Contents', 'Test.txt'); fileAttachmentDict.set('Contents', 'Test.txt');
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: fileStreamRef, ref: fileStreamRef,
data: fileStreamDict data: fileStreamDict
}, { }, {
@ -1061,7 +1043,7 @@ describe('annotation', function () {
popupDict.set('F', 25); popupDict.set('F', 25);
popupDict.set('Parent', parentDict); popupDict.set('Parent', parentDict);
var popupRef = new _primitives.Ref(13, 0); var popupRef = new _primitives.Ref(13, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: popupRef, ref: popupRef,
data: popupDict data: popupDict
}]); }]);

57
lib/test/unit/colorspace_spec.js

@ -14,48 +14,15 @@
*/ */
'use strict'; 'use strict';
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; }; }();
var _primitives = require('../../core/primitives'); var _primitives = require('../../core/primitives');
var _stream = require('../../core/stream'); var _stream = require('../../core/stream');
var _colorspace = require('../../core/colorspace'); var _colorspace = require('../../core/colorspace');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var _test_utils = require('./test_utils');
describe('colorspace', function () { describe('colorspace', function () {
var XRefMock = function () {
function XRefMock(array) {
_classCallCheck(this, XRefMock);
this.map = Object.create(null);
for (var elem in array) {
var obj = array[elem];
var ref = obj.ref;
var data = obj.data;
this.map[ref.toString()] = data;
}
}
_createClass(XRefMock, [{
key: 'fetch',
value: function fetch(ref) {
return this.map[ref.toString()];
}
}, {
key: 'fetchIfRef',
value: function fetchIfRef(obj) {
if (!(0, _primitives.isRef)(obj)) {
return obj;
}
return this.fetch(obj);
}
}]);
return XRefMock;
}();
describe('ColorSpace', function () { describe('ColorSpace', function () {
it('should be true if decode is not an array', function () { it('should be true if decode is not an array', function () {
expect(_colorspace.ColorSpace.isDefaultDecode('string', 0)).toBeTruthy(); expect(_colorspace.ColorSpace.isDefaultDecode('string', 0)).toBeTruthy();
@ -77,7 +44,7 @@ describe('colorspace', function () {
describe('DeviceGrayCS', function () { describe('DeviceGrayCS', function () {
it('should handle the case when cs is a Name object', function () { it('should handle the case when cs is a Name object', function () {
var cs = _primitives.Name.get('DeviceGray'); var cs = _primitives.Name.get('DeviceGray');
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: new _primitives.Ref(10, 0), ref: new _primitives.Ref(10, 0),
data: new _primitives.Dict() data: new _primitives.Dict()
}]); }]);
@ -94,7 +61,7 @@ describe('colorspace', function () {
}); });
it('should handle the case when cs is an indirect object', function () { it('should handle the case when cs is an indirect object', function () {
var cs = new _primitives.Ref(10, 0); var cs = new _primitives.Ref(10, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: cs, ref: cs,
data: _primitives.Name.get('DeviceGray') data: _primitives.Name.get('DeviceGray')
}]); }]);
@ -113,7 +80,7 @@ describe('colorspace', function () {
describe('DeviceRgbCS', function () { describe('DeviceRgbCS', function () {
it('should handle the case when cs is a Name object', function () { it('should handle the case when cs is a Name object', function () {
var cs = _primitives.Name.get('DeviceRGB'); var cs = _primitives.Name.get('DeviceRGB');
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: new _primitives.Ref(10, 0), ref: new _primitives.Ref(10, 0),
data: new _primitives.Dict() data: new _primitives.Dict()
}]); }]);
@ -130,7 +97,7 @@ describe('colorspace', function () {
}); });
it('should handle the case when cs is an indirect object', function () { it('should handle the case when cs is an indirect object', function () {
var cs = new _primitives.Ref(10, 0); var cs = new _primitives.Ref(10, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: cs, ref: cs,
data: _primitives.Name.get('DeviceRGB') data: _primitives.Name.get('DeviceRGB')
}]); }]);
@ -149,7 +116,7 @@ describe('colorspace', function () {
describe('DeviceCmykCS', function () { describe('DeviceCmykCS', function () {
it('should handle the case when cs is a Name object', function () { it('should handle the case when cs is a Name object', function () {
var cs = _primitives.Name.get('DeviceCMYK'); var cs = _primitives.Name.get('DeviceCMYK');
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: new _primitives.Ref(10, 0), ref: new _primitives.Ref(10, 0),
data: new _primitives.Dict() data: new _primitives.Dict()
}]); }]);
@ -166,7 +133,7 @@ describe('colorspace', function () {
}); });
it('should handle the case when cs is an indirect object', function () { it('should handle the case when cs is an indirect object', function () {
var cs = new _primitives.Ref(10, 0); var cs = new _primitives.Ref(10, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: cs, ref: cs,
data: _primitives.Name.get('DeviceCMYK') data: _primitives.Name.get('DeviceCMYK')
}]); }]);
@ -189,7 +156,7 @@ describe('colorspace', function () {
params.set('BlackPoint', [0, 0, 0]); params.set('BlackPoint', [0, 0, 0]);
params.set('Gamma', 2.0); params.set('Gamma', 2.0);
var cs = [_primitives.Name.get('CalGray'), params]; var cs = [_primitives.Name.get('CalGray'), params];
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: new _primitives.Ref(10, 0), ref: new _primitives.Ref(10, 0),
data: new _primitives.Dict() data: new _primitives.Dict()
}]); }]);
@ -213,7 +180,7 @@ describe('colorspace', function () {
params.set('Gamma', [1, 1, 1]); params.set('Gamma', [1, 1, 1]);
params.set('Matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]); params.set('Matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
var cs = [_primitives.Name.get('CalRGB'), params]; var cs = [_primitives.Name.get('CalRGB'), params];
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: new _primitives.Ref(10, 0), ref: new _primitives.Ref(10, 0),
data: new _primitives.Dict() data: new _primitives.Dict()
}]); }]);
@ -236,7 +203,7 @@ describe('colorspace', function () {
params.set('BlackPoint', [0, 0, 0]); params.set('BlackPoint', [0, 0, 0]);
params.set('Range', [-100, 100, -100, 100]); params.set('Range', [-100, 100, -100, 100]);
var cs = [_primitives.Name.get('Lab'), params]; var cs = [_primitives.Name.get('Lab'), params];
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: new _primitives.Ref(10, 0), ref: new _primitives.Ref(10, 0),
data: new _primitives.Dict() data: new _primitives.Dict()
}]); }]);
@ -257,7 +224,7 @@ describe('colorspace', function () {
it('should handle the case when cs is an array', function () { it('should handle the case when cs is an array', function () {
var lookup = new Uint8Array([23, 155, 35, 147, 69, 93, 255, 109, 70]); var lookup = new Uint8Array([23, 155, 35, 147, 69, 93, 255, 109, 70]);
var cs = [_primitives.Name.get('Indexed'), _primitives.Name.get('DeviceRGB'), 2, lookup]; var cs = [_primitives.Name.get('Indexed'), _primitives.Name.get('DeviceRGB'), 2, lookup];
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: new _primitives.Ref(10, 0), ref: new _primitives.Ref(10, 0),
data: new _primitives.Dict() data: new _primitives.Dict()
}]); }]);
@ -284,7 +251,7 @@ describe('colorspace', function () {
fn = new _stream.Stream(fn.bytes, 0, 58, fnDict); fn = new _stream.Stream(fn.bytes, 0, 58, fnDict);
var fnRef = new _primitives.Ref(10, 0); var fnRef = new _primitives.Ref(10, 0);
var cs = [_primitives.Name.get('Separation'), _primitives.Name.get('LogoGreen'), _primitives.Name.get('DeviceCMYK'), fnRef]; var cs = [_primitives.Name.get('Separation'), _primitives.Name.get('LogoGreen'), _primitives.Name.get('DeviceCMYK'), fnRef];
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: fnRef, ref: fnRef,
data: fn data: fn
}]); }]);

12
lib/test/unit/evaluator_spec.js

@ -24,15 +24,9 @@ var _util = require('../../shared/util');
var _worker = require('../../core/worker'); var _worker = require('../../core/worker');
var _test_utils = require('./test_utils');
describe('evaluator', function () { describe('evaluator', function () {
function XrefMock(queue) {
this.queue = queue || [];
}
XrefMock.prototype = {
fetchIfRef: function fetchIfRef() {
return this.queue.shift();
}
};
function HandlerMock() { function HandlerMock() {
this.inputs = []; this.inputs = [];
} }
@ -67,7 +61,7 @@ describe('evaluator', function () {
beforeAll(function (done) { beforeAll(function (done) {
partialEvaluator = new _evaluator.PartialEvaluator({ partialEvaluator = new _evaluator.PartialEvaluator({
pdfManager: new PdfManagerMock(), pdfManager: new PdfManagerMock(),
xref: new XrefMock(), xref: new _test_utils.XRefMock(),
handler: new HandlerMock(), handler: new HandlerMock(),
pageIndex: 0 pageIndex: 0
}); });

32
lib/test/unit/primitives_spec.js

@ -16,33 +16,9 @@
var _primitives = require('../../core/primitives'); var _primitives = require('../../core/primitives');
var _test_utils = require('./test_utils');
describe('primitives', function () { describe('primitives', function () {
function XRefMock(array) {
this.map = Object.create(null);
for (var elem in array) {
var obj = array[elem];
var ref = obj.ref,
data = obj.data;
this.map[ref.toString()] = data;
}
}
XRefMock.prototype = {
fetch: function fetch(ref) {
return this.map[ref.toString()];
},
fetchIfRef: function fetchIfRef(obj) {
if (!(0, _primitives.isRef)(obj)) {
return obj;
}
return this.fetch(obj);
},
fetchAsync: function fetchAsync(ref) {
return Promise.resolve(this.fetch(ref));
},
fetchIfRefAsync: function fetchIfRefAsync(obj) {
return Promise.resolve(this.fetchIfRef(obj));
}
};
describe('Name', function () { describe('Name', function () {
it('should retain the given name', function () { it('should retain the given name', function () {
var givenName = 'Font'; var givenName = 'Font';
@ -165,7 +141,7 @@ describe('primitives', function () {
}); });
it('should handle keys pointing to indirect objects, both sync and async', function (done) { it('should handle keys pointing to indirect objects, both sync and async', function (done) {
var fontRef = new _primitives.Ref(1, 0); var fontRef = new _primitives.Ref(1, 0);
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: fontRef, ref: fontRef,
data: testFontFile data: testFontFile
}]); }]);
@ -185,7 +161,7 @@ describe('primitives', function () {
maxCoordRef = new _primitives.Ref(2, 0); maxCoordRef = new _primitives.Ref(2, 0);
var minCoord = 0, var minCoord = 0,
maxCoord = 1; maxCoord = 1;
var xref = new XRefMock([{ var xref = new _test_utils.XRefMock([{
ref: minCoordRef, ref: minCoordRef,
data: minCoord data: minCoord
}, { }, {

44
lib/test/unit/test_utils.js

@ -17,12 +17,14 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.TEST_PDFS_PATH = exports.buildGetDocumentParams = exports.NodeCMapReaderFactory = exports.NodeFileReaderFactory = undefined; exports.TEST_PDFS_PATH = exports.buildGetDocumentParams = exports.XRefMock = 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; }; }(); 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; }; }();
var _util = require('../../shared/util'); var _util = require('../../shared/util');
var _primitives = require('../../core/primitives');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var NodeFileReaderFactory = function () { var NodeFileReaderFactory = function () {
@ -102,7 +104,47 @@ var NodeCMapReaderFactory = function () {
return NodeCMapReaderFactory; return NodeCMapReaderFactory;
}(); }();
var XRefMock = function () {
function XRefMock(array) {
_classCallCheck(this, XRefMock);
this._map = Object.create(null);
for (var key in array) {
var obj = array[key];
this._map[obj.ref.toString()] = obj.data;
}
}
_createClass(XRefMock, [{
key: 'fetch',
value: function fetch(ref) {
return this._map[ref.toString()];
}
}, {
key: 'fetchAsync',
value: function fetchAsync(ref) {
return Promise.resolve(this.fetch(ref));
}
}, {
key: 'fetchIfRef',
value: function fetchIfRef(obj) {
if (!(0, _primitives.isRef)(obj)) {
return obj;
}
return this.fetch(obj);
}
}, {
key: 'fetchIfRefAsync',
value: function fetchIfRefAsync(obj) {
return Promise.resolve(this.fetchIfRef(obj));
}
}]);
return XRefMock;
}();
exports.NodeFileReaderFactory = NodeFileReaderFactory; exports.NodeFileReaderFactory = NodeFileReaderFactory;
exports.NodeCMapReaderFactory = NodeCMapReaderFactory; exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
exports.XRefMock = XRefMock;
exports.buildGetDocumentParams = buildGetDocumentParams; exports.buildGetDocumentParams = buildGetDocumentParams;
exports.TEST_PDFS_PATH = TEST_PDFS_PATH; exports.TEST_PDFS_PATH = TEST_PDFS_PATH;

2
package.json

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

Loading…
Cancel
Save