pdfjs-dist 2.6.347 → 2.7.570

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 (158) hide show
  1. package/README.md +3 -3
  2. package/bower.json +1 -1
  3. package/build/pdf.js +2050 -1087
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +1 -1
  6. package/build/pdf.worker.js +18219 -10436
  7. package/build/pdf.worker.js.map +1 -1
  8. package/build/pdf.worker.min.js +1 -1
  9. package/es5/build/pdf.d.ts +1 -0
  10. package/es5/build/pdf.js +6623 -6654
  11. package/es5/build/pdf.js.map +1 -1
  12. package/es5/build/pdf.min.js +1 -1
  13. package/es5/build/pdf.worker.js +20815 -13888
  14. package/es5/build/pdf.worker.js.map +1 -1
  15. package/es5/build/pdf.worker.min.js +1 -1
  16. package/es5/image_decoders/pdf.image_decoders.js +3817 -4946
  17. package/es5/image_decoders/pdf.image_decoders.js.map +1 -1
  18. package/es5/image_decoders/pdf.image_decoders.min.js +1 -1
  19. package/es5/web/pdf_viewer.css +18 -15
  20. package/es5/web/pdf_viewer.js +1094 -514
  21. package/es5/web/pdf_viewer.js.map +1 -1
  22. package/image_decoders/pdf.image_decoders.js +774 -168
  23. package/image_decoders/pdf.image_decoders.js.map +1 -1
  24. package/image_decoders/pdf.image_decoders.min.js +1 -1
  25. package/lib/core/annotation.js +556 -108
  26. package/lib/core/cff_parser.js +7 -1
  27. package/lib/core/charsets.js +1 -1
  28. package/lib/core/cmap.js +20 -1
  29. package/lib/core/core_utils.js +162 -3
  30. package/lib/core/crypto.js +1 -1
  31. package/lib/core/default_appearance.js +132 -0
  32. package/lib/core/document.js +115 -9
  33. package/lib/core/encodings.js +1 -1
  34. package/lib/core/evaluator.js +168 -74
  35. package/lib/core/fonts.js +97 -11
  36. package/lib/core/function.js +5 -10
  37. package/lib/core/glyphlist.js +11 -4529
  38. package/lib/core/image_utils.js +30 -1
  39. package/lib/core/jpg.js +1 -1
  40. package/lib/core/jpx.js +5 -5
  41. package/lib/core/murmurhash3.js +1 -1
  42. package/lib/core/obj.js +123 -39
  43. package/lib/core/pattern.js +4 -4
  44. package/lib/core/primitives.js +24 -5
  45. package/lib/core/standard_fonts.js +1 -1
  46. package/lib/core/stream.js +5 -1
  47. package/lib/core/unicode.js +15 -1387
  48. package/lib/core/worker.js +58 -17
  49. package/lib/core/writer.js +68 -4
  50. package/lib/display/annotation_layer.js +712 -119
  51. package/lib/display/annotation_storage.js +21 -4
  52. package/lib/display/api.js +88 -18
  53. package/lib/display/canvas.js +414 -375
  54. package/lib/display/display_utils.js +11 -4
  55. package/lib/display/fetch_stream.js +3 -3
  56. package/lib/display/font_loader.js +2 -3
  57. package/lib/display/metadata.js +54 -20
  58. package/lib/display/node_stream.js +1 -1
  59. package/lib/display/optional_content_config.js +1 -1
  60. package/lib/display/pattern_helper.js +109 -113
  61. package/lib/display/svg.js +5 -5
  62. package/lib/display/text_layer.js +54 -54
  63. package/lib/display/transport_stream.js +4 -4
  64. package/lib/display/webgl.js +65 -68
  65. package/lib/examples/node/domstubs.js +9 -4
  66. package/lib/pdf.js +2 -2
  67. package/lib/pdf.sandbox.js +311 -0
  68. package/lib/pdf.worker.js +2 -2
  69. package/lib/shared/scripting_utils.js +84 -0
  70. package/lib/shared/util.js +129 -14
  71. package/lib/{display → shared}/xml_parser.js +112 -4
  72. package/lib/test/unit/annotation_spec.js +831 -109
  73. package/lib/test/unit/annotation_storage_spec.js +28 -10
  74. package/lib/test/unit/api_spec.js +190 -160
  75. package/lib/test/unit/bidi_spec.js +6 -6
  76. package/lib/test/unit/cff_parser_spec.js +73 -73
  77. package/lib/test/unit/clitests_helper.js +2 -0
  78. package/lib/test/unit/cmap_spec.js +48 -74
  79. package/lib/test/unit/core_utils_spec.js +34 -0
  80. package/lib/test/unit/crypto_spec.js +162 -199
  81. package/lib/test/unit/custom_spec.js +7 -18
  82. package/lib/test/unit/default_appearance_spec.js +54 -0
  83. package/lib/test/unit/display_svg_spec.js +24 -19
  84. package/lib/test/unit/display_utils_spec.js +1 -1
  85. package/lib/test/unit/document_spec.js +187 -20
  86. package/lib/test/unit/evaluator_spec.js +30 -30
  87. package/lib/test/unit/function_spec.js +165 -165
  88. package/lib/test/unit/jasmine-boot.js +52 -53
  89. package/lib/test/unit/metadata_spec.js +2 -2
  90. package/lib/test/unit/murmurhash3_spec.js +29 -16
  91. package/lib/test/unit/network_spec.js +21 -21
  92. package/lib/test/unit/pdf_find_controller_spec.js +131 -69
  93. package/lib/test/unit/pdf_find_utils_spec.js +10 -10
  94. package/lib/test/unit/scripting_spec.js +1104 -0
  95. package/lib/test/unit/stream_spec.js +8 -8
  96. package/lib/test/unit/test_utils.js +16 -19
  97. package/lib/test/unit/testreporter.js +11 -4
  98. package/lib/test/unit/type1_parser_spec.js +23 -23
  99. package/lib/test/unit/ui_utils_spec.js +78 -35
  100. package/lib/test/unit/unicode_spec.js +7 -7
  101. package/lib/test/unit/util_spec.js +26 -3
  102. package/lib/test/unit/writer_spec.js +16 -1
  103. package/lib/test/unit/xml_spec.js +117 -0
  104. package/lib/web/annotation_layer_builder.js +18 -6
  105. package/lib/web/app.js +579 -161
  106. package/lib/web/app_options.js +14 -0
  107. package/lib/web/base_tree_viewer.js +50 -0
  108. package/lib/web/base_viewer.js +350 -14
  109. package/lib/web/chromecom.js +9 -1
  110. package/lib/web/debugger.js +1 -2
  111. package/lib/web/download_manager.js +0 -15
  112. package/lib/web/firefox_print_service.js +6 -4
  113. package/lib/web/firefoxcom.js +84 -69
  114. package/lib/web/generic_scripting.js +55 -0
  115. package/lib/web/genericcom.js +9 -1
  116. package/lib/web/grab_to_pan.js +1 -1
  117. package/lib/web/interfaces.js +9 -3
  118. package/lib/web/pdf_attachment_viewer.js +1 -3
  119. package/lib/web/pdf_cursor_tools.js +20 -13
  120. package/lib/web/pdf_document_properties.js +48 -61
  121. package/lib/web/pdf_find_bar.js +1 -3
  122. package/lib/web/pdf_find_controller.js +58 -12
  123. package/lib/web/pdf_history.js +43 -21
  124. package/lib/web/pdf_layer_viewer.js +1 -9
  125. package/lib/web/pdf_link_service.js +108 -78
  126. package/lib/web/pdf_outline_viewer.js +166 -10
  127. package/lib/web/pdf_page_view.js +14 -14
  128. package/lib/web/pdf_presentation_mode.js +21 -31
  129. package/lib/web/pdf_rendering_queue.js +8 -1
  130. package/lib/web/pdf_sidebar.js +62 -107
  131. package/lib/web/pdf_sidebar_resizer.js +11 -21
  132. package/lib/web/pdf_single_page_viewer.js +8 -0
  133. package/lib/web/pdf_thumbnail_view.js +26 -26
  134. package/lib/web/pdf_thumbnail_viewer.js +13 -2
  135. package/lib/web/pdf_viewer.component.js +2 -2
  136. package/lib/web/pdf_viewer.js +3 -1
  137. package/lib/web/preferences.js +33 -44
  138. package/lib/web/text_layer_builder.js +2 -9
  139. package/lib/web/ui_utils.js +78 -46
  140. package/lib/web/viewer_compatibility.js +1 -2
  141. package/package.json +4 -1
  142. package/types/display/annotation_layer.d.ts +18 -3
  143. package/types/display/api.d.ts +110 -54
  144. package/types/display/canvas.d.ts +1 -1
  145. package/types/display/display_utils.d.ts +96 -95
  146. package/types/display/fetch_stream.d.ts +2 -2
  147. package/types/display/metadata.d.ts +4 -0
  148. package/types/display/pattern_helper.d.ts +1 -1
  149. package/types/display/text_layer.d.ts +7 -7
  150. package/types/display/transport_stream.d.ts +1 -1
  151. package/types/shared/scripting_utils.d.ts +12 -0
  152. package/types/shared/util.d.ts +281 -250
  153. package/types/shared/xml_parser.d.ts +64 -0
  154. package/web/pdf_viewer.css +18 -15
  155. package/web/pdf_viewer.js +809 -408
  156. package/web/pdf_viewer.js.map +1 -1
  157. package/webpack.js +1 -1
  158. package/types/display/xml_parser.d.ts +0 -35
@@ -25,10 +25,10 @@ var _test_utils = require("./test_utils.js");
25
25
 
26
26
  var _util = require("../../shared/util.js");
27
27
 
28
- var _display_utils = require("../../display/display_utils.js");
29
-
30
28
  var _api = require("../../display/api.js");
31
29
 
30
+ var _display_utils = require("../../display/display_utils.js");
31
+
32
32
  var _ui_utils = require("../../web/ui_utils.js");
33
33
 
34
34
  var _image_utils = require("../../core/image_utils.js");
@@ -39,20 +39,13 @@ var _is_node = require("../../shared/is_node.js");
39
39
 
40
40
  var _metadata = require("../../display/metadata.js");
41
41
 
42
- var _node_utils = require("../../display/node_utils.js");
43
-
44
42
  describe("api", function () {
45
43
  const basicApiFileName = "basicapi.pdf";
46
44
  const basicApiFileLength = 105779;
47
45
  const basicApiGetDocumentParams = (0, _test_utils.buildGetDocumentParams)(basicApiFileName);
48
46
  let CanvasFactory;
49
47
  beforeAll(function (done) {
50
- if (_is_node.isNodeJS) {
51
- CanvasFactory = new _node_utils.NodeCanvasFactory();
52
- } else {
53
- CanvasFactory = new _display_utils.DOMCanvasFactory();
54
- }
55
-
48
+ CanvasFactory = new _api.DefaultCanvasFactory();
56
49
  done();
57
50
  });
58
51
  afterAll(function (done) {
@@ -61,7 +54,7 @@ describe("api", function () {
61
54
  });
62
55
 
63
56
  function waitSome(callback) {
64
- var WAIT_TIMEOUT = 10;
57
+ const WAIT_TIMEOUT = 10;
65
58
  setTimeout(function () {
66
59
  callback();
67
60
  }, WAIT_TIMEOUT);
@@ -69,8 +62,8 @@ describe("api", function () {
69
62
 
70
63
  describe("getDocument", function () {
71
64
  it("creates pdf doc from URL", function (done) {
72
- var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
73
- var progressReportedCapability = (0, _util.createPromiseCapability)();
65
+ const loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
66
+ const progressReportedCapability = (0, _util.createPromiseCapability)();
74
67
 
75
68
  loadingTask.onProgress = function (progressData) {
76
69
  if (!progressReportedCapability.settled) {
@@ -78,7 +71,7 @@ describe("api", function () {
78
71
  }
79
72
  };
80
73
 
81
- var promises = [progressReportedCapability.promise, loadingTask.promise];
74
+ const promises = [progressReportedCapability.promise, loadingTask.promise];
82
75
  Promise.all(promises).then(function (data) {
83
76
  expect(data[0].loaded / data[0].total >= 0).toEqual(true);
84
77
  expect(data[1] instanceof _api.PDFDocumentProxy).toEqual(true);
@@ -87,7 +80,7 @@ describe("api", function () {
87
80
  }).catch(done.fail);
88
81
  });
89
82
  it("creates pdf doc from URL and aborts before worker initialized", function (done) {
90
- var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
83
+ const loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
91
84
  const destroyed = loadingTask.destroy();
92
85
  loadingTask.promise.then(function (reason) {
93
86
  done.fail("shall fail loading");
@@ -97,9 +90,9 @@ describe("api", function () {
97
90
  });
98
91
  });
99
92
  it("creates pdf doc from URL and aborts loading after worker initialized", function (done) {
100
- var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
93
+ const loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
101
94
 
102
- var destroyed = loadingTask._worker.promise.then(function () {
95
+ const destroyed = loadingTask._worker.promise.then(function () {
103
96
  return loadingTask.destroy();
104
97
  });
105
98
 
@@ -109,17 +102,9 @@ describe("api", function () {
109
102
  }).catch(done.fail);
110
103
  });
111
104
  it("creates pdf doc from typed array", function (done) {
112
- let typedArrayPdfPromise;
113
-
114
- if (_is_node.isNodeJS) {
115
- typedArrayPdfPromise = _test_utils.NodeFileReaderFactory.fetch({
116
- path: _test_utils.TEST_PDFS_PATH.node + basicApiFileName
117
- });
118
- } else {
119
- typedArrayPdfPromise = _test_utils.DOMFileReaderFactory.fetch({
120
- path: _test_utils.TEST_PDFS_PATH.dom + basicApiFileName
121
- });
122
- }
105
+ const typedArrayPdfPromise = _test_utils.DefaultFileReaderFactory.fetch({
106
+ path: _test_utils.TEST_PDFS_PATH + basicApiFileName
107
+ });
123
108
 
124
109
  typedArrayPdfPromise.then(typedArrayPdf => {
125
110
  expect(typedArrayPdf.length).toEqual(basicApiFileLength);
@@ -138,7 +123,7 @@ describe("api", function () {
138
123
  }).catch(done.fail);
139
124
  });
140
125
  it("creates pdf doc from invalid PDF file", function (done) {
141
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("bug1020226.pdf"));
126
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("bug1020226.pdf"));
142
127
  loadingTask.promise.then(function () {
143
128
  done.fail("shall fail loading");
144
129
  }).catch(function (reason) {
@@ -148,7 +133,7 @@ describe("api", function () {
148
133
  });
149
134
  });
150
135
  it("creates pdf doc from non-existent URL", function (done) {
151
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("non-existent.pdf"));
136
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("non-existent.pdf"));
152
137
  loadingTask.promise.then(function (error) {
153
138
  done.fail("shall fail loading");
154
139
  }).catch(function (error) {
@@ -157,9 +142,9 @@ describe("api", function () {
157
142
  });
158
143
  });
159
144
  it("creates pdf doc from PDF file protected with user and owner password", function (done) {
160
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("pr6531_1.pdf"));
161
- var passwordNeededCapability = (0, _util.createPromiseCapability)();
162
- var passwordIncorrectCapability = (0, _util.createPromiseCapability)();
145
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("pr6531_1.pdf"));
146
+ const passwordNeededCapability = (0, _util.createPromiseCapability)();
147
+ const passwordIncorrectCapability = (0, _util.createPromiseCapability)();
163
148
 
164
149
  loadingTask.onPassword = function (updatePassword, reason) {
165
150
  if (reason === _util.PasswordResponses.NEED_PASSWORD && !passwordNeededCapability.settled) {
@@ -177,18 +162,18 @@ describe("api", function () {
177
162
  expect(false).toEqual(true);
178
163
  };
179
164
 
180
- var promises = [passwordNeededCapability.promise, passwordIncorrectCapability.promise, loadingTask.promise];
165
+ const promises = [passwordNeededCapability.promise, passwordIncorrectCapability.promise, loadingTask.promise];
181
166
  Promise.all(promises).then(function (data) {
182
167
  expect(data[2] instanceof _api.PDFDocumentProxy).toEqual(true);
183
168
  loadingTask.destroy().then(done);
184
169
  }).catch(done.fail);
185
170
  });
186
171
  it("creates pdf doc from PDF file protected with only a user password", function (done) {
187
- var filename = "pr6531_2.pdf";
188
- var passwordNeededLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename, {
172
+ const filename = "pr6531_2.pdf";
173
+ const passwordNeededLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename, {
189
174
  password: ""
190
175
  }));
191
- var result1 = passwordNeededLoadingTask.promise.then(function () {
176
+ const result1 = passwordNeededLoadingTask.promise.then(function () {
192
177
  done.fail("shall fail with no password");
193
178
  return Promise.reject(new Error("loadingTask should be rejected"));
194
179
  }, function (data) {
@@ -196,10 +181,10 @@ describe("api", function () {
196
181
  expect(data.code).toEqual(_util.PasswordResponses.NEED_PASSWORD);
197
182
  return passwordNeededLoadingTask.destroy();
198
183
  });
199
- var passwordIncorrectLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename, {
184
+ const passwordIncorrectLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename, {
200
185
  password: "qwerty"
201
186
  }));
202
- var result2 = passwordIncorrectLoadingTask.promise.then(function () {
187
+ const result2 = passwordIncorrectLoadingTask.promise.then(function () {
203
188
  done.fail("shall fail with wrong password");
204
189
  return Promise.reject(new Error("loadingTask should be rejected"));
205
190
  }, function (data) {
@@ -207,10 +192,10 @@ describe("api", function () {
207
192
  expect(data.code).toEqual(_util.PasswordResponses.INCORRECT_PASSWORD);
208
193
  return passwordIncorrectLoadingTask.destroy();
209
194
  });
210
- var passwordAcceptedLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename, {
195
+ const passwordAcceptedLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename, {
211
196
  password: "asdfasdf"
212
197
  }));
213
- var result3 = passwordAcceptedLoadingTask.promise.then(function (data) {
198
+ const result3 = passwordAcceptedLoadingTask.promise.then(function (data) {
214
199
  expect(data instanceof _api.PDFDocumentProxy).toEqual(true);
215
200
  return passwordAcceptedLoadingTask.destroy();
216
201
  });
@@ -219,9 +204,9 @@ describe("api", function () {
219
204
  }).catch(done.fail);
220
205
  });
221
206
  it("creates pdf doc from password protected PDF file and aborts/throws " + "in the onPassword callback (issue 7806)", function (done) {
222
- var filename = "issue3371.pdf";
223
- var passwordNeededLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename));
224
- var passwordIncorrectLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename, {
207
+ const filename = "issue3371.pdf";
208
+ const passwordNeededLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename));
209
+ const passwordIncorrectLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename, {
225
210
  password: "qwerty"
226
211
  }));
227
212
  let passwordNeededDestroyed;
@@ -235,7 +220,7 @@ describe("api", function () {
235
220
  expect(false).toEqual(true);
236
221
  };
237
222
 
238
- var result1 = passwordNeededLoadingTask.promise.then(function () {
223
+ const result1 = passwordNeededLoadingTask.promise.then(function () {
239
224
  done.fail("shall fail since the loadingTask should be destroyed");
240
225
  return Promise.reject(new Error("loadingTask should be rejected"));
241
226
  }, function (reason) {
@@ -252,7 +237,7 @@ describe("api", function () {
252
237
  expect(false).toEqual(true);
253
238
  };
254
239
 
255
- var result2 = passwordIncorrectLoadingTask.promise.then(function () {
240
+ const result2 = passwordIncorrectLoadingTask.promise.then(function () {
256
241
  done.fail("shall fail since the onPassword callback should throw");
257
242
  return Promise.reject(new Error("loadingTask should be rejected"));
258
243
  }, function (reason) {
@@ -281,7 +266,7 @@ describe("api", function () {
281
266
  pending("Worker is not supported in Node.js.");
282
267
  }
283
268
 
284
- var worker = new _api.PDFWorker({
269
+ const worker = new _api.PDFWorker({
285
270
  name: "test1"
286
271
  });
287
272
  worker.promise.then(function () {
@@ -301,17 +286,17 @@ describe("api", function () {
301
286
  pending("Worker is not supported in Node.js.");
302
287
  }
303
288
 
304
- var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
305
- var worker;
289
+ const loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
290
+ let worker;
306
291
  loadingTask.promise.then(function () {
307
292
  worker = loadingTask._worker;
308
293
  expect(!!worker).toEqual(true);
309
294
  });
310
- var destroyPromise = loadingTask.promise.then(function () {
295
+ const destroyPromise = loadingTask.promise.then(function () {
311
296
  return loadingTask.destroy();
312
297
  });
313
298
  destroyPromise.then(function () {
314
- var destroyedWorker = loadingTask._worker;
299
+ const destroyedWorker = loadingTask._worker;
315
300
  expect(!!destroyedWorker).toEqual(false);
316
301
  expect(worker.destroyed).toEqual(true);
317
302
  done();
@@ -322,19 +307,19 @@ describe("api", function () {
322
307
  pending("Worker is not supported in Node.js.");
323
308
  }
324
309
 
325
- var worker = new _api.PDFWorker({
310
+ const worker = new _api.PDFWorker({
326
311
  name: "test1"
327
312
  });
328
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(basicApiFileName, {
313
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(basicApiFileName, {
329
314
  worker
330
315
  }));
331
316
  loadingTask.promise.then(function () {
332
- var docWorker = loadingTask._worker;
317
+ const docWorker = loadingTask._worker;
333
318
  expect(!!docWorker).toEqual(false);
334
- var messageHandlerPort = loadingTask._transport.messageHandler.comObj;
319
+ const messageHandlerPort = loadingTask._transport.messageHandler.comObj;
335
320
  expect(messageHandlerPort === worker.port).toEqual(true);
336
321
  });
337
- var destroyPromise = loadingTask.promise.then(function () {
322
+ const destroyPromise = loadingTask.promise.then(function () {
338
323
  return loadingTask.destroy();
339
324
  });
340
325
  destroyPromise.then(function () {
@@ -348,16 +333,16 @@ describe("api", function () {
348
333
  pending("Worker is not supported in Node.js.");
349
334
  }
350
335
 
351
- var worker1 = new _api.PDFWorker({
336
+ const worker1 = new _api.PDFWorker({
352
337
  name: "test1"
353
338
  });
354
- var worker2 = new _api.PDFWorker({
339
+ const worker2 = new _api.PDFWorker({
355
340
  name: "test2"
356
341
  });
357
- var worker3 = new _api.PDFWorker({
342
+ const worker3 = new _api.PDFWorker({
358
343
  name: "test3"
359
344
  });
360
- var ready = Promise.all([worker1.promise, worker2.promise, worker3.promise]);
345
+ const ready = Promise.all([worker1.promise, worker2.promise, worker3.promise]);
361
346
  ready.then(function () {
362
347
  expect(worker1.port !== worker2.port && worker1.port !== worker3.port && worker2.port !== worker3.port).toEqual(true);
363
348
  worker1.destroy();
@@ -396,7 +381,7 @@ describe("api", function () {
396
381
  expect(pdfDocument.fingerprint).toEqual("ea8b35919d6279a369e835bde778611b");
397
382
  });
398
383
  it("gets page", function (done) {
399
- var promise = pdfDocument.getPage(1);
384
+ const promise = pdfDocument.getPage(1);
400
385
  promise.then(function (data) {
401
386
  expect(data instanceof _api.PDFPageProxy).toEqual(true);
402
387
  expect(data.pageNumber).toEqual(1);
@@ -404,9 +389,9 @@ describe("api", function () {
404
389
  }).catch(done.fail);
405
390
  });
406
391
  it("gets non-existent page", function (done) {
407
- var outOfRangePromise = pdfDocument.getPage(100);
408
- var nonIntegerPromise = pdfDocument.getPage(2.5);
409
- var nonNumberPromise = pdfDocument.getPage("1");
392
+ let outOfRangePromise = pdfDocument.getPage(100);
393
+ let nonIntegerPromise = pdfDocument.getPage(2.5);
394
+ let nonNumberPromise = pdfDocument.getPage("1");
410
395
  outOfRangePromise = outOfRangePromise.then(function () {
411
396
  throw new Error("shall fail for out-of-range pageNumber parameter");
412
397
  }, function (reason) {
@@ -452,22 +437,22 @@ describe("api", function () {
452
437
  }, done.fail);
453
438
  });
454
439
  it("gets page index", function (done) {
455
- var ref = {
440
+ const ref = {
456
441
  num: 17,
457
442
  gen: 0
458
443
  };
459
- var promise = pdfDocument.getPageIndex(ref);
444
+ const promise = pdfDocument.getPageIndex(ref);
460
445
  promise.then(function (pageIndex) {
461
446
  expect(pageIndex).toEqual(1);
462
447
  done();
463
448
  }).catch(done.fail);
464
449
  });
465
450
  it("gets invalid page index", function (done) {
466
- var ref = {
451
+ const ref = {
467
452
  num: 3,
468
453
  gen: 0
469
454
  };
470
- var promise = pdfDocument.getPageIndex(ref);
455
+ const promise = pdfDocument.getPageIndex(ref);
471
456
  promise.then(function () {
472
457
  done.fail("shall fail for invalid page reference.");
473
458
  }).catch(function (reason) {
@@ -476,7 +461,7 @@ describe("api", function () {
476
461
  });
477
462
  });
478
463
  it("gets destinations, from /Dests dictionary", function (done) {
479
- var promise = pdfDocument.getDestinations();
464
+ const promise = pdfDocument.getDestinations();
480
465
  promise.then(function (data) {
481
466
  expect(data).toEqual({
482
467
  chapter1: [{
@@ -490,7 +475,7 @@ describe("api", function () {
490
475
  }).catch(done.fail);
491
476
  });
492
477
  it("gets a destination, from /Dests dictionary", function (done) {
493
- var promise = pdfDocument.getDestination("chapter1");
478
+ const promise = pdfDocument.getDestination("chapter1");
494
479
  promise.then(function (data) {
495
480
  expect(data).toEqual([{
496
481
  gen: 0,
@@ -502,15 +487,15 @@ describe("api", function () {
502
487
  }).catch(done.fail);
503
488
  });
504
489
  it("gets a non-existent destination, from /Dests dictionary", function (done) {
505
- var promise = pdfDocument.getDestination("non-existent-named-destination");
490
+ const promise = pdfDocument.getDestination("non-existent-named-destination");
506
491
  promise.then(function (data) {
507
492
  expect(data).toEqual(null);
508
493
  done();
509
494
  }).catch(done.fail);
510
495
  });
511
496
  it("gets destinations, from /Names (NameTree) dictionary", function (done) {
512
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("issue6204.pdf"));
513
- var promise = loadingTask.promise.then(function (pdfDoc) {
497
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("issue6204.pdf"));
498
+ const promise = loadingTask.promise.then(function (pdfDoc) {
514
499
  return pdfDoc.getDestinations();
515
500
  });
516
501
  promise.then(function (destinations) {
@@ -532,8 +517,8 @@ describe("api", function () {
532
517
  }).catch(done.fail);
533
518
  });
534
519
  it("gets a destination, from /Names (NameTree) dictionary", function (done) {
535
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("issue6204.pdf"));
536
- var promise = loadingTask.promise.then(function (pdfDoc) {
520
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("issue6204.pdf"));
521
+ const promise = loadingTask.promise.then(function (pdfDoc) {
537
522
  return pdfDoc.getDestination("Page.1");
538
523
  });
539
524
  promise.then(function (destination) {
@@ -547,8 +532,8 @@ describe("api", function () {
547
532
  }).catch(done.fail);
548
533
  });
549
534
  it("gets a non-existent destination, from /Names (NameTree) dictionary", function (done) {
550
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("issue6204.pdf"));
551
- var promise = loadingTask.promise.then(function (pdfDoc) {
535
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("issue6204.pdf"));
536
+ const promise = loadingTask.promise.then(function (pdfDoc) {
552
537
  return pdfDoc.getDestination("non-existent-named-destination");
553
538
  });
554
539
  promise.then(function (destination) {
@@ -583,27 +568,27 @@ describe("api", function () {
583
568
  Promise.all([numberPromise, booleanPromise, arrayPromise]).then(done, done.fail);
584
569
  });
585
570
  it("gets non-existent page labels", function (done) {
586
- var promise = pdfDocument.getPageLabels();
571
+ const promise = pdfDocument.getPageLabels();
587
572
  promise.then(function (data) {
588
573
  expect(data).toEqual(null);
589
574
  done();
590
575
  }).catch(done.fail);
591
576
  });
592
577
  it("gets page labels", function (done) {
593
- var loadingTask0 = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("bug793632.pdf"));
594
- var promise0 = loadingTask0.promise.then(function (pdfDoc) {
578
+ const loadingTask0 = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("bug793632.pdf"));
579
+ const promise0 = loadingTask0.promise.then(function (pdfDoc) {
595
580
  return pdfDoc.getPageLabels();
596
581
  });
597
- var loadingTask1 = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("issue1453.pdf"));
598
- var promise1 = loadingTask1.promise.then(function (pdfDoc) {
582
+ const loadingTask1 = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("issue1453.pdf"));
583
+ const promise1 = loadingTask1.promise.then(function (pdfDoc) {
599
584
  return pdfDoc.getPageLabels();
600
585
  });
601
- var loadingTask2 = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("rotation.pdf"));
602
- var promise2 = loadingTask2.promise.then(function (pdfDoc) {
586
+ const loadingTask2 = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("rotation.pdf"));
587
+ const promise2 = loadingTask2.promise.then(function (pdfDoc) {
603
588
  return pdfDoc.getPageLabels();
604
589
  });
605
- var loadingTask3 = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("bad-PageLabels.pdf"));
606
- var promise3 = loadingTask3.promise.then(function (pdfDoc) {
590
+ const loadingTask3 = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("bad-PageLabels.pdf"));
591
+ const promise3 = loadingTask3.promise.then(function (pdfDoc) {
607
592
  return pdfDoc.getPageLabels();
608
593
  });
609
594
  Promise.all([promise0, promise1, promise2, promise3]).then(function (pageLabels) {
@@ -615,7 +600,7 @@ describe("api", function () {
615
600
  }).catch(done.fail);
616
601
  });
617
602
  it("gets default page layout", function (done) {
618
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf"));
603
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf"));
619
604
  loadingTask.promise.then(function (pdfDoc) {
620
605
  return pdfDoc.getPageLayout();
621
606
  }).then(function (mode) {
@@ -630,7 +615,7 @@ describe("api", function () {
630
615
  }).catch(done.fail);
631
616
  });
632
617
  it("gets default page mode", function (done) {
633
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf"));
618
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf"));
634
619
  loadingTask.promise.then(function (pdfDoc) {
635
620
  return pdfDoc.getPageMode();
636
621
  }).then(function (mode) {
@@ -645,7 +630,7 @@ describe("api", function () {
645
630
  }).catch(done.fail);
646
631
  });
647
632
  it("gets default viewer preferences", function (done) {
648
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf"));
633
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf"));
649
634
  loadingTask.promise.then(function (pdfDoc) {
650
635
  return pdfDoc.getViewerPreferences();
651
636
  }).then(function (prefs) {
@@ -662,7 +647,7 @@ describe("api", function () {
662
647
  }).catch(done.fail);
663
648
  });
664
649
  it("gets default open action", function (done) {
665
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf"));
650
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf"));
666
651
  loadingTask.promise.then(function (pdfDoc) {
667
652
  return pdfDoc.getOpenAction();
668
653
  }).then(function (openAction) {
@@ -702,34 +687,34 @@ describe("api", function () {
702
687
  Promise.all([promise1, promise2]).then(done, done.fail);
703
688
  });
704
689
  it("gets non-existent attachments", function (done) {
705
- var promise = pdfDocument.getAttachments();
690
+ const promise = pdfDocument.getAttachments();
706
691
  promise.then(function (data) {
707
692
  expect(data).toEqual(null);
708
693
  done();
709
694
  }).catch(done.fail);
710
695
  });
711
696
  it("gets attachments", function (done) {
712
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("attachment.pdf"));
713
- var promise = loadingTask.promise.then(function (pdfDoc) {
697
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("attachment.pdf"));
698
+ const promise = loadingTask.promise.then(function (pdfDoc) {
714
699
  return pdfDoc.getAttachments();
715
700
  });
716
701
  promise.then(function (data) {
717
- var attachment = data["foo.txt"];
702
+ const attachment = data["foo.txt"];
718
703
  expect(attachment.filename).toEqual("foo.txt");
719
704
  expect(attachment.content).toEqual(new Uint8Array([98, 97, 114, 32, 98, 97, 122, 32, 10]));
720
705
  loadingTask.destroy().then(done);
721
706
  }).catch(done.fail);
722
707
  });
723
708
  it("gets javascript", function (done) {
724
- var promise = pdfDocument.getJavaScript();
709
+ const promise = pdfDocument.getJavaScript();
725
710
  promise.then(function (data) {
726
711
  expect(data).toEqual(null);
727
712
  done();
728
713
  }).catch(done.fail);
729
714
  });
730
715
  it("gets javascript with printing instructions (JS action)", function (done) {
731
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("issue6106.pdf"));
732
- var promise = loadingTask.promise.then(function (pdfDoc) {
716
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("issue6106.pdf"));
717
+ const promise = loadingTask.promise.then(function (pdfDoc) {
733
718
  return pdfDoc.getJavaScript();
734
719
  });
735
720
  promise.then(function (data) {
@@ -738,9 +723,45 @@ describe("api", function () {
738
723
  loadingTask.destroy().then(done);
739
724
  }).catch(done.fail);
740
725
  });
726
+ it("gets JSActions (none)", function (done) {
727
+ const promise = pdfDocument.getJSActions();
728
+ promise.then(function (data) {
729
+ expect(data).toEqual(null);
730
+ done();
731
+ }).catch(done.fail);
732
+ });
733
+ it("gets JSActions", function (done) {
734
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("doc_actions.pdf"));
735
+ const promise = loadingTask.promise.then(async pdfDoc => {
736
+ const docActions = await pdfDoc.getJSActions();
737
+ const page1 = await pdfDoc.getPage(1);
738
+ const page3 = await pdfDoc.getPage(3);
739
+ const page1Actions = await page1.getJSActions();
740
+ const page3Actions = await page3.getJSActions();
741
+ return [docActions, page1Actions, page3Actions];
742
+ });
743
+ promise.then(async ([docActions, page1Actions, page3Actions]) => {
744
+ expect(docActions).toEqual({
745
+ DidPrint: [`this.getField("Text2").value = "DidPrint";`],
746
+ DidSave: [`this.getField("Text2").value = "DidSave";`],
747
+ WillClose: [`this.getField("Text1").value = "WillClose";`],
748
+ WillPrint: [`this.getField("Text1").value = "WillPrint";`],
749
+ WillSave: [`this.getField("Text1").value = "WillSave";`]
750
+ });
751
+ expect(page1Actions).toEqual({
752
+ PageOpen: [`this.getField("Text1").value = "PageOpen 1";`],
753
+ PageClose: [`this.getField("Text2").value = "PageClose 1";`]
754
+ });
755
+ expect(page3Actions).toEqual({
756
+ PageOpen: [`this.getField("Text5").value = "PageOpen 3";`],
757
+ PageClose: [`this.getField("Text6").value = "PageClose 3";`]
758
+ });
759
+ loadingTask.destroy().then(done);
760
+ }).catch(done.fail);
761
+ });
741
762
  it("gets non-existent outline", function (done) {
742
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf"));
743
- var promise = loadingTask.promise.then(function (pdfDoc) {
763
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf"));
764
+ const promise = loadingTask.promise.then(function (pdfDoc) {
744
765
  return pdfDoc.getOutline();
745
766
  });
746
767
  promise.then(function (outline) {
@@ -749,11 +770,11 @@ describe("api", function () {
749
770
  }).catch(done.fail);
750
771
  });
751
772
  it("gets outline", function (done) {
752
- var promise = pdfDocument.getOutline();
773
+ const promise = pdfDocument.getOutline();
753
774
  promise.then(function (outline) {
754
775
  expect(Array.isArray(outline)).toEqual(true);
755
776
  expect(outline.length).toEqual(2);
756
- var outlineItem = outline[1];
777
+ const outlineItem = outline[1];
757
778
  expect(outlineItem.title).toEqual("Chapter 1");
758
779
  expect(Array.isArray(outlineItem.dest)).toEqual(true);
759
780
  expect(outlineItem.url).toEqual(null);
@@ -768,18 +789,18 @@ describe("api", function () {
768
789
  }).catch(done.fail);
769
790
  });
770
791
  it("gets outline containing a url", function (done) {
771
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("issue3214.pdf"));
792
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("issue3214.pdf"));
772
793
  loadingTask.promise.then(function (pdfDoc) {
773
794
  pdfDoc.getOutline().then(function (outline) {
774
795
  expect(Array.isArray(outline)).toEqual(true);
775
796
  expect(outline.length).toEqual(5);
776
- var outlineItemTwo = outline[2];
797
+ const outlineItemTwo = outline[2];
777
798
  expect(typeof outlineItemTwo.title).toEqual("string");
778
799
  expect(outlineItemTwo.dest).toEqual(null);
779
800
  expect(outlineItemTwo.url).toEqual("http://google.com/");
780
801
  expect(outlineItemTwo.unsafeUrl).toEqual("http://google.com");
781
802
  expect(outlineItemTwo.newWindow).toBeUndefined();
782
- var outlineItemOne = outline[1];
803
+ const outlineItemOne = outline[1];
783
804
  expect(outlineItemOne.bold).toEqual(false);
784
805
  expect(outlineItemOne.italic).toEqual(true);
785
806
  expect(outlineItemOne.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
@@ -819,11 +840,12 @@ describe("api", function () {
819
840
  }).catch(done.fail);
820
841
  });
821
842
  it("gets metadata", function (done) {
822
- var promise = pdfDocument.getMetadata();
843
+ const promise = pdfDocument.getMetadata();
823
844
  promise.then(function ({
824
845
  info,
825
846
  metadata,
826
- contentDispositionFilename
847
+ contentDispositionFilename,
848
+ contentLength
827
849
  }) {
828
850
  expect(info.Title).toEqual("Basic API Test");
829
851
  expect(info.Custom).toEqual(undefined);
@@ -835,17 +857,19 @@ describe("api", function () {
835
857
  expect(metadata instanceof _metadata.Metadata).toEqual(true);
836
858
  expect(metadata.get("dc:title")).toEqual("Basic API Test");
837
859
  expect(contentDispositionFilename).toEqual(null);
860
+ expect(contentLength).toEqual(basicApiFileLength);
838
861
  done();
839
862
  }).catch(done.fail);
840
863
  });
841
864
  it("gets metadata, with custom info dict entries", function (done) {
842
- var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf"));
865
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf"));
843
866
  loadingTask.promise.then(function (pdfDoc) {
844
867
  return pdfDoc.getMetadata();
845
868
  }).then(function ({
846
869
  info,
847
870
  metadata,
848
- contentDispositionFilename
871
+ contentDispositionFilename,
872
+ contentLength
849
873
  }) {
850
874
  expect(info.Creator).toEqual("TeX");
851
875
  expect(info.Producer).toEqual("pdfeTeX-1.21a");
@@ -860,6 +884,7 @@ describe("api", function () {
860
884
  expect(info.IsCollectionPresent).toEqual(false);
861
885
  expect(metadata).toEqual(null);
862
886
  expect(contentDispositionFilename).toEqual(null);
887
+ expect(contentLength).toEqual(1016315);
863
888
  loadingTask.destroy().then(done);
864
889
  }).catch(done.fail);
865
890
  });
@@ -870,7 +895,8 @@ describe("api", function () {
870
895
  }).then(function ({
871
896
  info,
872
897
  metadata,
873
- contentDispositionFilename
898
+ contentDispositionFilename,
899
+ contentLength
874
900
  }) {
875
901
  expect(info.PDFFormatVersion).toEqual(null);
876
902
  expect(info.IsLinearized).toEqual(false);
@@ -879,11 +905,23 @@ describe("api", function () {
879
905
  expect(info.IsCollectionPresent).toEqual(false);
880
906
  expect(metadata).toEqual(null);
881
907
  expect(contentDispositionFilename).toEqual(null);
908
+ expect(contentLength).toEqual(624);
882
909
  loadingTask.destroy().then(done);
883
910
  }).catch(done.fail);
884
911
  });
912
+ it("gets markInfo", function (done) {
913
+ const loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("annotation-line.pdf"));
914
+ loadingTask.promise.then(function (pdfDoc) {
915
+ return pdfDoc.getMarkInfo();
916
+ }).then(function (info) {
917
+ expect(info.Marked).toEqual(true);
918
+ expect(info.UserProperties).toEqual(false);
919
+ expect(info.Suspects).toEqual(false);
920
+ done();
921
+ }).catch(done.fail);
922
+ });
885
923
  it("gets data", function (done) {
886
- var promise = pdfDocument.getData();
924
+ const promise = pdfDocument.getData();
887
925
  promise.then(function (data) {
888
926
  expect(data instanceof Uint8Array).toEqual(true);
889
927
  expect(data.length).toEqual(basicApiFileLength);
@@ -891,7 +929,7 @@ describe("api", function () {
891
929
  }).catch(done.fail);
892
930
  });
893
931
  it("gets download info", function (done) {
894
- var promise = pdfDocument.getDownloadInfo();
932
+ const promise = pdfDocument.getDownloadInfo();
895
933
  promise.then(function (data) {
896
934
  expect(data).toEqual({
897
935
  length: basicApiFileLength
@@ -900,7 +938,7 @@ describe("api", function () {
900
938
  }).catch(done.fail);
901
939
  });
902
940
  it("gets document stats", function (done) {
903
- var promise = pdfDocument.getStats();
941
+ const promise = pdfDocument.getStats();
904
942
  promise.then(function (stats) {
905
943
  expect(stats).toEqual({
906
944
  streamTypes: {},
@@ -929,15 +967,15 @@ describe("api", function () {
929
967
  }).catch(done.fail);
930
968
  });
931
969
  describe("Cross-origin", function () {
932
- var loadingTask;
970
+ let loadingTask;
933
971
 
934
972
  function _checkCanLoad(expectSuccess, filename, options) {
935
973
  if (_is_node.isNodeJS) {
936
974
  pending("Cannot simulate cross-origin requests in Node.js");
937
975
  }
938
976
 
939
- var params = (0, _test_utils.buildGetDocumentParams)(filename, options);
940
- var url = new URL(params.url);
977
+ const params = (0, _test_utils.buildGetDocumentParams)(filename, options);
978
+ const url = new URL(params.url);
941
979
 
942
980
  if (url.hostname === "localhost") {
943
981
  url.hostname = "127.0.0.1";
@@ -1060,7 +1098,7 @@ describe("api", function () {
1060
1098
  }).catch(done.fail);
1061
1099
  });
1062
1100
  it("gets viewport", function () {
1063
- var viewport = page.getViewport({
1101
+ const viewport = page.getViewport({
1064
1102
  scale: 1.5,
1065
1103
  rotation: 90
1066
1104
  });
@@ -1108,15 +1146,15 @@ describe("api", function () {
1108
1146
  }).toThrow(new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees."));
1109
1147
  });
1110
1148
  it("gets annotations", function (done) {
1111
- var defaultPromise = page.getAnnotations().then(function (data) {
1149
+ const defaultPromise = page.getAnnotations().then(function (data) {
1112
1150
  expect(data.length).toEqual(4);
1113
1151
  });
1114
- var displayPromise = page.getAnnotations({
1152
+ const displayPromise = page.getAnnotations({
1115
1153
  intent: "display"
1116
1154
  }).then(function (data) {
1117
1155
  expect(data.length).toEqual(4);
1118
1156
  });
1119
- var printPromise = page.getAnnotations({
1157
+ const printPromise = page.getAnnotations({
1120
1158
  intent: "print"
1121
1159
  }).then(function (data) {
1122
1160
  expect(data.length).toEqual(4);
@@ -1126,33 +1164,33 @@ describe("api", function () {
1126
1164
  }).catch(done.fail);
1127
1165
  });
1128
1166
  it("gets annotations containing relative URLs (bug 766086)", function (done) {
1129
- var filename = "bug766086.pdf";
1130
- var defaultLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename));
1131
- var defaultPromise = defaultLoadingTask.promise.then(function (pdfDoc) {
1167
+ const filename = "bug766086.pdf";
1168
+ const defaultLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename));
1169
+ const defaultPromise = defaultLoadingTask.promise.then(function (pdfDoc) {
1132
1170
  return pdfDoc.getPage(1).then(function (pdfPage) {
1133
1171
  return pdfPage.getAnnotations();
1134
1172
  });
1135
1173
  });
1136
- var docBaseUrlLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename, {
1174
+ const docBaseUrlLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename, {
1137
1175
  docBaseUrl: "http://www.example.com/test/pdfs/qwerty.pdf"
1138
1176
  }));
1139
- var docBaseUrlPromise = docBaseUrlLoadingTask.promise.then(function (pdfDoc) {
1177
+ const docBaseUrlPromise = docBaseUrlLoadingTask.promise.then(function (pdfDoc) {
1140
1178
  return pdfDoc.getPage(1).then(function (pdfPage) {
1141
1179
  return pdfPage.getAnnotations();
1142
1180
  });
1143
1181
  });
1144
- var invalidDocBaseUrlLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename, {
1182
+ const invalidDocBaseUrlLoadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(filename, {
1145
1183
  docBaseUrl: "qwerty.pdf"
1146
1184
  }));
1147
- var invalidDocBaseUrlPromise = invalidDocBaseUrlLoadingTask.promise.then(function (pdfDoc) {
1185
+ const invalidDocBaseUrlPromise = invalidDocBaseUrlLoadingTask.promise.then(function (pdfDoc) {
1148
1186
  return pdfDoc.getPage(1).then(function (pdfPage) {
1149
1187
  return pdfPage.getAnnotations();
1150
1188
  });
1151
1189
  });
1152
1190
  Promise.all([defaultPromise, docBaseUrlPromise, invalidDocBaseUrlPromise]).then(function (data) {
1153
- var defaultAnnotations = data[0];
1154
- var docBaseUrlAnnotations = data[1];
1155
- var invalidDocBaseUrlAnnotations = data[2];
1191
+ const defaultAnnotations = data[0];
1192
+ const docBaseUrlAnnotations = data[1];
1193
+ const invalidDocBaseUrlAnnotations = data[2];
1156
1194
  expect(defaultAnnotations[0].url).toBeUndefined();
1157
1195
  expect(defaultAnnotations[0].unsafeUrl).toEqual("../../0021/002156/215675E.pdf#15");
1158
1196
  expect(docBaseUrlAnnotations[0].url).toEqual("http://www.example.com/0021/002156/215675E.pdf#15");
@@ -1163,12 +1201,12 @@ describe("api", function () {
1163
1201
  }).catch(done.fail);
1164
1202
  });
1165
1203
  it("gets text content", function (done) {
1166
- var defaultPromise = page.getTextContent();
1167
- var parametersPromise = page.getTextContent({
1204
+ const defaultPromise = page.getTextContent();
1205
+ const parametersPromise = page.getTextContent({
1168
1206
  normalizeWhitespace: true,
1169
1207
  disableCombineTextItems: true
1170
1208
  });
1171
- var promises = [defaultPromise, parametersPromise];
1209
+ const promises = [defaultPromise, parametersPromise];
1172
1210
  Promise.all(promises).then(function (data) {
1173
1211
  expect(!!data[0].items).toEqual(true);
1174
1212
  expect(data[0].items.length).toEqual(7);
@@ -1207,7 +1245,7 @@ describe("api", function () {
1207
1245
  }).catch(done.fail);
1208
1246
  });
1209
1247
  it("gets operator list", function (done) {
1210
- var promise = page.getOperatorList();
1248
+ const promise = page.getOperatorList();
1211
1249
  promise.then(function (oplist) {
1212
1250
  expect(!!oplist.fnArray).toEqual(true);
1213
1251
  expect(!!oplist.argsArray).toEqual(true);
@@ -1262,12 +1300,12 @@ describe("api", function () {
1262
1300
  Promise.all([result1, result2]).then(done, done.fail);
1263
1301
  });
1264
1302
  it("gets document stats after parsing page", function (done) {
1265
- var promise = page.getOperatorList().then(function () {
1303
+ const promise = page.getOperatorList().then(function () {
1266
1304
  return pdfDocument.getStats();
1267
1305
  });
1268
- var expectedStreamTypes = {};
1306
+ const expectedStreamTypes = {};
1269
1307
  expectedStreamTypes[_util.StreamType.FLATE] = true;
1270
- var expectedFontTypes = {};
1308
+ const expectedFontTypes = {};
1271
1309
  expectedFontTypes[_util.FontType.TYPE1] = true;
1272
1310
  expectedFontTypes[_util.FontType.CIDFONTTYPE2] = true;
1273
1311
  promise.then(function (stats) {
@@ -1340,11 +1378,11 @@ describe("api", function () {
1340
1378
  }, done.fail);
1341
1379
  });
1342
1380
  it("cancels rendering of page", function (done) {
1343
- var viewport = page.getViewport({
1381
+ const viewport = page.getViewport({
1344
1382
  scale: 1
1345
1383
  });
1346
- var canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
1347
- var renderTask = page.render({
1384
+ const canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
1385
+ const renderTask = page.render({
1348
1386
  canvasContext: canvasAndCtx.context,
1349
1387
  canvasFactory: CanvasFactory,
1350
1388
  viewport
@@ -1389,17 +1427,17 @@ describe("api", function () {
1389
1427
  });
1390
1428
  it("multiple render() on the same canvas", function (done) {
1391
1429
  const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
1392
- var viewport = page.getViewport({
1430
+ const viewport = page.getViewport({
1393
1431
  scale: 1
1394
1432
  });
1395
- var canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
1396
- var renderTask1 = page.render({
1433
+ const canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
1434
+ const renderTask1 = page.render({
1397
1435
  canvasContext: canvasAndCtx.context,
1398
1436
  canvasFactory: CanvasFactory,
1399
1437
  viewport,
1400
1438
  optionalContentConfigPromise
1401
1439
  });
1402
- var renderTask2 = page.render({
1440
+ const renderTask2 = page.render({
1403
1441
  canvasContext: canvasAndCtx.context,
1404
1442
  canvasFactory: CanvasFactory,
1405
1443
  viewport,
@@ -1532,10 +1570,10 @@ describe("api", function () {
1532
1570
  });
1533
1571
  });
1534
1572
  describe("Multiple `getDocument` instances", function () {
1535
- var pdf1 = (0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf");
1536
- var pdf2 = (0, _test_utils.buildGetDocumentParams)("TAMReview.pdf");
1537
- var pdf3 = (0, _test_utils.buildGetDocumentParams)("issue6068.pdf");
1538
- var loadingTasks = [];
1573
+ const pdf1 = (0, _test_utils.buildGetDocumentParams)("tracemonkey.pdf");
1574
+ const pdf2 = (0, _test_utils.buildGetDocumentParams)("TAMReview.pdf");
1575
+ const pdf3 = (0, _test_utils.buildGetDocumentParams)("issue6068.pdf");
1576
+ const loadingTasks = [];
1539
1577
 
1540
1578
  async function renderPDF(filename) {
1541
1579
  const loadingTask = (0, _api.getDocument)(filename);
@@ -1564,8 +1602,8 @@ describe("api", function () {
1564
1602
  Promise.all(destroyPromises).then(done);
1565
1603
  });
1566
1604
  it("should correctly render PDFs in parallel", function (done) {
1567
- var baseline1, baseline2, baseline3;
1568
- var promiseDone = renderPDF(pdf1).then(function (data1) {
1605
+ let baseline1, baseline2, baseline3;
1606
+ const promiseDone = renderPDF(pdf1).then(function (data1) {
1569
1607
  baseline1 = data1;
1570
1608
  return renderPDF(pdf2);
1571
1609
  }).then(function (data2) {
@@ -1589,17 +1627,9 @@ describe("api", function () {
1589
1627
  let dataPromise;
1590
1628
  beforeAll(function (done) {
1591
1629
  const fileName = "tracemonkey.pdf";
1592
-
1593
- if (_is_node.isNodeJS) {
1594
- dataPromise = _test_utils.NodeFileReaderFactory.fetch({
1595
- path: _test_utils.TEST_PDFS_PATH.node + fileName
1596
- });
1597
- } else {
1598
- dataPromise = _test_utils.DOMFileReaderFactory.fetch({
1599
- path: _test_utils.TEST_PDFS_PATH.dom + fileName
1600
- });
1601
- }
1602
-
1630
+ dataPromise = _test_utils.DefaultFileReaderFactory.fetch({
1631
+ path: _test_utils.TEST_PDFS_PATH + fileName
1632
+ });
1603
1633
  done();
1604
1634
  });
1605
1635
  afterAll(function () {