pdfjs-dist 2.1.266 → 2.2.228

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (166) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +3349 -2324
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +1 -1
  6. package/build/pdf.worker.js +2804 -1975
  7. package/build/pdf.worker.js.map +1 -1
  8. package/build/pdf.worker.min.js +1 -1
  9. package/image_decoders/pdf.image_decoders.js +431 -511
  10. package/image_decoders/pdf.image_decoders.js.map +1 -1
  11. package/image_decoders/pdf.image_decoders.min.js +1 -1
  12. package/lib/core/annotation.js +294 -224
  13. package/lib/core/arithmetic_decoder.js +1 -1
  14. package/lib/core/bidi.js +1 -1
  15. package/lib/core/ccitt.js +1 -1
  16. package/lib/core/ccitt_stream.js +1 -1
  17. package/lib/core/cff_parser.js +61 -12
  18. package/lib/core/charsets.js +1 -1
  19. package/lib/core/chunked_stream.js +24 -14
  20. package/lib/core/cmap.js +17 -13
  21. package/lib/core/colorspace.js +1 -1
  22. package/lib/core/core_utils.js +147 -0
  23. package/lib/core/crypto.js +1 -1
  24. package/lib/core/document.js +47 -40
  25. package/lib/core/encodings.js +1 -1
  26. package/lib/core/evaluator.js +346 -279
  27. package/lib/core/font_renderer.js +1 -1
  28. package/lib/core/fonts.js +23 -11
  29. package/lib/core/function.js +1 -1
  30. package/lib/core/glyphlist.js +2 -2
  31. package/lib/core/image.js +2 -2
  32. package/lib/core/image_utils.js +111 -0
  33. package/lib/core/jbig2.js +1 -1
  34. package/lib/core/jbig2_stream.js +1 -1
  35. package/lib/core/jpeg_stream.js +1 -1
  36. package/lib/core/jpg.js +2 -1
  37. package/lib/core/jpx.js +1 -1
  38. package/lib/core/jpx_stream.js +1 -1
  39. package/lib/core/metrics.js +13 -13
  40. package/lib/core/murmurhash3.js +37 -33
  41. package/lib/core/obj.js +245 -41
  42. package/lib/core/operator_list.js +43 -32
  43. package/lib/core/parser.js +228 -133
  44. package/lib/core/pattern.js +4 -2
  45. package/lib/core/pdf_manager.js +17 -15
  46. package/lib/core/primitives.js +40 -6
  47. package/lib/core/ps_parser.js +1 -1
  48. package/lib/core/standard_fonts.js +9 -9
  49. package/lib/core/stream.js +1 -1
  50. package/lib/core/type1_parser.js +1 -1
  51. package/lib/core/unicode.js +2 -2
  52. package/lib/core/worker.js +54 -171
  53. package/lib/core/worker_stream.js +277 -0
  54. package/lib/display/annotation_layer.js +112 -33
  55. package/lib/display/api.js +211 -123
  56. package/lib/display/api_compatibility.js +1 -1
  57. package/lib/display/canvas.js +40 -19
  58. package/lib/display/content_disposition.js +1 -1
  59. package/lib/display/display_utils.js +747 -0
  60. package/lib/display/fetch_stream.js +19 -12
  61. package/lib/display/font_loader.js +11 -8
  62. package/lib/display/metadata.js +1 -1
  63. package/lib/display/network.js +563 -521
  64. package/lib/display/network_utils.js +1 -1
  65. package/lib/display/node_stream.js +21 -12
  66. package/lib/display/pattern_helper.js +24 -25
  67. package/lib/display/svg.js +1068 -565
  68. package/lib/display/text_layer.js +24 -14
  69. package/lib/display/transport_stream.js +192 -70
  70. package/lib/display/webgl.js +1 -1
  71. package/lib/display/worker_options.js +1 -1
  72. package/lib/display/xml_parser.js +1 -1
  73. package/lib/examples/node/domstubs.js +4 -1
  74. package/lib/pdf.js +20 -15
  75. package/lib/pdf.worker.js +3 -3
  76. package/lib/shared/compatibility.js +6 -6
  77. package/lib/shared/global_scope.js +1 -1
  78. package/lib/shared/is_node.js +2 -2
  79. package/lib/shared/message_handler.js +7 -7
  80. package/lib/shared/streams_polyfill.js +1 -1
  81. package/lib/shared/url_polyfill.js +1 -1
  82. package/lib/shared/util.js +13 -125
  83. package/lib/test/unit/annotation_spec.js +278 -93
  84. package/lib/test/unit/api_spec.js +198 -188
  85. package/lib/test/unit/bidi_spec.js +1 -1
  86. package/lib/test/unit/cff_parser_spec.js +15 -1
  87. package/lib/test/unit/clitests_helper.js +3 -3
  88. package/lib/test/unit/cmap_spec.js +20 -20
  89. package/lib/test/unit/colorspace_spec.js +17 -12
  90. package/lib/test/unit/core_utils_spec.js +191 -0
  91. package/lib/test/unit/crypto_spec.js +1 -1
  92. package/lib/test/unit/custom_spec.js +8 -8
  93. package/lib/test/unit/display_svg_spec.js +8 -8
  94. package/lib/test/unit/display_utils_spec.js +273 -0
  95. package/lib/test/unit/document_spec.js +7 -12
  96. package/lib/test/unit/encodings_spec.js +5 -5
  97. package/lib/test/unit/evaluator_spec.js +8 -10
  98. package/lib/test/unit/fetch_stream_spec.js +109 -0
  99. package/lib/test/unit/function_spec.js +1 -1
  100. package/lib/test/unit/jasmine-boot.js +4 -4
  101. package/lib/test/unit/message_handler_spec.js +1 -1
  102. package/lib/test/unit/metadata_spec.js +1 -1
  103. package/lib/test/unit/murmurhash3_spec.js +1 -1
  104. package/lib/test/unit/network_spec.js +5 -55
  105. package/lib/test/unit/network_utils_spec.js +51 -1
  106. package/lib/test/unit/node_stream_spec.js +8 -8
  107. package/lib/test/unit/parser_spec.js +150 -86
  108. package/lib/test/unit/pdf_find_controller_spec.js +1 -1
  109. package/lib/test/unit/pdf_find_utils_spec.js +1 -1
  110. package/lib/test/unit/pdf_history_spec.js +1 -1
  111. package/lib/test/unit/primitives_spec.js +30 -17
  112. package/lib/test/unit/stream_spec.js +1 -1
  113. package/lib/test/unit/test_utils.js +197 -43
  114. package/lib/test/unit/testreporter.js +1 -1
  115. package/lib/test/unit/type1_parser_spec.js +1 -1
  116. package/lib/test/unit/ui_utils_spec.js +20 -20
  117. package/lib/test/unit/unicode_spec.js +5 -5
  118. package/lib/test/unit/util_spec.js +1 -164
  119. package/lib/web/annotation_layer_builder.js +1 -1
  120. package/lib/web/app.js +104 -60
  121. package/lib/web/app_options.js +45 -37
  122. package/lib/web/base_viewer.js +7 -7
  123. package/lib/web/chromecom.js +8 -8
  124. package/lib/web/debugger.js +7 -7
  125. package/lib/web/download_manager.js +3 -2
  126. package/lib/web/firefox_print_service.js +4 -2
  127. package/lib/web/firefoxcom.js +50 -19
  128. package/lib/web/genericcom.js +8 -8
  129. package/lib/web/genericl10n.js +10 -10
  130. package/lib/web/grab_to_pan.js +3 -1
  131. package/lib/web/interfaces.js +13 -13
  132. package/lib/web/overlay_manager.js +10 -10
  133. package/lib/web/password_prompt.js +2 -2
  134. package/lib/web/pdf_attachment_viewer.js +1 -1
  135. package/lib/web/pdf_cursor_tools.js +1 -1
  136. package/lib/web/pdf_document_properties.js +188 -119
  137. package/lib/web/pdf_find_bar.js +1 -1
  138. package/lib/web/pdf_find_controller.js +3 -3
  139. package/lib/web/pdf_find_utils.js +1 -1
  140. package/lib/web/pdf_history.js +1 -1
  141. package/lib/web/pdf_link_service.js +2 -2
  142. package/lib/web/pdf_outline_viewer.js +53 -28
  143. package/lib/web/pdf_page_view.js +9 -18
  144. package/lib/web/pdf_presentation_mode.js +1 -1
  145. package/lib/web/pdf_print_service.js +5 -3
  146. package/lib/web/pdf_rendering_queue.js +4 -7
  147. package/lib/web/pdf_sidebar.js +24 -17
  148. package/lib/web/pdf_sidebar_resizer.js +1 -1
  149. package/lib/web/pdf_single_page_viewer.js +1 -1
  150. package/lib/web/pdf_thumbnail_view.js +2 -2
  151. package/lib/web/pdf_thumbnail_viewer.js +3 -3
  152. package/lib/web/pdf_viewer.component.js +3 -3
  153. package/lib/web/pdf_viewer.js +3 -3
  154. package/lib/web/preferences.js +30 -30
  155. package/lib/web/secondary_toolbar.js +1 -1
  156. package/lib/web/text_layer_builder.js +23 -45
  157. package/lib/web/toolbar.js +1 -1
  158. package/lib/web/ui_utils.js +14 -14
  159. package/lib/web/view_history.js +15 -15
  160. package/lib/web/viewer_compatibility.js +1 -1
  161. package/package.json +1 -1
  162. package/web/pdf_viewer.css +21 -10
  163. package/web/pdf_viewer.js +126 -194
  164. package/web/pdf_viewer.js.map +1 -1
  165. package/lib/display/dom_utils.js +0 -494
  166. package/lib/test/unit/dom_utils_spec.js +0 -89
@@ -0,0 +1,273 @@
1
+ /**
2
+ * @licstart The following is the entire license notice for the
3
+ * Javascript code in this page
4
+ *
5
+ * Copyright 2019 Mozilla Foundation
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ *
19
+ * @licend The above is the entire license notice for the
20
+ * Javascript code in this page
21
+ */
22
+ "use strict";
23
+
24
+ var _display_utils = require("../../display/display_utils");
25
+
26
+ var _is_node = _interopRequireDefault(require("../../shared/is_node"));
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
29
+
30
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
31
+
32
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
33
+
34
+ function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
35
+
36
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
37
+
38
+ describe('display_utils', function () {
39
+ describe('DOMCanvasFactory', function () {
40
+ var canvasFactory;
41
+ beforeAll(function (done) {
42
+ canvasFactory = new _display_utils.DOMCanvasFactory();
43
+ done();
44
+ });
45
+ afterAll(function () {
46
+ canvasFactory = null;
47
+ });
48
+ it('`create` should throw an error if the dimensions are invalid', function () {
49
+ expect(function () {
50
+ return canvasFactory.create(-1, 1);
51
+ }).toThrow(new Error('Invalid canvas size'));
52
+ expect(function () {
53
+ return canvasFactory.create(1, -1);
54
+ }).toThrow(new Error('Invalid canvas size'));
55
+ });
56
+ it('`create` should return a canvas if the dimensions are valid', function () {
57
+ if ((0, _is_node["default"])()) {
58
+ pending('Document is not supported in Node.js.');
59
+ }
60
+
61
+ var _canvasFactory$create = canvasFactory.create(20, 40),
62
+ canvas = _canvasFactory$create.canvas,
63
+ context = _canvasFactory$create.context;
64
+
65
+ expect(canvas instanceof HTMLCanvasElement).toBe(true);
66
+ expect(context instanceof CanvasRenderingContext2D).toBe(true);
67
+ expect(canvas.width).toBe(20);
68
+ expect(canvas.height).toBe(40);
69
+ });
70
+ it('`reset` should throw an error if no canvas is provided', function () {
71
+ var canvasAndContext = {
72
+ canvas: null,
73
+ context: null
74
+ };
75
+ expect(function () {
76
+ return canvasFactory.reset(canvasAndContext, 20, 40);
77
+ }).toThrow(new Error('Canvas is not specified'));
78
+ });
79
+ it('`reset` should throw an error if the dimensions are invalid', function () {
80
+ var canvasAndContext = {
81
+ canvas: 'foo',
82
+ context: 'bar'
83
+ };
84
+ expect(function () {
85
+ return canvasFactory.reset(canvasAndContext, -1, 1);
86
+ }).toThrow(new Error('Invalid canvas size'));
87
+ expect(function () {
88
+ return canvasFactory.reset(canvasAndContext, 1, -1);
89
+ }).toThrow(new Error('Invalid canvas size'));
90
+ });
91
+ it('`reset` should alter the canvas/context if the dimensions are valid', function () {
92
+ if ((0, _is_node["default"])()) {
93
+ pending('Document is not supported in Node.js.');
94
+ }
95
+
96
+ var canvasAndContext = canvasFactory.create(20, 40);
97
+ canvasFactory.reset(canvasAndContext, 60, 80);
98
+ var canvas = canvasAndContext.canvas,
99
+ context = canvasAndContext.context;
100
+ expect(canvas instanceof HTMLCanvasElement).toBe(true);
101
+ expect(context instanceof CanvasRenderingContext2D).toBe(true);
102
+ expect(canvas.width).toBe(60);
103
+ expect(canvas.height).toBe(80);
104
+ });
105
+ it('`destroy` should throw an error if no canvas is provided', function () {
106
+ expect(function () {
107
+ return canvasFactory.destroy({});
108
+ }).toThrow(new Error('Canvas is not specified'));
109
+ });
110
+ it('`destroy` should clear the canvas/context', function () {
111
+ if ((0, _is_node["default"])()) {
112
+ pending('Document is not supported in Node.js.');
113
+ }
114
+
115
+ var canvasAndContext = canvasFactory.create(20, 40);
116
+ canvasFactory.destroy(canvasAndContext);
117
+ var canvas = canvasAndContext.canvas,
118
+ context = canvasAndContext.context;
119
+ expect(canvas).toBe(null);
120
+ expect(context).toBe(null);
121
+ });
122
+ });
123
+ describe('DOMSVGFactory', function () {
124
+ var svgFactory;
125
+ beforeAll(function (done) {
126
+ svgFactory = new _display_utils.DOMSVGFactory();
127
+ done();
128
+ });
129
+ afterAll(function () {
130
+ svgFactory = null;
131
+ });
132
+ it('`create` should throw an error if the dimensions are invalid', function () {
133
+ expect(function () {
134
+ return svgFactory.create(-1, 0);
135
+ }).toThrow(new Error('Invalid SVG dimensions'));
136
+ expect(function () {
137
+ return svgFactory.create(0, -1);
138
+ }).toThrow(new Error('Invalid SVG dimensions'));
139
+ });
140
+ it('`create` should return an SVG element if the dimensions are valid', function () {
141
+ if ((0, _is_node["default"])()) {
142
+ pending('Document is not supported in Node.js.');
143
+ }
144
+
145
+ var svg = svgFactory.create(20, 40);
146
+ expect(svg instanceof SVGSVGElement).toBe(true);
147
+ expect(svg.getAttribute('version')).toBe('1.1');
148
+ expect(svg.getAttribute('width')).toBe('20px');
149
+ expect(svg.getAttribute('height')).toBe('40px');
150
+ expect(svg.getAttribute('preserveAspectRatio')).toBe('none');
151
+ expect(svg.getAttribute('viewBox')).toBe('0 0 20 40');
152
+ });
153
+ it('`createElement` should throw an error if the type is not a string', function () {
154
+ expect(function () {
155
+ return svgFactory.createElement(true);
156
+ }).toThrow(new Error('Invalid SVG element type'));
157
+ });
158
+ it('`createElement` should return an SVG element if the type is valid', function () {
159
+ if ((0, _is_node["default"])()) {
160
+ pending('Document is not supported in Node.js.');
161
+ }
162
+
163
+ var svg = svgFactory.createElement('svg:rect');
164
+ expect(svg instanceof SVGRectElement).toBe(true);
165
+ });
166
+ });
167
+ describe('getFilenameFromUrl', function () {
168
+ it('should get the filename from an absolute URL', function () {
169
+ var url = 'https://server.org/filename.pdf';
170
+ expect((0, _display_utils.getFilenameFromUrl)(url)).toEqual('filename.pdf');
171
+ });
172
+ it('should get the filename from a relative URL', function () {
173
+ var url = '../../filename.pdf';
174
+ expect((0, _display_utils.getFilenameFromUrl)(url)).toEqual('filename.pdf');
175
+ });
176
+ it('should get the filename from a URL with an anchor', function () {
177
+ var url = 'https://server.org/filename.pdf#foo';
178
+ expect((0, _display_utils.getFilenameFromUrl)(url)).toEqual('filename.pdf');
179
+ });
180
+ it('should get the filename from a URL with query parameters', function () {
181
+ var url = 'https://server.org/filename.pdf?foo=bar';
182
+ expect((0, _display_utils.getFilenameFromUrl)(url)).toEqual('filename.pdf');
183
+ });
184
+ });
185
+ describe('isValidFetchUrl', function () {
186
+ it('handles invalid Fetch URLs', function () {
187
+ expect((0, _display_utils.isValidFetchUrl)(null)).toEqual(false);
188
+ expect((0, _display_utils.isValidFetchUrl)(100)).toEqual(false);
189
+ expect((0, _display_utils.isValidFetchUrl)('foo')).toEqual(false);
190
+ expect((0, _display_utils.isValidFetchUrl)('/foo', 100)).toEqual(false);
191
+ });
192
+ it('handles relative Fetch URLs', function () {
193
+ expect((0, _display_utils.isValidFetchUrl)('/foo', 'file://www.example.com')).toEqual(false);
194
+ expect((0, _display_utils.isValidFetchUrl)('/foo', 'http://www.example.com')).toEqual(true);
195
+ });
196
+ it('handles unsupported Fetch protocols', function () {
197
+ expect((0, _display_utils.isValidFetchUrl)('file://www.example.com')).toEqual(false);
198
+ expect((0, _display_utils.isValidFetchUrl)('ftp://www.example.com')).toEqual(false);
199
+ });
200
+ it('handles supported Fetch protocols', function () {
201
+ expect((0, _display_utils.isValidFetchUrl)('http://www.example.com')).toEqual(true);
202
+ expect((0, _display_utils.isValidFetchUrl)('https://www.example.com')).toEqual(true);
203
+ });
204
+ });
205
+ describe('PDFDateString', function () {
206
+ describe('toDateObject', function () {
207
+ it('converts PDF date strings to JavaScript `Date` objects', function () {
208
+ var expectations = {
209
+ undefined: null,
210
+ "null": null,
211
+ 42: null,
212
+ '2019': null,
213
+ 'D2019': null,
214
+ 'D:': null,
215
+ 'D:201': null,
216
+ 'D:2019': new Date(Date.UTC(2019, 0, 1, 0, 0, 0)),
217
+ 'D:20190': new Date(Date.UTC(2019, 0, 1, 0, 0, 0)),
218
+ 'D:201900': new Date(Date.UTC(2019, 0, 1, 0, 0, 0)),
219
+ 'D:201913': new Date(Date.UTC(2019, 0, 1, 0, 0, 0)),
220
+ 'D:201902': new Date(Date.UTC(2019, 1, 1, 0, 0, 0)),
221
+ 'D:2019020': new Date(Date.UTC(2019, 1, 1, 0, 0, 0)),
222
+ 'D:20190200': new Date(Date.UTC(2019, 1, 1, 0, 0, 0)),
223
+ 'D:20190232': new Date(Date.UTC(2019, 1, 1, 0, 0, 0)),
224
+ 'D:20190203': new Date(Date.UTC(2019, 1, 3, 0, 0, 0)),
225
+ 'D:20190431': new Date(Date.UTC(2019, 4, 1, 0, 0, 0)),
226
+ 'D:201902030': new Date(Date.UTC(2019, 1, 3, 0, 0, 0)),
227
+ 'D:2019020300': new Date(Date.UTC(2019, 1, 3, 0, 0, 0)),
228
+ 'D:2019020324': new Date(Date.UTC(2019, 1, 3, 0, 0, 0)),
229
+ 'D:2019020304': new Date(Date.UTC(2019, 1, 3, 4, 0, 0)),
230
+ 'D:20190203040': new Date(Date.UTC(2019, 1, 3, 4, 0, 0)),
231
+ 'D:201902030400': new Date(Date.UTC(2019, 1, 3, 4, 0, 0)),
232
+ 'D:201902030460': new Date(Date.UTC(2019, 1, 3, 4, 0, 0)),
233
+ 'D:201902030405': new Date(Date.UTC(2019, 1, 3, 4, 5, 0)),
234
+ 'D:2019020304050': new Date(Date.UTC(2019, 1, 3, 4, 5, 0)),
235
+ 'D:20190203040500': new Date(Date.UTC(2019, 1, 3, 4, 5, 0)),
236
+ 'D:20190203040560': new Date(Date.UTC(2019, 1, 3, 4, 5, 0)),
237
+ 'D:20190203040506': new Date(Date.UTC(2019, 1, 3, 4, 5, 6)),
238
+ 'D:20190203040506F': new Date(Date.UTC(2019, 1, 3, 4, 5, 6)),
239
+ 'D:20190203040506Z': new Date(Date.UTC(2019, 1, 3, 4, 5, 6)),
240
+ 'D:20190203040506-': new Date(Date.UTC(2019, 1, 3, 4, 5, 6)),
241
+ 'D:20190203040506+': new Date(Date.UTC(2019, 1, 3, 4, 5, 6)),
242
+ 'D:20190203040506+\'': new Date(Date.UTC(2019, 1, 3, 4, 5, 6)),
243
+ 'D:20190203040506+0': new Date(Date.UTC(2019, 1, 3, 4, 5, 6)),
244
+ 'D:20190203040506+01': new Date(Date.UTC(2019, 1, 3, 3, 5, 6)),
245
+ 'D:20190203040506+00\'': new Date(Date.UTC(2019, 1, 3, 4, 5, 6)),
246
+ 'D:20190203040506+24\'': new Date(Date.UTC(2019, 1, 3, 4, 5, 6)),
247
+ 'D:20190203040506+01\'': new Date(Date.UTC(2019, 1, 3, 3, 5, 6)),
248
+ 'D:20190203040506+01\'0': new Date(Date.UTC(2019, 1, 3, 3, 5, 6)),
249
+ 'D:20190203040506+01\'00': new Date(Date.UTC(2019, 1, 3, 3, 5, 6)),
250
+ 'D:20190203040506+01\'60': new Date(Date.UTC(2019, 1, 3, 3, 5, 6)),
251
+ 'D:20190203040506+0102': new Date(Date.UTC(2019, 1, 3, 3, 3, 6)),
252
+ 'D:20190203040506+01\'02': new Date(Date.UTC(2019, 1, 3, 3, 3, 6)),
253
+ 'D:20190203040506+01\'02\'': new Date(Date.UTC(2019, 1, 3, 3, 3, 6)),
254
+ 'D:20190203040506+05\'07': new Date(Date.UTC(2019, 1, 2, 22, 58, 6))
255
+ };
256
+
257
+ for (var _i = 0, _Object$entries = Object.entries(expectations); _i < _Object$entries.length; _i++) {
258
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
259
+ input = _Object$entries$_i[0],
260
+ expectation = _Object$entries$_i[1];
261
+
262
+ var result = _display_utils.PDFDateString.toDateObject(input);
263
+
264
+ if (result) {
265
+ expect(result.getTime()).toEqual(expectation.getTime());
266
+ } else {
267
+ expect(result).toEqual(expectation);
268
+ }
269
+ }
270
+ });
271
+ });
272
+ });
273
+ });
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -21,27 +21,22 @@
21
21
  */
22
22
  "use strict";
23
23
 
24
- var _document = require("../../core/document");
24
+ var _test_utils = require("./test_utils");
25
25
 
26
26
  describe('document', function () {
27
27
  describe('Page', function () {
28
28
  it('should create correct objId using the idFactory', function () {
29
- var page1 = new _document.Page({
30
- pdfManager: {},
31
- pageIndex: 0
32
- });
33
- var page2 = new _document.Page({
34
- pdfManager: {},
35
- pageIndex: 1
36
- });
37
- var idFactory1 = page1.idFactory,
38
- idFactory2 = page2.idFactory;
29
+ var idFactory1 = (0, _test_utils.createIdFactory)(0);
30
+ var idFactory2 = (0, _test_utils.createIdFactory)(1);
39
31
  expect(idFactory1.createObjId()).toEqual('p0_1');
40
32
  expect(idFactory1.createObjId()).toEqual('p0_2');
33
+ expect(idFactory1.getDocId()).toEqual('g_d0');
41
34
  expect(idFactory2.createObjId()).toEqual('p1_1');
42
35
  expect(idFactory2.createObjId()).toEqual('p1_2');
36
+ expect(idFactory2.getDocId()).toEqual('g_d0');
43
37
  expect(idFactory1.createObjId()).toEqual('p0_3');
44
38
  expect(idFactory1.createObjId()).toEqual('p0_4');
39
+ expect(idFactory1.getDocId()).toEqual('g_d0');
45
40
  });
46
41
  });
47
42
  });
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,8 @@ describe('encodings', function () {
30
30
  it('fetches a valid array for known encoding names', function () {
31
31
  var knownEncodingNames = ['ExpertEncoding', 'MacExpertEncoding', 'MacRomanEncoding', 'StandardEncoding', 'SymbolSetEncoding', 'WinAnsiEncoding', 'ZapfDingbatsEncoding'];
32
32
 
33
- for (var _i = 0; _i < knownEncodingNames.length; _i++) {
34
- var knownEncodingName = knownEncodingNames[_i];
33
+ for (var _i = 0, _knownEncodingNames = knownEncodingNames; _i < _knownEncodingNames.length; _i++) {
34
+ var knownEncodingName = _knownEncodingNames[_i];
35
35
  var encoding = (0, _encodings.getEncoding)(knownEncodingName);
36
36
  expect(Array.isArray(encoding)).toEqual(true);
37
37
  expect(encoding.length).toEqual(256);
@@ -49,8 +49,8 @@ describe('encodings', function () {
49
49
  _iteratorError = err;
50
50
  } finally {
51
51
  try {
52
- if (!_iteratorNormalCompletion && _iterator.return != null) {
53
- _iterator.return();
52
+ if (!_iteratorNormalCompletion && _iterator["return"] != null) {
53
+ _iterator["return"]();
54
54
  }
55
55
  } finally {
56
56
  if (_didIteratorError) {
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
21
21
  */
22
22
  "use strict";
23
23
 
24
+ var _test_utils = require("./test_utils");
25
+
24
26
  var _primitives = require("../../core/primitives");
25
27
 
26
28
  var _util = require("../../shared/util");
@@ -33,8 +35,6 @@ var _evaluator = require("../../core/evaluator");
33
35
 
34
36
  var _worker = require("../../core/worker");
35
37
 
36
- var _test_utils = require("./test_utils");
37
-
38
38
  describe('evaluator', function () {
39
39
  function HandlerMock() {
40
40
  this.inputs = [];
@@ -57,8 +57,6 @@ describe('evaluator', function () {
57
57
  }
58
58
  };
59
59
 
60
- function PdfManagerMock() {}
61
-
62
60
  function runOperatorListCheck(evaluator, stream, resources, callback) {
63
61
  var result = new _operator_list.OperatorList();
64
62
  var task = new _worker.WorkerTask('OperatorListCheck');
@@ -77,10 +75,10 @@ describe('evaluator', function () {
77
75
  var partialEvaluator;
78
76
  beforeAll(function (done) {
79
77
  partialEvaluator = new _evaluator.PartialEvaluator({
80
- pdfManager: new PdfManagerMock(),
81
78
  xref: new _test_utils.XRefMock(),
82
79
  handler: new HandlerMock(),
83
- pageIndex: 0
80
+ pageIndex: 0,
81
+ idFactory: (0, _test_utils.createIdFactory)(0)
84
82
  });
85
83
  done();
86
84
  });
@@ -245,7 +243,7 @@ describe('evaluator', function () {
245
243
  done();
246
244
  });
247
245
  });
248
- it('should skip paintXObject if name is missing', function (done) {
246
+ it('should error on paintXObject if name is missing', function (done) {
249
247
  var stream = new _stream.StringStream('/ Do');
250
248
  runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
251
249
  expect(result instanceof _util.FormatError).toEqual(true);
@@ -281,7 +279,7 @@ describe('evaluator', function () {
281
279
  task: task,
282
280
  resources: resources,
283
281
  operatorList: result
284
- }).catch(function () {
282
+ })["catch"](function () {
285
283
  expect(!!result.fnArray && !!result.argsArray).toEqual(true);
286
284
  expect(result.fnArray.length).toEqual(0);
287
285
  done();
@@ -296,7 +294,7 @@ describe('evaluator', function () {
296
294
  stream: stream,
297
295
  task: task,
298
296
  resources: resources
299
- }).catch(function () {
297
+ })["catch"](function () {
300
298
  expect(true).toEqual(true);
301
299
  done();
302
300
  });
@@ -0,0 +1,109 @@
1
+ /**
2
+ * @licstart The following is the entire license notice for the
3
+ * Javascript code in this page
4
+ *
5
+ * Copyright 2019 Mozilla Foundation
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ *
19
+ * @licend The above is the entire license notice for the
20
+ * Javascript code in this page
21
+ */
22
+ "use strict";
23
+
24
+ var _fetch_stream = require("../../display/fetch_stream");
25
+
26
+ describe('fetch_stream', function () {
27
+ var pdfUrl = new URL('../pdfs/tracemonkey.pdf', window.location).href;
28
+ var pdfLength = 1016315;
29
+ it('read with streaming', function (done) {
30
+ var stream = new _fetch_stream.PDFFetchStream({
31
+ url: pdfUrl,
32
+ disableStream: false,
33
+ disableRange: true
34
+ });
35
+ var fullReader = stream.getFullReader();
36
+ var isStreamingSupported, isRangeSupported;
37
+ var promise = fullReader.headersReady.then(function () {
38
+ isStreamingSupported = fullReader.isStreamingSupported;
39
+ isRangeSupported = fullReader.isRangeSupported;
40
+ });
41
+ var len = 0;
42
+
43
+ var read = function read() {
44
+ return fullReader.read().then(function (result) {
45
+ if (result.done) {
46
+ return undefined;
47
+ }
48
+
49
+ len += result.value.byteLength;
50
+ return read();
51
+ });
52
+ };
53
+
54
+ var readPromise = Promise.all([read(), promise]);
55
+ readPromise.then(function () {
56
+ expect(len).toEqual(pdfLength);
57
+ expect(isStreamingSupported).toEqual(true);
58
+ expect(isRangeSupported).toEqual(false);
59
+ done();
60
+ })["catch"](done.fail);
61
+ });
62
+ it('read ranges with streaming', function (done) {
63
+ var rangeSize = 32768;
64
+ var stream = new _fetch_stream.PDFFetchStream({
65
+ url: pdfUrl,
66
+ rangeChunkSize: rangeSize,
67
+ disableStream: false,
68
+ disableRange: false
69
+ });
70
+ var fullReader = stream.getFullReader();
71
+ var isStreamingSupported, isRangeSupported, fullReaderCancelled;
72
+ var promise = fullReader.headersReady.then(function () {
73
+ isStreamingSupported = fullReader.isStreamingSupported;
74
+ isRangeSupported = fullReader.isRangeSupported;
75
+ fullReader.cancel(new Error('Don\'t need full reader'));
76
+ fullReaderCancelled = true;
77
+ });
78
+ var tailSize = pdfLength % rangeSize || rangeSize;
79
+ var rangeReader1 = stream.getRangeReader(pdfLength - tailSize - rangeSize, pdfLength - tailSize);
80
+ var rangeReader2 = stream.getRangeReader(pdfLength - tailSize, pdfLength);
81
+ var result1 = {
82
+ value: 0
83
+ },
84
+ result2 = {
85
+ value: 0
86
+ };
87
+
88
+ var read = function read(reader, lenResult) {
89
+ return reader.read().then(function (result) {
90
+ if (result.done) {
91
+ return undefined;
92
+ }
93
+
94
+ lenResult.value += result.value.byteLength;
95
+ return read(reader, lenResult);
96
+ });
97
+ };
98
+
99
+ var readPromise = Promise.all([read(rangeReader1, result1), read(rangeReader2, result2), promise]);
100
+ readPromise.then(function () {
101
+ expect(isStreamingSupported).toEqual(true);
102
+ expect(isRangeSupported).toEqual(true);
103
+ expect(fullReaderCancelled).toEqual(true);
104
+ expect(result1.value).toEqual(rangeSize);
105
+ expect(result2.value).toEqual(tailSize);
106
+ done();
107
+ })["catch"](done.fail);
108
+ });
109
+ });
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@
22
22
  'use strict';
23
23
 
24
24
  function initializePDFJS(callback) {
25
- Promise.all(['pdfjs/display/api', 'pdfjs/display/worker_options', 'pdfjs/display/network', 'pdfjs/display/fetch_stream', 'pdfjs/shared/is_node', 'pdfjs-test/unit/annotation_spec', 'pdfjs-test/unit/api_spec', 'pdfjs-test/unit/bidi_spec', 'pdfjs-test/unit/cff_parser_spec', 'pdfjs-test/unit/cmap_spec', 'pdfjs-test/unit/colorspace_spec', 'pdfjs-test/unit/crypto_spec', 'pdfjs-test/unit/custom_spec', 'pdfjs-test/unit/display_svg_spec', 'pdfjs-test/unit/document_spec', 'pdfjs-test/unit/dom_utils_spec', 'pdfjs-test/unit/encodings_spec', 'pdfjs-test/unit/evaluator_spec', 'pdfjs-test/unit/function_spec', 'pdfjs-test/unit/message_handler_spec', 'pdfjs-test/unit/metadata_spec', 'pdfjs-test/unit/murmurhash3_spec', 'pdfjs-test/unit/network_spec', 'pdfjs-test/unit/network_utils_spec', 'pdfjs-test/unit/parser_spec', 'pdfjs-test/unit/pdf_find_controller_spec', 'pdfjs-test/unit/pdf_find_utils_spec', 'pdfjs-test/unit/pdf_history_spec', 'pdfjs-test/unit/primitives_spec', 'pdfjs-test/unit/stream_spec', 'pdfjs-test/unit/type1_parser_spec', 'pdfjs-test/unit/ui_utils_spec', 'pdfjs-test/unit/unicode_spec', 'pdfjs-test/unit/util_spec'].map(function (moduleName) {
26
- return SystemJS.import(moduleName);
25
+ Promise.all(['pdfjs/display/api', 'pdfjs/display/worker_options', 'pdfjs/display/network', 'pdfjs/display/fetch_stream', 'pdfjs/shared/is_node', 'pdfjs-test/unit/annotation_spec', 'pdfjs-test/unit/api_spec', 'pdfjs-test/unit/bidi_spec', 'pdfjs-test/unit/cff_parser_spec', 'pdfjs-test/unit/cmap_spec', 'pdfjs-test/unit/colorspace_spec', 'pdfjs-test/unit/core_utils_spec', 'pdfjs-test/unit/crypto_spec', 'pdfjs-test/unit/custom_spec', 'pdfjs-test/unit/display_svg_spec', 'pdfjs-test/unit/display_utils_spec', 'pdfjs-test/unit/document_spec', 'pdfjs-test/unit/encodings_spec', 'pdfjs-test/unit/evaluator_spec', 'pdfjs-test/unit/function_spec', 'pdfjs-test/unit/fetch_stream_spec', 'pdfjs-test/unit/message_handler_spec', 'pdfjs-test/unit/metadata_spec', 'pdfjs-test/unit/murmurhash3_spec', 'pdfjs-test/unit/network_spec', 'pdfjs-test/unit/network_utils_spec', 'pdfjs-test/unit/parser_spec', 'pdfjs-test/unit/pdf_find_controller_spec', 'pdfjs-test/unit/pdf_find_utils_spec', 'pdfjs-test/unit/pdf_history_spec', 'pdfjs-test/unit/primitives_spec', 'pdfjs-test/unit/stream_spec', 'pdfjs-test/unit/type1_parser_spec', 'pdfjs-test/unit/ui_utils_spec', 'pdfjs-test/unit/unicode_spec', 'pdfjs-test/unit/util_spec'].map(function (moduleName) {
26
+ return SystemJS["import"](moduleName);
27
27
  })).then(function (modules) {
28
28
  var displayApi = modules[0];
29
29
  var GlobalWorkerOptions = modules[1].GlobalWorkerOptions;
@@ -54,7 +54,7 @@ function initializePDFJS(callback) {
54
54
  window.jasmine = jasmineRequire.core(jasmineRequire);
55
55
  jasmineRequire.html(jasmine);
56
56
  var env = jasmine.getEnv();
57
- var jasmineInterface = jasmineRequire.interface(jasmine, env);
57
+ var jasmineInterface = jasmineRequire["interface"](jasmine, env);
58
58
  extend(window, jasmineInterface);
59
59
  var queryString = new jasmine.QueryString({
60
60
  getWindowLocation: function getWindowLocation() {
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.