pdfjs-dist 2.0.487 → 2.1.266

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 (161) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +15564 -9476
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +46644 -36309
  6. package/build/pdf.worker.js.map +1 -1
  7. package/build/pdf.worker.min.js +1 -1
  8. package/external/url/url-lib.js +627 -0
  9. package/image_decoders/pdf.image_decoders.js +11430 -0
  10. package/image_decoders/pdf.image_decoders.js.map +1 -0
  11. package/image_decoders/pdf.image_decoders.min.js +1 -0
  12. package/lib/core/annotation.js +406 -131
  13. package/lib/core/arithmetic_decoder.js +275 -245
  14. package/lib/core/bidi.js +65 -6
  15. package/lib/core/ccitt.js +173 -18
  16. package/lib/core/ccitt_stream.js +15 -6
  17. package/lib/core/cff_parser.js +376 -53
  18. package/lib/core/charsets.js +5 -4
  19. package/lib/core/chunked_stream.js +387 -149
  20. package/lib/core/cmap.js +310 -75
  21. package/lib/core/colorspace.js +874 -594
  22. package/lib/core/crypto.js +290 -45
  23. package/lib/core/document.js +545 -260
  24. package/lib/core/encodings.js +19 -10
  25. package/lib/core/evaluator.js +725 -147
  26. package/lib/core/font_renderer.js +360 -91
  27. package/lib/core/fonts.js +791 -186
  28. package/lib/core/function.js +284 -71
  29. package/lib/core/glyphlist.js +3 -2
  30. package/lib/core/image.js +168 -61
  31. package/lib/core/jbig2.js +479 -66
  32. package/lib/core/jbig2_stream.js +19 -8
  33. package/lib/core/jpeg_stream.js +38 -13
  34. package/lib/core/jpg.js +252 -29
  35. package/lib/core/jpx.js +396 -6
  36. package/lib/core/jpx_stream.js +18 -6
  37. package/lib/core/metrics.js +4 -4
  38. package/lib/core/murmurhash3.js +24 -6
  39. package/lib/core/obj.js +1137 -475
  40. package/lib/core/operator_list.js +108 -6
  41. package/lib/core/parser.js +321 -68
  42. package/lib/core/pattern.js +145 -13
  43. package/lib/core/pdf_manager.js +321 -133
  44. package/lib/core/primitives.js +75 -22
  45. package/lib/core/ps_parser.js +134 -45
  46. package/lib/core/standard_fonts.js +10 -10
  47. package/lib/core/stream.js +313 -34
  48. package/lib/core/type1_parser.js +143 -13
  49. package/lib/core/unicode.js +31 -4
  50. package/lib/core/worker.js +210 -66
  51. package/lib/display/annotation_layer.js +361 -123
  52. package/lib/display/api.js +1454 -729
  53. package/lib/display/api_compatibility.js +11 -13
  54. package/lib/display/canvas.js +324 -29
  55. package/lib/display/content_disposition.js +83 -32
  56. package/lib/display/dom_utils.js +226 -41
  57. package/lib/display/fetch_stream.js +208 -84
  58. package/lib/display/font_loader.js +465 -236
  59. package/lib/display/metadata.js +38 -16
  60. package/lib/display/network.js +216 -51
  61. package/lib/display/network_utils.js +32 -19
  62. package/lib/display/node_stream.js +352 -169
  63. package/lib/display/pattern_helper.js +58 -7
  64. package/lib/display/svg.js +242 -29
  65. package/lib/display/text_layer.js +132 -18
  66. package/lib/display/transport_stream.js +171 -42
  67. package/lib/display/webgl.js +64 -18
  68. package/lib/display/worker_options.js +5 -4
  69. package/lib/display/xml_parser.js +166 -53
  70. package/lib/examples/node/domstubs.js +57 -4
  71. package/lib/pdf.js +21 -4
  72. package/lib/pdf.worker.js +5 -3
  73. package/lib/shared/compatibility.js +158 -564
  74. package/lib/shared/global_scope.js +2 -2
  75. package/lib/shared/is_node.js +4 -4
  76. package/lib/shared/message_handler.js +521 -0
  77. package/lib/shared/streams_polyfill.js +21 -17
  78. package/lib/shared/url_polyfill.js +56 -0
  79. package/lib/shared/util.js +295 -650
  80. package/lib/test/unit/annotation_spec.js +629 -345
  81. package/lib/test/unit/api_spec.js +555 -253
  82. package/lib/test/unit/bidi_spec.js +7 -7
  83. package/lib/test/unit/cff_parser_spec.js +40 -11
  84. package/lib/test/unit/clitests_helper.js +9 -7
  85. package/lib/test/unit/cmap_spec.js +80 -26
  86. package/lib/test/unit/colorspace_spec.js +99 -52
  87. package/lib/test/unit/crypto_spec.js +17 -5
  88. package/lib/test/unit/custom_spec.js +41 -53
  89. package/lib/test/unit/display_svg_spec.js +33 -17
  90. package/lib/test/unit/document_spec.js +3 -3
  91. package/lib/test/unit/dom_utils_spec.js +9 -9
  92. package/lib/test/unit/encodings_spec.js +25 -45
  93. package/lib/test/unit/evaluator_spec.js +34 -9
  94. package/lib/test/unit/function_spec.js +17 -5
  95. package/lib/test/unit/jasmine-boot.js +31 -18
  96. package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
  97. package/lib/test/unit/metadata_spec.js +71 -11
  98. package/lib/test/unit/murmurhash3_spec.js +3 -3
  99. package/lib/test/unit/network_spec.js +20 -5
  100. package/lib/test/unit/network_utils_spec.js +41 -14
  101. package/lib/test/unit/node_stream_spec.js +51 -27
  102. package/lib/test/unit/parser_spec.js +35 -8
  103. package/lib/test/unit/pdf_find_controller_spec.js +230 -0
  104. package/lib/test/unit/pdf_find_utils_spec.js +63 -0
  105. package/lib/test/unit/pdf_history_spec.js +21 -9
  106. package/lib/test/unit/primitives_spec.js +24 -4
  107. package/lib/test/unit/stream_spec.js +12 -4
  108. package/lib/test/unit/test_utils.js +90 -27
  109. package/lib/test/unit/testreporter.js +21 -3
  110. package/lib/test/unit/type1_parser_spec.js +8 -6
  111. package/lib/test/unit/ui_utils_spec.js +452 -14
  112. package/lib/test/unit/unicode_spec.js +14 -11
  113. package/lib/test/unit/util_spec.js +131 -9
  114. package/lib/web/annotation_layer_builder.js +39 -22
  115. package/lib/web/app.js +1240 -582
  116. package/lib/web/app_options.js +71 -41
  117. package/lib/web/base_viewer.js +508 -179
  118. package/lib/web/chromecom.js +261 -117
  119. package/lib/web/debugger.js +166 -22
  120. package/lib/web/download_manager.js +31 -13
  121. package/lib/web/firefox_print_service.js +17 -9
  122. package/lib/web/firefoxcom.js +283 -79
  123. package/lib/web/genericcom.js +89 -30
  124. package/lib/web/genericl10n.js +142 -30
  125. package/lib/web/grab_to_pan.js +26 -4
  126. package/lib/web/interfaces.js +170 -47
  127. package/lib/web/overlay_manager.js +235 -85
  128. package/lib/web/password_prompt.js +21 -13
  129. package/lib/web/pdf_attachment_viewer.js +38 -18
  130. package/lib/web/pdf_cursor_tools.js +39 -16
  131. package/lib/web/pdf_document_properties.js +80 -30
  132. package/lib/web/pdf_find_bar.js +84 -40
  133. package/lib/web/pdf_find_controller.js +495 -184
  134. package/lib/web/pdf_find_utils.js +111 -0
  135. package/lib/web/pdf_history.js +190 -53
  136. package/lib/web/pdf_link_service.js +137 -76
  137. package/lib/web/pdf_outline_viewer.js +73 -22
  138. package/lib/web/pdf_page_view.js +196 -63
  139. package/lib/web/pdf_presentation_mode.js +99 -34
  140. package/lib/web/pdf_print_service.js +57 -11
  141. package/lib/web/pdf_rendering_queue.js +27 -5
  142. package/lib/web/pdf_sidebar.js +120 -67
  143. package/lib/web/pdf_sidebar_resizer.js +42 -16
  144. package/lib/web/pdf_single_page_viewer.js +74 -66
  145. package/lib/web/pdf_thumbnail_view.js +103 -32
  146. package/lib/web/pdf_thumbnail_viewer.js +64 -24
  147. package/lib/web/pdf_viewer.component.js +112 -32
  148. package/lib/web/pdf_viewer.js +91 -52
  149. package/lib/web/preferences.js +275 -80
  150. package/lib/web/secondary_toolbar.js +165 -40
  151. package/lib/web/text_layer_builder.js +162 -65
  152. package/lib/web/toolbar.js +78 -43
  153. package/lib/web/ui_utils.js +462 -136
  154. package/lib/web/view_history.js +215 -67
  155. package/lib/web/viewer_compatibility.js +4 -13
  156. package/package.json +5 -4
  157. package/web/pdf_viewer.css +58 -1
  158. package/web/pdf_viewer.js +6346 -3919
  159. package/web/pdf_viewer.js.map +1 -1
  160. package/lib/test/unit/fonts_spec.js +0 -81
  161. 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 2018 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,9 +19,9 @@
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 _document = require('../../core/document');
24
+ var _document = require("../../core/document");
25
25
 
26
26
  describe('document', function () {
27
27
  describe('Page', 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 2018 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,19 +19,17 @@
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 _dom_utils = require('../../display/dom_utils');
24
+ var _dom_utils = require("../../display/dom_utils");
25
25
 
26
- var _is_node = require('../../shared/is_node');
27
-
28
- var _is_node2 = _interopRequireDefault(_is_node);
26
+ var _is_node = _interopRequireDefault(require("../../shared/is_node"));
29
27
 
30
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
29
 
32
30
  describe('dom_utils', function () {
33
31
  describe('DOMSVGFactory', function () {
34
- var svgFactory = void 0;
32
+ var svgFactory;
35
33
  beforeAll(function (done) {
36
34
  svgFactory = new _dom_utils.DOMSVGFactory();
37
35
  done();
@@ -48,9 +46,10 @@ describe('dom_utils', function () {
48
46
  }).toThrow(new Error('Invalid SVG dimensions'));
49
47
  });
50
48
  it('`create` should return an SVG element if the dimensions are valid', function () {
51
- if ((0, _is_node2.default)()) {
49
+ if ((0, _is_node.default)()) {
52
50
  pending('Document is not supported in Node.js.');
53
51
  }
52
+
54
53
  var svg = svgFactory.create(20, 40);
55
54
  expect(svg instanceof SVGSVGElement).toBe(true);
56
55
  expect(svg.getAttribute('version')).toBe('1.1');
@@ -65,9 +64,10 @@ describe('dom_utils', function () {
65
64
  }).toThrow(new Error('Invalid SVG element type'));
66
65
  });
67
66
  it('`createElement` should return an SVG element if the type is valid', function () {
68
- if ((0, _is_node2.default)()) {
67
+ if ((0, _is_node.default)()) {
69
68
  pending('Document is not supported in Node.js.');
70
69
  }
70
+
71
71
  var svg = svgFactory.createElement('svg:rect');
72
72
  expect(svg instanceof SVGRectElement).toBe(true);
73
73
  });
@@ -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 2018 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; _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 2018 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 _primitives = require("../../core/primitives");
25
25
 
26
- var _util = require('../../shared/util');
26
+ var _util = require("../../shared/util");
27
27
 
28
- var _stream = require('../../core/stream');
28
+ var _stream = require("../../core/stream");
29
29
 
30
- var _operator_list = require('../../core/operator_list');
30
+ var _operator_list = require("../../core/operator_list");
31
31
 
32
- var _evaluator = require('../../core/evaluator');
32
+ var _evaluator = require("../../core/evaluator");
33
33
 
34
- var _worker = require('../../core/worker');
34
+ var _worker = require("../../core/worker");
35
35
 
36
- var _test_utils = require('./test_utils');
36
+ var _test_utils = require("./test_utils");
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,17 @@ 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
  };
59
+
56
60
  function PdfManagerMock() {}
61
+
57
62
  function runOperatorListCheck(evaluator, stream, resources, callback) {
58
63
  var result = new _operator_list.OperatorList();
59
64
  var task = new _worker.WorkerTask('OperatorListCheck');
@@ -68,6 +73,7 @@ describe('evaluator', function () {
68
73
  callback(reason);
69
74
  });
70
75
  }
76
+
71
77
  var partialEvaluator;
72
78
  beforeAll(function (done) {
73
79
  partialEvaluator = new _evaluator.PartialEvaluator({
@@ -209,6 +215,24 @@ describe('evaluator', function () {
209
215
  done();
210
216
  });
211
217
  });
218
+ it('should error if (many) path operators have too few arguments ' + '(bug 1443140)', function (done) {
219
+ var NUM_INVALID_OPS = 25;
220
+ var tempArr = new Array(NUM_INVALID_OPS + 1);
221
+ var invalidMoveText = tempArr.join('10 Td\n');
222
+ var moveTextStream = new _stream.StringStream(invalidMoveText);
223
+ runOperatorListCheck(partialEvaluator, moveTextStream, new ResourcesMock(), function (result) {
224
+ expect(result.argsArray).toEqual([]);
225
+ expect(result.fnArray).toEqual([]);
226
+ done();
227
+ });
228
+ var invalidLineTo = tempArr.join('20 l\n');
229
+ var lineToStream = new _stream.StringStream(invalidLineTo);
230
+ runOperatorListCheck(partialEvaluator, lineToStream, new ResourcesMock(), function (error) {
231
+ expect(error instanceof _util.FormatError).toEqual(true);
232
+ expect(error.message).toEqual('Invalid command l: expected 2 args, but received 1 args.');
233
+ done();
234
+ });
235
+ });
212
236
  it('should close opened saves', function (done) {
213
237
  var stream = new _stream.StringStream('qq');
214
238
  runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
@@ -280,6 +304,7 @@ describe('evaluator', function () {
280
304
  });
281
305
  describe('operator list', function () {
282
306
  function MessageHandlerMock() {}
307
+
283
308
  MessageHandlerMock.prototype = {
284
309
  send: function send() {}
285
310
  };
@@ -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 2018 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 2018 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,7 +22,7 @@
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) {
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
26
  return SystemJS.import(moduleName);
27
27
  })).then(function (modules) {
28
28
  var displayApi = modules[0];
@@ -30,9 +30,11 @@ function initializePDFJS(callback) {
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,10 +44,12 @@ 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);
@@ -57,26 +61,27 @@ function initializePDFJS(callback) {
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
  })();