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
@@ -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.
@@ -304,4 +304,18 @@ describe('CFFCompiler', function () {
304
304
  var out = c.compileFDSelect(fdSelect);
305
305
  expect(out).toEqual([3, 0, 1, 0, 0, 0, 0, 2]);
306
306
  });
307
+ it('compiles charset of CID font', function () {
308
+ var charset = new _cff_parser.CFFCharset();
309
+ var c = new _cff_parser.CFFCompiler();
310
+ var numGlyphs = 7;
311
+ var out = c.compileCharset(charset, numGlyphs, new _cff_parser.CFFStrings(), true);
312
+ expect(out).toEqual([2, 0, 0, 0, numGlyphs - 1]);
313
+ });
314
+ it('compiles charset of non CID font', function () {
315
+ var charset = new _cff_parser.CFFCharset(false, 0, ['space', 'exclam']);
316
+ var c = new _cff_parser.CFFCompiler();
317
+ var numGlyphs = 3;
318
+ var out = c.compileCharset(charset, numGlyphs, new _cff_parser.CFFStrings(), false);
319
+ expect(out).toEqual([0, 0, 1, 0, 2]);
320
+ });
307
321
  });
@@ -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.
@@ -29,9 +29,9 @@ var _node_stream = require("../../display/node_stream");
29
29
 
30
30
  var _api = require("../../display/api");
31
31
 
32
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
33
33
 
34
- if (!(0, _is_node.default)()) {
34
+ if (!(0, _is_node["default"])()) {
35
35
  throw new Error('The `gulp unittestcli` command can only be used in ' + 'Node.js environments.');
36
36
  }
37
37
 
@@ -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.
@@ -23,7 +23,7 @@
23
23
 
24
24
  var _cmap = require("../../core/cmap");
25
25
 
26
- var _dom_utils = require("../../display/dom_utils");
26
+ var _display_utils = require("../../display/display_utils");
27
27
 
28
28
  var _is_node = _interopRequireDefault(require("../../shared/is_node"));
29
29
 
@@ -33,7 +33,7 @@ var _test_utils = require("./test_utils");
33
33
 
34
34
  var _stream = require("../../core/stream");
35
35
 
36
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
37
37
 
38
38
  var cMapUrl = {
39
39
  dom: '../../external/bcmaps/',
@@ -45,13 +45,13 @@ describe('cmap', function () {
45
45
  beforeAll(function (done) {
46
46
  var CMapReaderFactory;
47
47
 
48
- if ((0, _is_node.default)()) {
48
+ if ((0, _is_node["default"])()) {
49
49
  CMapReaderFactory = new _test_utils.NodeCMapReaderFactory({
50
50
  baseUrl: cMapUrl.node,
51
51
  isCompressed: cMapPacked
52
52
  });
53
53
  } else {
54
- CMapReaderFactory = new _dom_utils.DOMCMapReaderFactory({
54
+ CMapReaderFactory = new _display_utils.DOMCMapReaderFactory({
55
55
  baseUrl: cMapUrl.dom,
56
56
  isCompressed: cMapPacked
57
57
  });
@@ -81,7 +81,7 @@ describe('cmap', function () {
81
81
  expect(cmap.lookup(0x04)).toEqual(String.fromCharCode(0x01));
82
82
  expect(cmap.lookup(0x05)).toBeUndefined();
83
83
  done();
84
- }).catch(function (reason) {
84
+ })["catch"](function (reason) {
85
85
  done.fail(reason);
86
86
  });
87
87
  });
@@ -99,7 +99,7 @@ describe('cmap', function () {
99
99
  expect(cmap.lookup(0x0B)).toEqual(String.fromCharCode(0x05));
100
100
  expect(cmap.lookup(0x0C)).toBeUndefined();
101
101
  done();
102
- }).catch(function (reason) {
102
+ })["catch"](function (reason) {
103
103
  done.fail(reason);
104
104
  });
105
105
  });
@@ -117,7 +117,7 @@ describe('cmap', function () {
117
117
  expect(cmap.lookup(0x12)).toEqual(0x05);
118
118
  expect(cmap.lookup(0x13)).toBeUndefined();
119
119
  done();
120
- }).catch(function (reason) {
120
+ })["catch"](function (reason) {
121
121
  done.fail(reason);
122
122
  });
123
123
  });
@@ -133,7 +133,7 @@ describe('cmap', function () {
133
133
  expect(cmap.lookup(0x14)).toEqual(0x00);
134
134
  expect(cmap.lookup(0x15)).toBeUndefined();
135
135
  done();
136
- }).catch(function (reason) {
136
+ })["catch"](function (reason) {
137
137
  done.fail(reason);
138
138
  });
139
139
  });
@@ -151,7 +151,7 @@ describe('cmap', function () {
151
151
  expect(cmap.lookup(0x1B)).toEqual(0x05);
152
152
  expect(cmap.lookup(0x1C)).toBeUndefined();
153
153
  done();
154
- }).catch(function (reason) {
154
+ })["catch"](function (reason) {
155
155
  done.fail(reason);
156
156
  });
157
157
  });
@@ -172,7 +172,7 @@ describe('cmap', function () {
172
172
  expect(c.charcode).toEqual(3);
173
173
  expect(c.length).toEqual(4);
174
174
  done();
175
- }).catch(function (reason) {
175
+ })["catch"](function (reason) {
176
176
  done.fail(reason);
177
177
  });
178
178
  });
@@ -190,7 +190,7 @@ describe('cmap', function () {
190
190
  expect(c.charcode).toEqual(0x8EA1A1A1);
191
191
  expect(c.length).toEqual(4);
192
192
  done();
193
- }).catch(function (reason) {
193
+ })["catch"](function (reason) {
194
194
  done.fail(reason);
195
195
  });
196
196
  });
@@ -211,7 +211,7 @@ describe('cmap', function () {
211
211
  expect(cmap.length).toEqual(0x20A7);
212
212
  expect(cmap.isIdentityCMap).toEqual(false);
213
213
  done();
214
- }).catch(function (reason) {
214
+ })["catch"](function (reason) {
215
215
  done.fail(reason);
216
216
  });
217
217
  });
@@ -226,7 +226,7 @@ describe('cmap', function () {
226
226
  cmapPromise.then(function (cmap) {
227
227
  expect(cmap.name).toEqual('Identity-H');
228
228
  done();
229
- }).catch(function (reason) {
229
+ })["catch"](function (reason) {
230
230
  done.fail(reason);
231
231
  });
232
232
  });
@@ -241,7 +241,7 @@ describe('cmap', function () {
241
241
  cmapPromise.then(function (cmap) {
242
242
  expect(cmap.vertical).toEqual(true);
243
243
  done();
244
- }).catch(function (reason) {
244
+ })["catch"](function (reason) {
245
245
  done.fail(reason);
246
246
  });
247
247
  });
@@ -259,7 +259,7 @@ describe('cmap', function () {
259
259
  expect(cmap.length).toEqual(0x20A7);
260
260
  expect(cmap.isIdentityCMap).toEqual(false);
261
261
  done();
262
- }).catch(function (reason) {
262
+ })["catch"](function (reason) {
263
263
  done.fail(reason);
264
264
  });
265
265
  });
@@ -278,7 +278,7 @@ describe('cmap', function () {
278
278
  return cmap.isIdentityCMap;
279
279
  }).toThrow(new Error('should not access .isIdentityCMap'));
280
280
  done();
281
- }).catch(function (reason) {
281
+ })["catch"](function (reason) {
282
282
  done.fail(reason);
283
283
  });
284
284
  });
@@ -299,7 +299,7 @@ describe('cmap', function () {
299
299
  });
300
300
  it('attempts to load a built-in CMap without the necessary API parameters', function (done) {
301
301
  function tmpFetchBuiltInCMap(name) {
302
- var CMapReaderFactory = (0, _is_node.default)() ? new _test_utils.NodeCMapReaderFactory({}) : new _dom_utils.DOMCMapReaderFactory({});
302
+ var CMapReaderFactory = (0, _is_node["default"])() ? new _test_utils.NodeCMapReaderFactory({}) : new _display_utils.DOMCMapReaderFactory({});
303
303
  return CMapReaderFactory.fetch({
304
304
  name: name
305
305
  });
@@ -323,13 +323,13 @@ describe('cmap', function () {
323
323
  function tmpFetchBuiltInCMap(name) {
324
324
  var CMapReaderFactory;
325
325
 
326
- if ((0, _is_node.default)()) {
326
+ if ((0, _is_node["default"])()) {
327
327
  CMapReaderFactory = new _test_utils.NodeCMapReaderFactory({
328
328
  baseUrl: cMapUrl.node,
329
329
  isCompressed: false
330
330
  });
331
331
  } else {
332
- CMapReaderFactory = new _dom_utils.DOMCMapReaderFactory({
332
+ CMapReaderFactory = new _display_utils.DOMCMapReaderFactory({
333
333
  baseUrl: cMapUrl.dom,
334
334
  isCompressed: false
335
335
  });
@@ -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.
@@ -55,7 +55,7 @@ describe('colorspace', function () {
55
55
  var cs = _primitives.Name.get('DeviceGray');
56
56
 
57
57
  var xref = new _test_utils.XRefMock([{
58
- ref: new _primitives.Ref(10, 0),
58
+ ref: _primitives.Ref.get(10, 0),
59
59
  data: new _primitives.Dict()
60
60
  }]);
61
61
  var res = new _primitives.Dict();
@@ -75,7 +75,8 @@ describe('colorspace', function () {
75
75
  expect(testDest).toEqual(expectedDest);
76
76
  });
77
77
  it('should handle the case when cs is an indirect object', function () {
78
- var cs = new _primitives.Ref(10, 0);
78
+ var cs = _primitives.Ref.get(10, 0);
79
+
79
80
  var xref = new _test_utils.XRefMock([{
80
81
  ref: cs,
81
82
  data: _primitives.Name.get('DeviceGray')
@@ -102,7 +103,7 @@ describe('colorspace', function () {
102
103
  var cs = _primitives.Name.get('DeviceRGB');
103
104
 
104
105
  var xref = new _test_utils.XRefMock([{
105
- ref: new _primitives.Ref(10, 0),
106
+ ref: _primitives.Ref.get(10, 0),
106
107
  data: new _primitives.Dict()
107
108
  }]);
108
109
  var res = new _primitives.Dict();
@@ -122,7 +123,8 @@ describe('colorspace', function () {
122
123
  expect(testDest).toEqual(expectedDest);
123
124
  });
124
125
  it('should handle the case when cs is an indirect object', function () {
125
- var cs = new _primitives.Ref(10, 0);
126
+ var cs = _primitives.Ref.get(10, 0);
127
+
126
128
  var xref = new _test_utils.XRefMock([{
127
129
  ref: cs,
128
130
  data: _primitives.Name.get('DeviceRGB')
@@ -149,7 +151,7 @@ describe('colorspace', function () {
149
151
  var cs = _primitives.Name.get('DeviceCMYK');
150
152
 
151
153
  var xref = new _test_utils.XRefMock([{
152
- ref: new _primitives.Ref(10, 0),
154
+ ref: _primitives.Ref.get(10, 0),
153
155
  data: new _primitives.Dict()
154
156
  }]);
155
157
  var res = new _primitives.Dict();
@@ -169,7 +171,8 @@ describe('colorspace', function () {
169
171
  expect(testDest).toEqual(expectedDest);
170
172
  });
171
173
  it('should handle the case when cs is an indirect object', function () {
172
- var cs = new _primitives.Ref(10, 0);
174
+ var cs = _primitives.Ref.get(10, 0);
175
+
173
176
  var xref = new _test_utils.XRefMock([{
174
177
  ref: cs,
175
178
  data: _primitives.Name.get('DeviceCMYK')
@@ -199,7 +202,7 @@ describe('colorspace', function () {
199
202
  params.set('Gamma', 2.0);
200
203
  var cs = [_primitives.Name.get('CalGray'), params];
201
204
  var xref = new _test_utils.XRefMock([{
202
- ref: new _primitives.Ref(10, 0),
205
+ ref: _primitives.Ref.get(10, 0),
203
206
  data: new _primitives.Dict()
204
207
  }]);
205
208
  var res = new _primitives.Dict();
@@ -228,7 +231,7 @@ describe('colorspace', function () {
228
231
  params.set('Matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
229
232
  var cs = [_primitives.Name.get('CalRGB'), params];
230
233
  var xref = new _test_utils.XRefMock([{
231
- ref: new _primitives.Ref(10, 0),
234
+ ref: _primitives.Ref.get(10, 0),
232
235
  data: new _primitives.Dict()
233
236
  }]);
234
237
  var res = new _primitives.Dict();
@@ -256,7 +259,7 @@ describe('colorspace', function () {
256
259
  params.set('Range', [-100, 100, -100, 100]);
257
260
  var cs = [_primitives.Name.get('Lab'), params];
258
261
  var xref = new _test_utils.XRefMock([{
259
- ref: new _primitives.Ref(10, 0),
262
+ ref: _primitives.Ref.get(10, 0),
260
263
  data: new _primitives.Dict()
261
264
  }]);
262
265
  var res = new _primitives.Dict();
@@ -282,7 +285,7 @@ describe('colorspace', function () {
282
285
  var lookup = new Uint8Array([23, 155, 35, 147, 69, 93, 255, 109, 70]);
283
286
  var cs = [_primitives.Name.get('Indexed'), _primitives.Name.get('DeviceRGB'), 2, lookup];
284
287
  var xref = new _test_utils.XRefMock([{
285
- ref: new _primitives.Ref(10, 0),
288
+ ref: _primitives.Ref.get(10, 0),
286
289
  data: new _primitives.Dict()
287
290
  }]);
288
291
  var res = new _primitives.Dict();
@@ -311,7 +314,9 @@ describe('colorspace', function () {
311
314
  fnDict.set('Length', 58);
312
315
  var fn = new _stream.StringStream('{ dup 0.84 mul ' + 'exch 0.00 exch ' + 'dup 0.44 mul ' + 'exch 0.21 mul }');
313
316
  fn = new _stream.Stream(fn.bytes, 0, 58, fnDict);
314
- var fnRef = new _primitives.Ref(10, 0);
317
+
318
+ var fnRef = _primitives.Ref.get(10, 0);
319
+
315
320
  var cs = [_primitives.Name.get('Separation'), _primitives.Name.get('LogoGreen'), _primitives.Name.get('DeviceCMYK'), fnRef];
316
321
  var xref = new _test_utils.XRefMock([{
317
322
  ref: fnRef,
@@ -0,0 +1,191 @@
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 _primitives = require("../../core/primitives");
25
+
26
+ var _core_utils = require("../../core/core_utils");
27
+
28
+ var _test_utils = require("./test_utils");
29
+
30
+ describe('core_utils', function () {
31
+ describe('getInheritableProperty', function () {
32
+ it('handles non-dictionary arguments', function () {
33
+ expect((0, _core_utils.getInheritableProperty)({
34
+ dict: null,
35
+ key: 'foo'
36
+ })).toEqual(undefined);
37
+ expect((0, _core_utils.getInheritableProperty)({
38
+ dict: undefined,
39
+ key: 'foo'
40
+ })).toEqual(undefined);
41
+ });
42
+ it('handles dictionaries that do not contain the property', function () {
43
+ var emptyDict = new _primitives.Dict();
44
+ expect((0, _core_utils.getInheritableProperty)({
45
+ dict: emptyDict,
46
+ key: 'foo'
47
+ })).toEqual(undefined);
48
+ var filledDict = new _primitives.Dict();
49
+ filledDict.set('bar', 'baz');
50
+ expect((0, _core_utils.getInheritableProperty)({
51
+ dict: filledDict,
52
+ key: 'foo'
53
+ })).toEqual(undefined);
54
+ });
55
+ it('fetches the property if it is not inherited', function () {
56
+ var ref = _primitives.Ref.get(10, 0);
57
+
58
+ var xref = new _test_utils.XRefMock([{
59
+ ref: ref,
60
+ data: 'quux'
61
+ }]);
62
+ var dict = new _primitives.Dict(xref);
63
+ dict.set('foo', 'bar');
64
+ expect((0, _core_utils.getInheritableProperty)({
65
+ dict: dict,
66
+ key: 'foo'
67
+ })).toEqual('bar');
68
+ dict.set('baz', ['qux', ref]);
69
+ expect((0, _core_utils.getInheritableProperty)({
70
+ dict: dict,
71
+ key: 'baz',
72
+ getArray: true
73
+ })).toEqual(['qux', 'quux']);
74
+ });
75
+ it('fetches the property if it is inherited and present on one level', function () {
76
+ var ref = _primitives.Ref.get(10, 0);
77
+
78
+ var xref = new _test_utils.XRefMock([{
79
+ ref: ref,
80
+ data: 'quux'
81
+ }]);
82
+ var firstDict = new _primitives.Dict(xref);
83
+ var secondDict = new _primitives.Dict(xref);
84
+ firstDict.set('Parent', secondDict);
85
+ secondDict.set('foo', 'bar');
86
+ expect((0, _core_utils.getInheritableProperty)({
87
+ dict: firstDict,
88
+ key: 'foo'
89
+ })).toEqual('bar');
90
+ secondDict.set('baz', ['qux', ref]);
91
+ expect((0, _core_utils.getInheritableProperty)({
92
+ dict: firstDict,
93
+ key: 'baz',
94
+ getArray: true
95
+ })).toEqual(['qux', 'quux']);
96
+ });
97
+ it('fetches the property if it is inherited and present on multiple levels', function () {
98
+ var ref = _primitives.Ref.get(10, 0);
99
+
100
+ var xref = new _test_utils.XRefMock([{
101
+ ref: ref,
102
+ data: 'quux'
103
+ }]);
104
+ var firstDict = new _primitives.Dict(xref);
105
+ var secondDict = new _primitives.Dict(xref);
106
+ firstDict.set('Parent', secondDict);
107
+ firstDict.set('foo', 'bar1');
108
+ secondDict.set('foo', 'bar2');
109
+ expect((0, _core_utils.getInheritableProperty)({
110
+ dict: firstDict,
111
+ key: 'foo'
112
+ })).toEqual('bar1');
113
+ expect((0, _core_utils.getInheritableProperty)({
114
+ dict: firstDict,
115
+ key: 'foo',
116
+ getArray: false,
117
+ stopWhenFound: false
118
+ })).toEqual(['bar1', 'bar2']);
119
+ firstDict.set('baz', ['qux1', ref]);
120
+ secondDict.set('baz', ['qux2', ref]);
121
+ expect((0, _core_utils.getInheritableProperty)({
122
+ dict: firstDict,
123
+ key: 'baz',
124
+ getArray: true,
125
+ stopWhenFound: false
126
+ })).toEqual([['qux1', 'quux'], ['qux2', 'quux']]);
127
+ });
128
+ it('stops searching when the loop limit is reached', function () {
129
+ var dict = new _primitives.Dict();
130
+ var currentDict = dict;
131
+ var parentDict = null;
132
+
133
+ for (var i = 0; i < 150; i++) {
134
+ parentDict = new _primitives.Dict();
135
+ currentDict.set('Parent', parentDict);
136
+ currentDict = parentDict;
137
+ }
138
+
139
+ parentDict.set('foo', 'bar');
140
+ expect((0, _core_utils.getInheritableProperty)({
141
+ dict: dict,
142
+ key: 'foo'
143
+ })).toEqual(undefined);
144
+ dict.set('foo', 'baz');
145
+ expect((0, _core_utils.getInheritableProperty)({
146
+ dict: dict,
147
+ key: 'foo',
148
+ getArray: false,
149
+ stopWhenFound: false
150
+ })).toEqual(['baz']);
151
+ });
152
+ });
153
+ describe('toRomanNumerals', function () {
154
+ it('handles invalid arguments', function () {
155
+ var _loop = function _loop() {
156
+ var input = _arr[_i];
157
+ expect(function () {
158
+ (0, _core_utils.toRomanNumerals)(input);
159
+ }).toThrow(new Error('The number should be a positive integer.'));
160
+ };
161
+
162
+ for (var _i = 0, _arr = ['foo', -1, 0]; _i < _arr.length; _i++) {
163
+ _loop();
164
+ }
165
+ });
166
+ it('converts numbers to uppercase Roman numerals', function () {
167
+ expect((0, _core_utils.toRomanNumerals)(1)).toEqual('I');
168
+ expect((0, _core_utils.toRomanNumerals)(6)).toEqual('VI');
169
+ expect((0, _core_utils.toRomanNumerals)(7)).toEqual('VII');
170
+ expect((0, _core_utils.toRomanNumerals)(8)).toEqual('VIII');
171
+ expect((0, _core_utils.toRomanNumerals)(10)).toEqual('X');
172
+ expect((0, _core_utils.toRomanNumerals)(40)).toEqual('XL');
173
+ expect((0, _core_utils.toRomanNumerals)(100)).toEqual('C');
174
+ expect((0, _core_utils.toRomanNumerals)(500)).toEqual('D');
175
+ expect((0, _core_utils.toRomanNumerals)(1000)).toEqual('M');
176
+ expect((0, _core_utils.toRomanNumerals)(2019)).toEqual('MMXIX');
177
+ });
178
+ it('converts numbers to lowercase Roman numerals', function () {
179
+ expect((0, _core_utils.toRomanNumerals)(1, true)).toEqual('i');
180
+ expect((0, _core_utils.toRomanNumerals)(6, true)).toEqual('vi');
181
+ expect((0, _core_utils.toRomanNumerals)(7, true)).toEqual('vii');
182
+ expect((0, _core_utils.toRomanNumerals)(8, true)).toEqual('viii');
183
+ expect((0, _core_utils.toRomanNumerals)(10, true)).toEqual('x');
184
+ expect((0, _core_utils.toRomanNumerals)(40, true)).toEqual('xl');
185
+ expect((0, _core_utils.toRomanNumerals)(100, true)).toEqual('c');
186
+ expect((0, _core_utils.toRomanNumerals)(500, true)).toEqual('d');
187
+ expect((0, _core_utils.toRomanNumerals)(1000, true)).toEqual('m');
188
+ expect((0, _core_utils.toRomanNumerals)(2019, true)).toEqual('mmxix');
189
+ });
190
+ });
191
+ });
@@ -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.
@@ -23,13 +23,13 @@
23
23
 
24
24
  var _test_utils = require("./test_utils");
25
25
 
26
- var _dom_utils = require("../../display/dom_utils");
26
+ var _display_utils = require("../../display/display_utils");
27
27
 
28
28
  var _api = require("../../display/api");
29
29
 
30
30
  var _is_node = _interopRequireDefault(require("../../shared/is_node"));
31
31
 
32
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
33
33
 
34
34
  function getTopLeftPixel(canvasContext) {
35
35
  var imgData = canvasContext.getImageData(0, 0, 1, 1);
@@ -47,10 +47,10 @@ describe('custom canvas rendering', function () {
47
47
  var loadingTask;
48
48
  var page;
49
49
  beforeAll(function (done) {
50
- if ((0, _is_node.default)()) {
50
+ if ((0, _is_node["default"])()) {
51
51
  CanvasFactory = new _test_utils.NodeCanvasFactory();
52
52
  } else {
53
- CanvasFactory = new _dom_utils.DOMCanvasFactory();
53
+ CanvasFactory = new _display_utils.DOMCanvasFactory();
54
54
  }
55
55
 
56
56
  loadingTask = (0, _api.getDocument)(transparentGetDocumentParams);
@@ -59,7 +59,7 @@ describe('custom canvas rendering', function () {
59
59
  }).then(function (data) {
60
60
  page = data;
61
61
  done();
62
- }).catch(done.fail);
62
+ })["catch"](done.fail);
63
63
  });
64
64
  afterAll(function (done) {
65
65
  CanvasFactory = null;
@@ -84,7 +84,7 @@ describe('custom canvas rendering', function () {
84
84
  });
85
85
  CanvasFactory.destroy(canvasAndCtx);
86
86
  done();
87
- }).catch(done.fail);
87
+ })["catch"](done.fail);
88
88
  });
89
89
  it('renders to canvas with a custom background', function (done) {
90
90
  var viewport = page.getViewport({
@@ -105,6 +105,6 @@ describe('custom canvas rendering', function () {
105
105
  });
106
106
  CanvasFactory.destroy(canvasAndCtx);
107
107
  done();
108
- }).catch(done.fail);
108
+ })["catch"](done.fail);
109
109
  });
110
110
  });
@@ -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.
@@ -33,20 +33,20 @@ var _util = require("../../shared/util");
33
33
 
34
34
  var _svg = require("../../display/svg");
35
35
 
36
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
37
37
 
38
38
  var XLINK_NS = 'http://www.w3.org/1999/xlink';
39
39
 
40
40
  function withZlib(isZlibRequired, callback) {
41
41
  if (isZlibRequired) {
42
- if (!(0, _is_node.default)()) {
42
+ if (!(0, _is_node["default"])()) {
43
43
  throw new Error('zlib test can only be run in Node.js');
44
44
  }
45
45
 
46
46
  return callback();
47
47
  }
48
48
 
49
- if (!(0, _is_node.default)()) {
49
+ if (!(0, _is_node["default"])()) {
50
50
  return callback();
51
51
  }
52
52
 
@@ -103,7 +103,7 @@ describe('SVGGraphics', function () {
103
103
  };
104
104
  var xobjectObjId = 'img_p0_1';
105
105
 
106
- if ((0, _is_node.default)()) {
106
+ if ((0, _is_node["default"])()) {
107
107
  (0, _domstubs.setStubs)(global);
108
108
  }
109
109
 
@@ -111,7 +111,7 @@ describe('SVGGraphics', function () {
111
111
  var imgData = svgGfx.objs.get(xobjectObjId);
112
112
  svgGfx.paintInlineImageXObject(imgData, elementContainer);
113
113
  } finally {
114
- if ((0, _is_node.default)()) {
114
+ if ((0, _is_node["default"])()) {
115
115
  (0, _domstubs.unsetStubs)(global);
116
116
  }
117
117
  }
@@ -127,14 +127,14 @@ describe('SVGGraphics', function () {
127
127
 
128
128
  expect(testFunc.toString()).toMatch(/\srequire\(["']zlib["']\)/);
129
129
 
130
- if ((0, _is_node.default)()) {
130
+ if ((0, _is_node["default"])()) {
131
131
  expect(testFunc).not.toThrow();
132
132
  } else {
133
133
  expect(testFunc).toThrow();
134
134
  }
135
135
  });
136
136
  it('should produce a reasonably small svg:image', function (done) {
137
- if (!(0, _is_node.default)()) {
137
+ if (!(0, _is_node["default"])()) {
138
138
  pending('zlib.deflateSync is not supported in non-Node environments.');
139
139
  }
140
140