pdfjs-dist 2.0.489 → 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 (169) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +18515 -11402
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +1 -1
  6. package/build/pdf.worker.js +48266 -37137
  7. package/build/pdf.worker.js.map +1 -1
  8. package/build/pdf.worker.min.js +1 -1
  9. package/external/url/url-lib.js +627 -0
  10. package/image_decoders/pdf.image_decoders.js +11350 -0
  11. package/image_decoders/pdf.image_decoders.js.map +1 -0
  12. package/image_decoders/pdf.image_decoders.min.js +1 -0
  13. package/lib/core/annotation.js +587 -242
  14. package/lib/core/arithmetic_decoder.js +275 -245
  15. package/lib/core/bidi.js +65 -6
  16. package/lib/core/ccitt.js +173 -18
  17. package/lib/core/ccitt_stream.js +15 -6
  18. package/lib/core/cff_parser.js +433 -61
  19. package/lib/core/charsets.js +5 -4
  20. package/lib/core/chunked_stream.js +400 -152
  21. package/lib/core/cmap.js +326 -87
  22. package/lib/core/colorspace.js +874 -594
  23. package/lib/core/core_utils.js +147 -0
  24. package/lib/core/crypto.js +290 -45
  25. package/lib/core/document.js +560 -268
  26. package/lib/core/encodings.js +19 -10
  27. package/lib/core/evaluator.js +1005 -360
  28. package/lib/core/font_renderer.js +331 -97
  29. package/lib/core/fonts.js +812 -195
  30. package/lib/core/function.js +284 -71
  31. package/lib/core/glyphlist.js +4 -3
  32. package/lib/core/image.js +169 -62
  33. package/lib/core/image_utils.js +111 -0
  34. package/lib/core/jbig2.js +479 -66
  35. package/lib/core/jbig2_stream.js +19 -8
  36. package/lib/core/jpeg_stream.js +38 -13
  37. package/lib/core/jpg.js +253 -29
  38. package/lib/core/jpx.js +396 -6
  39. package/lib/core/jpx_stream.js +18 -6
  40. package/lib/core/metrics.js +15 -15
  41. package/lib/core/murmurhash3.js +56 -34
  42. package/lib/core/obj.js +1354 -488
  43. package/lib/core/operator_list.js +144 -31
  44. package/lib/core/parser.js +539 -191
  45. package/lib/core/pattern.js +148 -14
  46. package/lib/core/pdf_manager.js +323 -133
  47. package/lib/core/primitives.js +111 -24
  48. package/lib/core/ps_parser.js +134 -45
  49. package/lib/core/standard_fonts.js +17 -17
  50. package/lib/core/stream.js +313 -34
  51. package/lib/core/type1_parser.js +143 -13
  52. package/lib/core/unicode.js +32 -5
  53. package/lib/core/worker.js +217 -190
  54. package/lib/core/worker_stream.js +277 -0
  55. package/lib/display/annotation_layer.js +450 -133
  56. package/lib/display/api.js +1597 -784
  57. package/lib/display/api_compatibility.js +11 -13
  58. package/lib/display/canvas.js +360 -44
  59. package/lib/display/content_disposition.js +83 -32
  60. package/lib/display/display_utils.js +747 -0
  61. package/lib/display/fetch_stream.js +221 -90
  62. package/lib/display/font_loader.js +468 -236
  63. package/lib/display/metadata.js +38 -16
  64. package/lib/display/network.js +635 -428
  65. package/lib/display/network_utils.js +32 -19
  66. package/lib/display/node_stream.js +367 -175
  67. package/lib/display/pattern_helper.js +81 -31
  68. package/lib/display/svg.js +1235 -519
  69. package/lib/display/text_layer.js +153 -29
  70. package/lib/display/transport_stream.js +345 -94
  71. package/lib/display/webgl.js +64 -18
  72. package/lib/display/worker_options.js +5 -4
  73. package/lib/display/xml_parser.js +166 -53
  74. package/lib/examples/node/domstubs.js +60 -4
  75. package/lib/pdf.js +36 -14
  76. package/lib/pdf.worker.js +5 -3
  77. package/lib/shared/compatibility.js +158 -564
  78. package/lib/shared/global_scope.js +2 -2
  79. package/lib/shared/is_node.js +4 -4
  80. package/lib/shared/message_handler.js +521 -0
  81. package/lib/shared/streams_polyfill.js +21 -17
  82. package/lib/shared/url_polyfill.js +56 -0
  83. package/lib/shared/util.js +243 -710
  84. package/lib/test/unit/annotation_spec.js +870 -401
  85. package/lib/test/unit/api_spec.js +657 -345
  86. package/lib/test/unit/bidi_spec.js +7 -7
  87. package/lib/test/unit/cff_parser_spec.js +54 -11
  88. package/lib/test/unit/clitests_helper.js +10 -8
  89. package/lib/test/unit/cmap_spec.js +95 -41
  90. package/lib/test/unit/colorspace_spec.js +115 -63
  91. package/lib/test/unit/core_utils_spec.js +191 -0
  92. package/lib/test/unit/crypto_spec.js +17 -5
  93. package/lib/test/unit/custom_spec.js +43 -55
  94. package/lib/test/unit/display_svg_spec.js +34 -18
  95. package/lib/test/unit/display_utils_spec.js +273 -0
  96. package/lib/test/unit/document_spec.js +8 -13
  97. package/lib/test/unit/encodings_spec.js +25 -45
  98. package/lib/test/unit/evaluator_spec.js +38 -15
  99. package/lib/test/unit/fetch_stream_spec.js +109 -0
  100. package/lib/test/unit/function_spec.js +17 -5
  101. package/lib/test/unit/jasmine-boot.js +33 -20
  102. package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
  103. package/lib/test/unit/metadata_spec.js +71 -11
  104. package/lib/test/unit/murmurhash3_spec.js +3 -3
  105. package/lib/test/unit/network_spec.js +19 -54
  106. package/lib/test/unit/network_utils_spec.js +91 -14
  107. package/lib/test/unit/node_stream_spec.js +56 -32
  108. package/lib/test/unit/parser_spec.js +162 -71
  109. package/lib/test/unit/pdf_find_controller_spec.js +230 -0
  110. package/lib/test/unit/pdf_find_utils_spec.js +63 -0
  111. package/lib/test/unit/pdf_history_spec.js +21 -9
  112. package/lib/test/unit/primitives_spec.js +53 -20
  113. package/lib/test/unit/stream_spec.js +12 -4
  114. package/lib/test/unit/test_utils.js +273 -56
  115. package/lib/test/unit/testreporter.js +21 -3
  116. package/lib/test/unit/type1_parser_spec.js +8 -6
  117. package/lib/test/unit/ui_utils_spec.js +454 -16
  118. package/lib/test/unit/unicode_spec.js +18 -15
  119. package/lib/test/unit/util_spec.js +87 -128
  120. package/lib/web/annotation_layer_builder.js +39 -22
  121. package/lib/web/app.js +1290 -588
  122. package/lib/web/app_options.js +100 -62
  123. package/lib/web/base_viewer.js +511 -182
  124. package/lib/web/chromecom.js +261 -117
  125. package/lib/web/debugger.js +166 -22
  126. package/lib/web/download_manager.js +32 -13
  127. package/lib/web/firefox_print_service.js +20 -10
  128. package/lib/web/firefoxcom.js +315 -80
  129. package/lib/web/genericcom.js +89 -30
  130. package/lib/web/genericl10n.js +142 -30
  131. package/lib/web/grab_to_pan.js +28 -4
  132. package/lib/web/interfaces.js +170 -47
  133. package/lib/web/overlay_manager.js +235 -85
  134. package/lib/web/password_prompt.js +22 -14
  135. package/lib/web/pdf_attachment_viewer.js +38 -18
  136. package/lib/web/pdf_cursor_tools.js +39 -16
  137. package/lib/web/pdf_document_properties.js +255 -136
  138. package/lib/web/pdf_find_bar.js +84 -40
  139. package/lib/web/pdf_find_controller.js +495 -184
  140. package/lib/web/pdf_find_utils.js +111 -0
  141. package/lib/web/pdf_history.js +190 -53
  142. package/lib/web/pdf_link_service.js +138 -77
  143. package/lib/web/pdf_outline_viewer.js +122 -46
  144. package/lib/web/pdf_page_view.js +191 -67
  145. package/lib/web/pdf_presentation_mode.js +99 -34
  146. package/lib/web/pdf_print_service.js +61 -13
  147. package/lib/web/pdf_rendering_queue.js +28 -9
  148. package/lib/web/pdf_sidebar.js +141 -81
  149. package/lib/web/pdf_sidebar_resizer.js +42 -16
  150. package/lib/web/pdf_single_page_viewer.js +74 -66
  151. package/lib/web/pdf_thumbnail_view.js +104 -33
  152. package/lib/web/pdf_thumbnail_viewer.js +66 -26
  153. package/lib/web/pdf_viewer.component.js +112 -32
  154. package/lib/web/pdf_viewer.js +91 -52
  155. package/lib/web/preferences.js +284 -89
  156. package/lib/web/secondary_toolbar.js +165 -40
  157. package/lib/web/text_layer_builder.js +134 -59
  158. package/lib/web/toolbar.js +78 -43
  159. package/lib/web/ui_utils.js +462 -136
  160. package/lib/web/view_history.js +215 -67
  161. package/lib/web/viewer_compatibility.js +4 -13
  162. package/package.json +5 -4
  163. package/web/pdf_viewer.css +79 -11
  164. package/web/pdf_viewer.js +6107 -3748
  165. package/web/pdf_viewer.js.map +1 -1
  166. package/lib/display/dom_utils.js +0 -309
  167. package/lib/test/unit/dom_utils_spec.js +0 -89
  168. package/lib/test/unit/fonts_spec.js +0 -81
  169. package/lib/web/dom_events.js +0 -137
@@ -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 2017 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.
@@ -19,65 +19,45 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- 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; };
24
+ var _encodings = require("../../core/encodings");
25
25
 
26
- var _encodings = require('../../core/encodings');
26
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
27
27
 
28
28
  describe('encodings', function () {
29
29
  describe('getEncoding', 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
- var _iteratorNormalCompletion = true;
33
- var _didIteratorError = false;
34
- var _iteratorError = undefined;
35
32
 
36
- try {
37
- for (var _iterator = knownEncodingNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
38
- var knownEncodingName = _step.value;
39
-
40
- var encoding = (0, _encodings.getEncoding)(knownEncodingName);
41
- expect(Array.isArray(encoding)).toEqual(true);
42
- expect(encoding.length).toEqual(256);
43
- var _iteratorNormalCompletion2 = true;
44
- var _didIteratorError2 = false;
45
- var _iteratorError2 = undefined;
33
+ for (var _i = 0, _knownEncodingNames = knownEncodingNames; _i < _knownEncodingNames.length; _i++) {
34
+ var knownEncodingName = _knownEncodingNames[_i];
35
+ var encoding = (0, _encodings.getEncoding)(knownEncodingName);
36
+ expect(Array.isArray(encoding)).toEqual(true);
37
+ expect(encoding.length).toEqual(256);
38
+ var _iteratorNormalCompletion = true;
39
+ var _didIteratorError = false;
40
+ var _iteratorError = undefined;
46
41
 
42
+ try {
43
+ for (var _iterator = encoding[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
44
+ var item = _step.value;
45
+ expect(_typeof(item)).toEqual('string');
46
+ }
47
+ } catch (err) {
48
+ _didIteratorError = true;
49
+ _iteratorError = err;
50
+ } finally {
47
51
  try {
48
- for (var _iterator2 = encoding[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
49
- var item = _step2.value;
50
-
51
- expect(typeof item === 'undefined' ? 'undefined' : _typeof(item)).toEqual('string');
52
+ if (!_iteratorNormalCompletion && _iterator["return"] != null) {
53
+ _iterator["return"]();
52
54
  }
53
- } catch (err) {
54
- _didIteratorError2 = true;
55
- _iteratorError2 = err;
56
55
  } finally {
57
- try {
58
- if (!_iteratorNormalCompletion2 && _iterator2.return) {
59
- _iterator2.return();
60
- }
61
- } finally {
62
- if (_didIteratorError2) {
63
- throw _iteratorError2;
64
- }
56
+ if (_didIteratorError) {
57
+ throw _iteratorError;
65
58
  }
66
59
  }
67
60
  }
68
- } catch (err) {
69
- _didIteratorError = true;
70
- _iteratorError = err;
71
- } finally {
72
- try {
73
- if (!_iteratorNormalCompletion && _iterator.return) {
74
- _iterator.return();
75
- }
76
- } finally {
77
- if (_didIteratorError) {
78
- throw _iteratorError;
79
- }
80
- }
81
61
  }
82
62
  });
83
63
  it('fetches `null` for unknown encoding names', function () {
@@ -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 2017 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.
@@ -19,26 +19,27 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- var _primitives = require('../../core/primitives');
24
+ var _test_utils = require("./test_utils");
25
25
 
26
- var _util = require('../../shared/util');
26
+ var _primitives = require("../../core/primitives");
27
27
 
28
- var _stream = require('../../core/stream');
28
+ var _util = require("../../shared/util");
29
29
 
30
- var _operator_list = require('../../core/operator_list');
30
+ var _stream = require("../../core/stream");
31
31
 
32
- var _evaluator = require('../../core/evaluator');
32
+ var _operator_list = require("../../core/operator_list");
33
33
 
34
- var _worker = require('../../core/worker');
34
+ var _evaluator = require("../../core/evaluator");
35
35
 
36
- var _test_utils = require('./test_utils');
36
+ var _worker = require("../../core/worker");
37
37
 
38
38
  describe('evaluator', function () {
39
39
  function HandlerMock() {
40
40
  this.inputs = [];
41
41
  }
42
+
42
43
  HandlerMock.prototype = {
43
44
  send: function send(name, data) {
44
45
  this.inputs.push({
@@ -47,13 +48,15 @@ describe('evaluator', function () {
47
48
  });
48
49
  }
49
50
  };
51
+
50
52
  function ResourcesMock() {}
53
+
51
54
  ResourcesMock.prototype = {
52
55
  get: function get(name) {
53
56
  return this[name];
54
57
  }
55
58
  };
56
- function PdfManagerMock() {}
59
+
57
60
  function runOperatorListCheck(evaluator, stream, resources, callback) {
58
61
  var result = new _operator_list.OperatorList();
59
62
  var task = new _worker.WorkerTask('OperatorListCheck');
@@ -68,13 +71,14 @@ describe('evaluator', function () {
68
71
  callback(reason);
69
72
  });
70
73
  }
74
+
71
75
  var partialEvaluator;
72
76
  beforeAll(function (done) {
73
77
  partialEvaluator = new _evaluator.PartialEvaluator({
74
- pdfManager: new PdfManagerMock(),
75
78
  xref: new _test_utils.XRefMock(),
76
79
  handler: new HandlerMock(),
77
- pageIndex: 0
80
+ pageIndex: 0,
81
+ idFactory: (0, _test_utils.createIdFactory)(0)
78
82
  });
79
83
  done();
80
84
  });
@@ -209,6 +213,24 @@ describe('evaluator', function () {
209
213
  done();
210
214
  });
211
215
  });
216
+ it('should error if (many) path operators have too few arguments ' + '(bug 1443140)', function (done) {
217
+ var NUM_INVALID_OPS = 25;
218
+ var tempArr = new Array(NUM_INVALID_OPS + 1);
219
+ var invalidMoveText = tempArr.join('10 Td\n');
220
+ var moveTextStream = new _stream.StringStream(invalidMoveText);
221
+ runOperatorListCheck(partialEvaluator, moveTextStream, new ResourcesMock(), function (result) {
222
+ expect(result.argsArray).toEqual([]);
223
+ expect(result.fnArray).toEqual([]);
224
+ done();
225
+ });
226
+ var invalidLineTo = tempArr.join('20 l\n');
227
+ var lineToStream = new _stream.StringStream(invalidLineTo);
228
+ runOperatorListCheck(partialEvaluator, lineToStream, new ResourcesMock(), function (error) {
229
+ expect(error instanceof _util.FormatError).toEqual(true);
230
+ expect(error.message).toEqual('Invalid command l: expected 2 args, but received 1 args.');
231
+ done();
232
+ });
233
+ });
212
234
  it('should close opened saves', function (done) {
213
235
  var stream = new _stream.StringStream('qq');
214
236
  runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
@@ -221,7 +243,7 @@ describe('evaluator', function () {
221
243
  done();
222
244
  });
223
245
  });
224
- it('should skip paintXObject if name is missing', function (done) {
246
+ it('should error on paintXObject if name is missing', function (done) {
225
247
  var stream = new _stream.StringStream('/ Do');
226
248
  runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
227
249
  expect(result instanceof _util.FormatError).toEqual(true);
@@ -257,7 +279,7 @@ describe('evaluator', function () {
257
279
  task: task,
258
280
  resources: resources,
259
281
  operatorList: result
260
- }).catch(function () {
282
+ })["catch"](function () {
261
283
  expect(!!result.fnArray && !!result.argsArray).toEqual(true);
262
284
  expect(result.fnArray.length).toEqual(0);
263
285
  done();
@@ -272,7 +294,7 @@ describe('evaluator', function () {
272
294
  stream: stream,
273
295
  task: task,
274
296
  resources: resources
275
- }).catch(function () {
297
+ })["catch"](function () {
276
298
  expect(true).toEqual(true);
277
299
  done();
278
300
  });
@@ -280,6 +302,7 @@ describe('evaluator', function () {
280
302
  });
281
303
  describe('operator list', function () {
282
304
  function MessageHandlerMock() {}
305
+
283
306
  MessageHandlerMock.prototype = {
284
307
  send: function send() {}
285
308
  };
@@ -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 2017 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.
@@ -19,13 +19,13 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- var _function = require('../../core/function');
24
+ var _function = require("../../core/function");
25
25
 
26
- var _ps_parser = require('../../core/ps_parser');
26
+ var _ps_parser = require("../../core/ps_parser");
27
27
 
28
- var _stream = require('../../core/stream');
28
+ var _stream = require("../../core/stream");
29
29
 
30
30
  describe('function', function () {
31
31
  beforeEach(function () {
@@ -34,23 +34,29 @@ describe('function', function () {
34
34
  return {
35
35
  compare: function compare(actual, expected) {
36
36
  var result = {};
37
+
37
38
  if (actual.length !== expected.length) {
38
39
  result.pass = false;
39
40
  result.message = 'Array length: ' + actual.length + ', expected: ' + expected.length;
40
41
  return result;
41
42
  }
43
+
42
44
  result.pass = true;
45
+
43
46
  for (var i = 0; i < expected.length; i++) {
44
47
  var a = actual[i],
45
48
  b = expected[i];
49
+
46
50
  if (Array.isArray(b)) {
47
51
  if (a.length !== b.length) {
48
52
  result.pass = false;
49
53
  break;
50
54
  }
55
+
51
56
  for (var j = 0; j < a.length; j++) {
52
57
  var suba = a[j],
53
58
  subb = b[j];
59
+
54
60
  if (suba !== subb) {
55
61
  result.pass = false;
56
62
  break;
@@ -63,6 +69,7 @@ describe('function', function () {
63
69
  }
64
70
  }
65
71
  }
72
+
66
73
  return result;
67
74
  }
68
75
  };
@@ -75,6 +82,7 @@ describe('function', function () {
75
82
  var parser = new _ps_parser.PostScriptParser(new _ps_parser.PostScriptLexer(stream));
76
83
  return parser.parse();
77
84
  }
85
+
78
86
  it('parses empty programs', function () {
79
87
  var output = parse('{}');
80
88
  expect(output.length).toEqual(0);
@@ -133,6 +141,7 @@ describe('function', function () {
133
141
  var output = evaluator.execute();
134
142
  return output;
135
143
  }
144
+
136
145
  it('pushes stack', function () {
137
146
  var stack = evaluate('{ 99 }');
138
147
  var expectedStack = [99];
@@ -448,11 +457,13 @@ describe('function', function () {
448
457
  function check(code, domain, range, samples) {
449
458
  var compiler = new _function.PostScriptCompiler();
450
459
  var compiledCode = compiler.compile(code, domain, range);
460
+
451
461
  if (samples === null) {
452
462
  expect(compiledCode).toBeNull();
453
463
  } else {
454
464
  expect(compiledCode).not.toBeNull();
455
465
  var fn = new Function('src', 'srcOffset', 'dest', 'destOffset', compiledCode);
466
+
456
467
  for (var i = 0; i < samples.length; i++) {
457
468
  var out = new Float32Array(samples[i].output.length);
458
469
  fn(samples[i].input, 0, out, 0);
@@ -460,6 +471,7 @@ describe('function', function () {
460
471
  }
461
472
  }
462
473
  }
474
+
463
475
  it('check compiled add', function () {
464
476
  check([0.25, 0.5, 'add'], [], [0, 1], [{
465
477
  input: [],
@@ -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 2017 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,17 +22,19 @@
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/fonts_spec', 'pdfjs-test/unit/function_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_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', 'pdfjs-test/unit/util_stream_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;
30
30
  var PDFNetworkStream = modules[2].PDFNetworkStream;
31
31
  var PDFFetchStream = modules[3].PDFFetchStream;
32
32
  var isNodeJS = modules[4];
33
+
33
34
  if (isNodeJS()) {
34
35
  throw new Error('The `gulp unittest` command cannot be used in ' + 'Node.js environments.');
35
36
  }
37
+
36
38
  if (typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream !== 'undefined') {
37
39
  displayApi.setPDFNetworkStreamFactory(function (params) {
38
40
  return new PDFFetchStream(params);
@@ -42,41 +44,44 @@ function initializePDFJS(callback) {
42
44
  return new PDFNetworkStream(params);
43
45
  });
44
46
  }
47
+
45
48
  GlobalWorkerOptions.workerSrc = '../../build/generic/build/pdf.worker.js';
46
49
  callback();
47
50
  });
48
51
  }
52
+
49
53
  (function () {
50
54
  window.jasmine = jasmineRequire.core(jasmineRequire);
51
55
  jasmineRequire.html(jasmine);
52
56
  var env = jasmine.getEnv();
53
- var jasmineInterface = jasmineRequire.interface(jasmine, env);
57
+ var jasmineInterface = jasmineRequire["interface"](jasmine, env);
54
58
  extend(window, jasmineInterface);
55
59
  var queryString = new jasmine.QueryString({
56
60
  getWindowLocation: function getWindowLocation() {
57
61
  return window.location;
58
62
  }
59
63
  });
60
- var stoppingOnSpecFailure = queryString.getParam('failFast');
61
- env.stopOnSpecFailure(typeof stoppingOnSpecFailure === 'undefined' ? false : stoppingOnSpecFailure);
62
- var throwingExpectationFailures = queryString.getParam('throwFailures');
63
- env.throwOnExpectationFailure(throwingExpectationFailures);
64
+ var config = {
65
+ failFast: queryString.getParam('failFast'),
66
+ oneFailurePerSpec: queryString.getParam('oneFailurePerSpec'),
67
+ hideDisabled: queryString.getParam('hideDisabled')
68
+ };
64
69
  var random = queryString.getParam('random');
65
- env.randomizeTests(random);
70
+
71
+ if (random !== undefined && random !== '') {
72
+ config.random = random;
73
+ }
74
+
66
75
  var seed = queryString.getParam('seed');
76
+
67
77
  if (seed) {
68
- env.seed(seed);
78
+ config.seed = seed;
69
79
  }
80
+
70
81
  var htmlReporter = new jasmine.HtmlReporter({
71
82
  env: env,
72
- onStopExecutionClick: function onStopExecutionClick() {
73
- queryString.navigateWithNewParam('failFast', env.stoppingOnSpecFailure());
74
- },
75
- onThrowExpectationsClick: function onThrowExpectationsClick() {
76
- queryString.navigateWithNewParam('throwFailures', !env.throwingExpectationFailures());
77
- },
78
- onRandomClick: function onRandomClick() {
79
- queryString.navigateWithNewParam('random', !env.randomTests());
83
+ navigateWithNewParam: function navigateWithNewParam(key, value) {
84
+ return queryString.navigateWithNewParam(key, value);
80
85
  },
81
86
  addToExistingQueryString: function addToExistingQueryString(key, value) {
82
87
  return queryString.fullStringWithNewParam(key, value);
@@ -90,37 +95,45 @@ function initializePDFJS(callback) {
90
95
  createTextNode: function createTextNode() {
91
96
  return document.createTextNode.apply(document, arguments);
92
97
  },
93
-
94
98
  timer: new jasmine.Timer()
95
99
  });
96
100
  env.addReporter(htmlReporter);
101
+
97
102
  if (queryString.getParam('browser')) {
98
103
  var testReporter = new TestReporter(queryString.getParam('browser'), queryString.getParam('path'));
99
104
  env.addReporter(testReporter);
100
105
  }
106
+
101
107
  var specFilter = new jasmine.HtmlSpecFilter({
102
108
  filterString: function filterString() {
103
109
  return queryString.getParam('spec');
104
110
  }
105
111
  });
106
- env.specFilter = function (spec) {
112
+
113
+ config.specFilter = function (spec) {
107
114
  return specFilter.matches(spec.getFullName());
108
115
  };
116
+
117
+ env.configure(config);
109
118
  jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
110
119
  var currentWindowOnload = window.onload;
120
+
111
121
  window.onload = function () {
112
122
  if (currentWindowOnload) {
113
123
  currentWindowOnload();
114
124
  }
125
+
115
126
  initializePDFJS(function () {
116
127
  htmlReporter.initialize();
117
128
  env.execute();
118
129
  });
119
130
  };
131
+
120
132
  function extend(destination, source) {
121
133
  for (var property in source) {
122
134
  destination[property] = source[property];
123
135
  }
136
+
124
137
  return destination;
125
138
  }
126
139
  })();