pdfjs-dist 2.1.266 → 2.5.207

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 (191) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/README.md +4 -0
  3. package/bower.json +1 -1
  4. package/build/pdf.js +8382 -18492
  5. package/build/pdf.js.map +1 -1
  6. package/build/pdf.min.js +22 -1
  7. package/build/pdf.worker.entry.js +5 -3
  8. package/build/pdf.worker.js +20417 -29816
  9. package/build/pdf.worker.js.map +1 -1
  10. package/build/pdf.worker.min.js +22 -1
  11. package/es5/build/pdf.js +25688 -0
  12. package/es5/build/pdf.js.map +1 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +58239 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/web/images/annotation-check.svg +11 -0
  17. package/es5/web/images/annotation-comment.svg +16 -0
  18. package/es5/web/images/annotation-help.svg +26 -0
  19. package/es5/web/images/annotation-insert.svg +10 -0
  20. package/es5/web/images/annotation-key.svg +11 -0
  21. package/es5/web/images/annotation-newparagraph.svg +11 -0
  22. package/es5/web/images/annotation-noicon.svg +7 -0
  23. package/es5/web/images/annotation-note.svg +42 -0
  24. package/es5/web/images/annotation-paragraph.svg +16 -0
  25. package/es5/web/images/loading-icon.gif +0 -0
  26. package/es5/web/images/shadow.png +0 -0
  27. package/es5/web/images/texture.png +0 -0
  28. package/es5/web/pdf_viewer.css +403 -0
  29. package/es5/web/pdf_viewer.js +7742 -0
  30. package/es5/web/pdf_viewer.js.map +1 -0
  31. package/image_decoders/pdf.image_decoders.js +1475 -4897
  32. package/image_decoders/pdf.image_decoders.js.map +1 -1
  33. package/image_decoders/pdf.image_decoders.min.js +22 -1
  34. package/lib/README.md +7 -0
  35. package/lib/core/annotation.js +750 -899
  36. package/lib/core/arithmetic_decoder.js +81 -97
  37. package/lib/core/bidi.js +54 -46
  38. package/lib/core/ccitt.js +88 -81
  39. package/lib/core/ccitt_stream.js +15 -14
  40. package/lib/core/cff_parser.js +235 -183
  41. package/lib/core/charsets.js +4 -4
  42. package/lib/core/chunked_stream.js +447 -542
  43. package/lib/core/cmap.js +222 -264
  44. package/lib/core/colorspace.js +699 -863
  45. package/lib/core/core_utils.js +152 -0
  46. package/lib/core/crypto.js +379 -437
  47. package/lib/core/document.js +573 -660
  48. package/lib/core/encodings.js +15 -15
  49. package/lib/core/evaluator.js +1103 -868
  50. package/lib/core/font_renderer.js +135 -178
  51. package/lib/core/fonts.js +570 -491
  52. package/lib/core/function.js +291 -288
  53. package/lib/core/glyphlist.js +4527 -4526
  54. package/lib/core/image.js +145 -149
  55. package/lib/core/image_utils.js +170 -0
  56. package/lib/core/jbig2.js +325 -316
  57. package/lib/core/jbig2_stream.js +18 -17
  58. package/lib/core/jpeg_stream.js +21 -26
  59. package/lib/core/jpg.js +284 -232
  60. package/lib/core/jpx.js +161 -143
  61. package/lib/core/jpx_stream.js +28 -28
  62. package/lib/core/metrics.js +2929 -2929
  63. package/lib/core/murmurhash3.js +90 -101
  64. package/lib/core/obj.js +1183 -1157
  65. package/lib/core/operator_list.js +99 -67
  66. package/lib/core/parser.js +972 -911
  67. package/lib/core/pattern.js +87 -70
  68. package/lib/core/pdf_manager.js +150 -315
  69. package/lib/core/primitives.js +83 -56
  70. package/lib/core/ps_parser.js +175 -214
  71. package/lib/core/standard_fonts.js +237 -236
  72. package/lib/core/stream.js +94 -74
  73. package/lib/core/type1_parser.js +87 -69
  74. package/lib/core/unicode.js +1654 -1654
  75. package/lib/core/worker.js +193 -390
  76. package/lib/core/worker_stream.js +168 -0
  77. package/lib/display/annotation_layer.js +741 -972
  78. package/lib/display/api.js +1500 -1791
  79. package/lib/display/api_compatibility.js +12 -17
  80. package/lib/display/canvas.js +165 -165
  81. package/lib/display/content_disposition.js +40 -59
  82. package/lib/display/display_utils.js +515 -0
  83. package/lib/display/fetch_stream.js +183 -298
  84. package/lib/display/font_loader.js +273 -413
  85. package/lib/display/metadata.js +86 -98
  86. package/lib/display/network.js +266 -359
  87. package/lib/display/network_utils.js +25 -18
  88. package/lib/display/node_stream.js +285 -458
  89. package/lib/display/pattern_helper.js +113 -65
  90. package/lib/display/svg.js +1166 -901
  91. package/lib/display/text_layer.js +156 -132
  92. package/lib/display/transport_stream.js +262 -278
  93. package/lib/display/webgl.js +70 -83
  94. package/lib/display/worker_options.js +3 -3
  95. package/lib/display/xml_parser.js +303 -392
  96. package/lib/examples/node/domstubs.js +40 -37
  97. package/lib/pdf.js +226 -59
  98. package/lib/pdf.worker.js +14 -6
  99. package/lib/shared/compatibility.js +3 -246
  100. package/lib/shared/is_node.js +7 -6
  101. package/lib/shared/message_handler.js +327 -332
  102. package/lib/shared/util.js +266 -416
  103. package/lib/test/unit/annotation_spec.js +1555 -701
  104. package/lib/test/unit/api_spec.js +802 -604
  105. package/lib/test/unit/bidi_spec.js +7 -7
  106. package/lib/test/unit/cff_parser_spec.js +84 -69
  107. package/lib/test/unit/clitests_helper.js +7 -9
  108. package/lib/test/unit/cmap_spec.js +74 -76
  109. package/lib/test/unit/colorspace_spec.js +166 -161
  110. package/lib/test/unit/core_utils_spec.js +211 -0
  111. package/lib/test/unit/crypto_spec.js +181 -181
  112. package/lib/test/unit/custom_spec.js +20 -22
  113. package/lib/test/unit/display_svg_spec.js +34 -39
  114. package/lib/test/unit/display_utils_spec.js +263 -0
  115. package/lib/test/unit/document_spec.js +16 -21
  116. package/lib/test/unit/encodings_spec.js +12 -34
  117. package/lib/test/unit/evaluator_spec.js +83 -83
  118. package/lib/test/unit/fetch_stream_spec.js +111 -0
  119. package/lib/test/unit/function_spec.js +206 -204
  120. package/lib/test/unit/jasmine-boot.js +46 -30
  121. package/lib/test/unit/message_handler_spec.js +173 -159
  122. package/lib/test/unit/metadata_spec.js +69 -69
  123. package/lib/test/unit/murmurhash3_spec.js +12 -12
  124. package/lib/test/unit/network_spec.js +13 -61
  125. package/lib/test/unit/network_utils_spec.js +183 -119
  126. package/lib/test/unit/node_stream_spec.js +78 -92
  127. package/lib/test/unit/parser_spec.js +172 -114
  128. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  129. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  130. package/lib/test/unit/pdf_history_spec.js +32 -32
  131. package/lib/test/unit/primitives_spec.js +140 -125
  132. package/lib/test/unit/stream_spec.js +16 -14
  133. package/lib/test/unit/test_utils.js +131 -143
  134. package/lib/test/unit/testreporter.js +19 -19
  135. package/lib/test/unit/type1_parser_spec.js +42 -42
  136. package/lib/test/unit/ui_utils_spec.js +297 -459
  137. package/lib/test/unit/unicode_spec.js +38 -38
  138. package/lib/test/unit/util_spec.js +121 -305
  139. package/lib/web/annotation_layer_builder.js +66 -103
  140. package/lib/web/app.js +1328 -1214
  141. package/lib/web/app_options.js +105 -107
  142. package/lib/web/base_viewer.js +824 -838
  143. package/lib/web/chromecom.js +165 -252
  144. package/lib/web/debugger.js +149 -205
  145. package/lib/web/download_manager.js +39 -55
  146. package/lib/web/firefox_print_service.js +37 -27
  147. package/lib/web/firefoxcom.js +212 -363
  148. package/lib/web/genericcom.js +26 -108
  149. package/lib/web/genericl10n.js +24 -153
  150. package/lib/web/grab_to_pan.js +32 -30
  151. package/lib/web/interfaces.js +80 -254
  152. package/lib/web/overlay_manager.js +70 -246
  153. package/lib/web/password_prompt.js +38 -64
  154. package/lib/web/pdf_attachment_viewer.js +113 -131
  155. package/lib/web/pdf_cursor_tools.js +75 -102
  156. package/lib/web/pdf_document_properties.js +221 -306
  157. package/lib/web/pdf_find_bar.js +136 -170
  158. package/lib/web/pdf_find_controller.js +491 -548
  159. package/lib/web/pdf_find_utils.js +13 -13
  160. package/lib/web/pdf_history.js +397 -406
  161. package/lib/web/pdf_link_service.js +304 -348
  162. package/lib/web/pdf_outline_viewer.js +140 -175
  163. package/lib/web/pdf_page_view.js +452 -523
  164. package/lib/web/pdf_presentation_mode.js +308 -357
  165. package/lib/web/pdf_print_service.js +90 -104
  166. package/lib/web/pdf_rendering_queue.js +84 -108
  167. package/lib/web/pdf_sidebar.js +276 -306
  168. package/lib/web/pdf_sidebar_resizer.js +92 -119
  169. package/lib/web/pdf_single_page_viewer.js +77 -126
  170. package/lib/web/pdf_thumbnail_view.js +276 -297
  171. package/lib/web/pdf_thumbnail_viewer.js +186 -206
  172. package/lib/web/pdf_viewer.component.js +20 -21
  173. package/lib/web/pdf_viewer.js +55 -115
  174. package/lib/web/preferences.js +82 -286
  175. package/lib/web/secondary_toolbar.js +164 -196
  176. package/lib/web/text_layer_builder.js +282 -339
  177. package/lib/web/toolbar.js +217 -210
  178. package/lib/web/ui_utils.js +267 -420
  179. package/lib/web/view_history.js +52 -226
  180. package/lib/web/viewer_compatibility.js +21 -6
  181. package/package.json +2 -9
  182. package/web/pdf_viewer.css +35 -25
  183. package/web/pdf_viewer.js +3489 -4855
  184. package/web/pdf_viewer.js.map +1 -1
  185. package/webpack.js +14 -5
  186. package/external/streams/streams-lib.js +0 -3962
  187. package/external/url/url-lib.js +0 -627
  188. package/lib/display/dom_utils.js +0 -494
  189. package/lib/shared/streams_polyfill.js +0 -43
  190. package/lib/shared/url_polyfill.js +0 -56
  191. 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 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -21,158 +21,220 @@
21
21
  */
22
22
  "use strict";
23
23
 
24
- var _annotation = require("../../core/annotation");
24
+ var _annotation = require("../../core/annotation.js");
25
25
 
26
- var _util = require("../../shared/util");
26
+ var _util = require("../../shared/util.js");
27
27
 
28
- var _primitives = require("../../core/primitives");
28
+ var _test_utils = require("./test_utils.js");
29
29
 
30
- var _parser = require("../../core/parser");
30
+ var _primitives = require("../../core/primitives.js");
31
31
 
32
- var _stream = require("../../core/stream");
32
+ var _parser = require("../../core/parser.js");
33
33
 
34
- var _test_utils = require("./test_utils");
35
-
36
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
37
-
38
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
39
-
40
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
41
-
42
- describe('annotation', function () {
43
- var PDFManagerMock =
44
- /*#__PURE__*/
45
- function () {
46
- function PDFManagerMock(params) {
47
- _classCallCheck(this, PDFManagerMock);
34
+ var _stream = require("../../core/stream.js");
48
35
 
36
+ describe("annotation", function () {
37
+ class PDFManagerMock {
38
+ constructor(params) {
49
39
  this.docBaseUrl = params.docBaseUrl || null;
50
40
  }
51
41
 
52
- _createClass(PDFManagerMock, [{
53
- key: "ensure",
54
- value: function ensure(obj, prop, args) {
55
- return new Promise(function (resolve) {
56
- var value = obj[prop];
57
-
58
- if (typeof value === 'function') {
59
- resolve(value.apply(obj, args));
60
- } else {
61
- resolve(value);
62
- }
63
- });
64
- }
65
- }]);
66
-
67
- return PDFManagerMock;
68
- }();
69
-
70
- var IdFactoryMock =
71
- /*#__PURE__*/
72
- function () {
73
- function IdFactoryMock(params) {
74
- _classCallCheck(this, IdFactoryMock);
42
+ ensure(obj, prop, args) {
43
+ return new Promise(function (resolve) {
44
+ const value = obj[prop];
75
45
 
76
- this.uniquePrefix = params.prefix || 'p0_';
77
- this.idCounters = {
78
- obj: params.startObjId || 0
79
- };
46
+ if (typeof value === "function") {
47
+ resolve(value.apply(obj, args));
48
+ } else {
49
+ resolve(value);
50
+ }
51
+ });
80
52
  }
81
53
 
82
- _createClass(IdFactoryMock, [{
83
- key: "createObjId",
84
- value: function createObjId() {
85
- return this.uniquePrefix + ++this.idCounters.obj;
86
- }
87
- }]);
88
-
89
- return IdFactoryMock;
90
- }();
54
+ }
91
55
 
92
- var pdfManagerMock, idFactoryMock;
56
+ let pdfManagerMock, idFactoryMock;
93
57
  beforeAll(function (done) {
94
58
  pdfManagerMock = new PDFManagerMock({
95
59
  docBaseUrl: null
96
60
  });
97
- idFactoryMock = new IdFactoryMock({});
61
+ idFactoryMock = (0, _test_utils.createIdFactory)(0);
98
62
  done();
99
63
  });
100
64
  afterAll(function () {
101
65
  pdfManagerMock = null;
102
66
  idFactoryMock = null;
103
67
  });
104
- describe('AnnotationFactory', function () {
105
- it('should get id for annotation', function (done) {
106
- var annotationDict = new _primitives.Dict();
107
- annotationDict.set('Type', _primitives.Name.get('Annot'));
108
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
109
- var annotationRef = new _primitives.Ref(10, 0);
110
- var xref = new _test_utils.XRefMock([{
68
+ describe("AnnotationFactory", function () {
69
+ it("should get id for annotation", function (done) {
70
+ const annotationDict = new _primitives.Dict();
71
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
72
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
73
+
74
+ const annotationRef = _primitives.Ref.get(10, 0);
75
+
76
+ const xref = new _test_utils.XRefMock([{
111
77
  ref: annotationRef,
112
78
  data: annotationDict
113
79
  }]);
114
80
 
115
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref) {
116
- var data = _ref.data;
81
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
82
+ data
83
+ }) => {
117
84
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
118
- expect(data.id).toEqual('10R');
85
+ expect(data.id).toEqual("10R");
119
86
  done();
120
87
  }, done.fail);
121
88
  });
122
- it('should handle, and get fallback IDs for, annotations that are not ' + 'indirect objects (issue 7569)', function (done) {
123
- var annotationDict = new _primitives.Dict();
124
- annotationDict.set('Type', _primitives.Name.get('Annot'));
125
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
126
- var xref = new _test_utils.XRefMock();
127
- var idFactory = new IdFactoryMock({
128
- prefix: 'p0_',
129
- startObjId: 0
130
- });
89
+ it("should handle, and get fallback IDs for, annotations that are not " + "indirect objects (issue 7569)", function (done) {
90
+ const annotationDict = new _primitives.Dict();
91
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
92
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
93
+ const xref = new _test_utils.XRefMock();
94
+ const idFactory = (0, _test_utils.createIdFactory)(0);
131
95
 
132
- var annotation1 = _annotation.AnnotationFactory.create(xref, annotationDict, pdfManagerMock, idFactory).then(function (_ref2) {
133
- var data = _ref2.data;
96
+ const annotation1 = _annotation.AnnotationFactory.create(xref, annotationDict, pdfManagerMock, idFactory).then(({
97
+ data
98
+ }) => {
134
99
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
135
- expect(data.id).toEqual('annot_p0_1');
100
+ expect(data.id).toEqual("annot_p0_1");
136
101
  });
137
102
 
138
- var annotation2 = _annotation.AnnotationFactory.create(xref, annotationDict, pdfManagerMock, idFactory).then(function (_ref3) {
139
- var data = _ref3.data;
103
+ const annotation2 = _annotation.AnnotationFactory.create(xref, annotationDict, pdfManagerMock, idFactory).then(({
104
+ data
105
+ }) => {
140
106
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
141
- expect(data.id).toEqual('annot_p0_2');
107
+ expect(data.id).toEqual("annot_p0_2");
142
108
  });
143
109
 
144
110
  Promise.all([annotation1, annotation2]).then(done, done.fail);
145
111
  });
146
- it('should handle missing /Subtype', function (done) {
147
- var annotationDict = new _primitives.Dict();
148
- annotationDict.set('Type', _primitives.Name.get('Annot'));
149
- var annotationRef = new _primitives.Ref(1, 0);
150
- var xref = new _test_utils.XRefMock([{
112
+ it("should handle missing /Subtype", function (done) {
113
+ const annotationDict = new _primitives.Dict();
114
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
115
+
116
+ const annotationRef = _primitives.Ref.get(1, 0);
117
+
118
+ const xref = new _test_utils.XRefMock([{
151
119
  ref: annotationRef,
152
120
  data: annotationDict
153
121
  }]);
154
122
 
155
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref4) {
156
- var data = _ref4.data;
123
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
124
+ data
125
+ }) => {
157
126
  expect(data.annotationType).toBeUndefined();
158
127
  done();
159
128
  }, done.fail);
160
129
  });
161
130
  });
162
- describe('Annotation', function () {
163
- var dict, ref;
131
+ describe("getQuadPoints", function () {
132
+ let dict, rect;
133
+ beforeEach(function (done) {
134
+ dict = new _primitives.Dict();
135
+ rect = [];
136
+ done();
137
+ });
138
+ afterEach(function () {
139
+ dict = null;
140
+ rect = null;
141
+ });
142
+ it("should ignore missing quadpoints", function () {
143
+ expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
144
+ });
145
+ it("should ignore non-array values", function () {
146
+ dict.set("QuadPoints", "foo");
147
+ expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
148
+ });
149
+ it("should ignore arrays where the length is not a multiple of eight", function () {
150
+ dict.set("QuadPoints", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
151
+ expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
152
+ });
153
+ it("should ignore quadpoints if one coordinate lies outside the rectangle", function () {
154
+ rect = [10, 10, 20, 20];
155
+ const inputs = [[11, 11, 12, 12, 9, 13, 14, 14], [11, 11, 12, 12, 13, 9, 14, 14], [11, 11, 12, 12, 21, 13, 14, 14], [11, 11, 12, 12, 13, 21, 14, 14]];
156
+
157
+ for (const input of inputs) {
158
+ dict.set("QuadPoints", input);
159
+ expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
160
+ }
161
+ });
162
+ it("should process valid quadpoints arrays", function () {
163
+ rect = [10, 10, 20, 20];
164
+ dict.set("QuadPoints", [11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18]);
165
+ expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual([[{
166
+ x: 11,
167
+ y: 11
168
+ }, {
169
+ x: 12,
170
+ y: 12
171
+ }, {
172
+ x: 13,
173
+ y: 13
174
+ }, {
175
+ x: 14,
176
+ y: 14
177
+ }], [{
178
+ x: 15,
179
+ y: 15
180
+ }, {
181
+ x: 16,
182
+ y: 16
183
+ }, {
184
+ x: 17,
185
+ y: 17
186
+ }, {
187
+ x: 18,
188
+ y: 18
189
+ }]]);
190
+ });
191
+ });
192
+ describe("Annotation", function () {
193
+ let dict, ref;
164
194
  beforeAll(function (done) {
165
195
  dict = new _primitives.Dict();
166
- ref = new _primitives.Ref(1, 0);
196
+ ref = _primitives.Ref.get(1, 0);
167
197
  done();
168
198
  });
169
199
  afterAll(function () {
170
200
  dict = ref = null;
171
201
  });
172
- it('should set and get flags', function () {
173
- var annotation = new _annotation.Annotation({
174
- dict: dict,
175
- ref: ref
202
+ it("should set and get valid contents", function () {
203
+ const annotation = new _annotation.Annotation({
204
+ dict,
205
+ ref
206
+ });
207
+ annotation.setContents("Foo bar baz");
208
+ expect(annotation.contents).toEqual("Foo bar baz");
209
+ });
210
+ it("should not set and get invalid contents", function () {
211
+ const annotation = new _annotation.Annotation({
212
+ dict,
213
+ ref
214
+ });
215
+ annotation.setContents(undefined);
216
+ expect(annotation.contents).toEqual("");
217
+ });
218
+ it("should set and get a valid modification date", function () {
219
+ const annotation = new _annotation.Annotation({
220
+ dict,
221
+ ref
222
+ });
223
+ annotation.setModificationDate("D:20190422");
224
+ expect(annotation.modificationDate).toEqual("D:20190422");
225
+ });
226
+ it("should not set and get an invalid modification date", function () {
227
+ const annotation = new _annotation.Annotation({
228
+ dict,
229
+ ref
230
+ });
231
+ annotation.setModificationDate(undefined);
232
+ expect(annotation.modificationDate).toEqual(null);
233
+ });
234
+ it("should set and get flags", function () {
235
+ const annotation = new _annotation.Annotation({
236
+ dict,
237
+ ref
176
238
  });
177
239
  annotation.setFlags(13);
178
240
  expect(annotation.hasFlag(_util.AnnotationFlag.INVISIBLE)).toEqual(true);
@@ -180,397 +242,693 @@ describe('annotation', function () {
180
242
  expect(annotation.hasFlag(_util.AnnotationFlag.PRINT)).toEqual(true);
181
243
  expect(annotation.hasFlag(_util.AnnotationFlag.READONLY)).toEqual(false);
182
244
  });
183
- it('should be viewable and not printable by default', function () {
184
- var annotation = new _annotation.Annotation({
185
- dict: dict,
186
- ref: ref
245
+ it("should be viewable and not printable by default", function () {
246
+ const annotation = new _annotation.Annotation({
247
+ dict,
248
+ ref
187
249
  });
188
250
  expect(annotation.viewable).toEqual(true);
189
251
  expect(annotation.printable).toEqual(false);
190
252
  });
191
- it('should set and get a valid rectangle', function () {
192
- var annotation = new _annotation.Annotation({
193
- dict: dict,
194
- ref: ref
253
+ it("should set and get a valid rectangle", function () {
254
+ const annotation = new _annotation.Annotation({
255
+ dict,
256
+ ref
195
257
  });
196
258
  annotation.setRectangle([117, 694, 164.298, 720]);
197
259
  expect(annotation.rectangle).toEqual([117, 694, 164.298, 720]);
198
260
  });
199
- it('should not set and get an invalid rectangle', function () {
200
- var annotation = new _annotation.Annotation({
201
- dict: dict,
202
- ref: ref
261
+ it("should not set and get an invalid rectangle", function () {
262
+ const annotation = new _annotation.Annotation({
263
+ dict,
264
+ ref
203
265
  });
204
266
  annotation.setRectangle([117, 694, 164.298]);
205
267
  expect(annotation.rectangle).toEqual([0, 0, 0, 0]);
206
268
  });
207
- it('should reject a color if it is not an array', function () {
208
- var annotation = new _annotation.Annotation({
209
- dict: dict,
210
- ref: ref
269
+ it("should reject a color if it is not an array", function () {
270
+ const annotation = new _annotation.Annotation({
271
+ dict,
272
+ ref
211
273
  });
212
- annotation.setColor('red');
274
+ annotation.setColor("red");
213
275
  expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
214
276
  });
215
- it('should set and get a transparent color', function () {
216
- var annotation = new _annotation.Annotation({
217
- dict: dict,
218
- ref: ref
277
+ it("should set and get a transparent color", function () {
278
+ const annotation = new _annotation.Annotation({
279
+ dict,
280
+ ref
219
281
  });
220
282
  annotation.setColor([]);
221
283
  expect(annotation.color).toEqual(null);
222
284
  });
223
- it('should set and get a grayscale color', function () {
224
- var annotation = new _annotation.Annotation({
225
- dict: dict,
226
- ref: ref
285
+ it("should set and get a grayscale color", function () {
286
+ const annotation = new _annotation.Annotation({
287
+ dict,
288
+ ref
227
289
  });
228
290
  annotation.setColor([0.4]);
229
291
  expect(annotation.color).toEqual(new Uint8ClampedArray([102, 102, 102]));
230
292
  });
231
- it('should set and get an RGB color', function () {
232
- var annotation = new _annotation.Annotation({
233
- dict: dict,
234
- ref: ref
293
+ it("should set and get an RGB color", function () {
294
+ const annotation = new _annotation.Annotation({
295
+ dict,
296
+ ref
235
297
  });
236
298
  annotation.setColor([0, 0, 1]);
237
299
  expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
238
300
  });
239
- it('should set and get a CMYK color', function () {
240
- var annotation = new _annotation.Annotation({
241
- dict: dict,
242
- ref: ref
301
+ it("should set and get a CMYK color", function () {
302
+ const annotation = new _annotation.Annotation({
303
+ dict,
304
+ ref
243
305
  });
244
306
  annotation.setColor([0.1, 0.92, 0.84, 0.02]);
245
307
  expect(annotation.color).toEqual(new Uint8ClampedArray([234, 59, 48]));
246
308
  });
247
- it('should not set and get an invalid color', function () {
248
- var annotation = new _annotation.Annotation({
249
- dict: dict,
250
- ref: ref
309
+ it("should not set and get an invalid color", function () {
310
+ const annotation = new _annotation.Annotation({
311
+ dict,
312
+ ref
251
313
  });
252
314
  annotation.setColor([0.4, 0.6]);
253
315
  expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
254
316
  });
255
317
  });
256
- describe('AnnotationBorderStyle', function () {
257
- it('should set and get a valid width', function () {
258
- var borderStyle = new _annotation.AnnotationBorderStyle();
318
+ describe("AnnotationBorderStyle", function () {
319
+ it("should set and get a valid width", function () {
320
+ const borderStyle = new _annotation.AnnotationBorderStyle();
259
321
  borderStyle.setWidth(3);
260
322
  expect(borderStyle.width).toEqual(3);
261
323
  });
262
- it('should not set and get an invalid width', function () {
263
- var borderStyle = new _annotation.AnnotationBorderStyle();
264
- borderStyle.setWidth('three');
324
+ it("should not set and get an invalid width", function () {
325
+ const borderStyle = new _annotation.AnnotationBorderStyle();
326
+ borderStyle.setWidth("three");
265
327
  expect(borderStyle.width).toEqual(1);
266
328
  });
267
- it('should set the width to zero, when the input is a `Name` (issue 10385)', function () {
268
- var borderStyleZero = new _annotation.AnnotationBorderStyle();
269
- borderStyleZero.setWidth(_primitives.Name.get('0'));
270
- var borderStyleFive = new _annotation.AnnotationBorderStyle();
271
- borderStyleFive.setWidth(_primitives.Name.get('5'));
329
+ it("should set the width to zero, when the input is a `Name` (issue 10385)", function () {
330
+ const borderStyleZero = new _annotation.AnnotationBorderStyle();
331
+ borderStyleZero.setWidth(_primitives.Name.get("0"));
332
+ const borderStyleFive = new _annotation.AnnotationBorderStyle();
333
+ borderStyleFive.setWidth(_primitives.Name.get("5"));
272
334
  expect(borderStyleZero.width).toEqual(0);
273
335
  expect(borderStyleFive.width).toEqual(0);
274
336
  });
275
- it('should set and get a valid style', function () {
276
- var borderStyle = new _annotation.AnnotationBorderStyle();
277
- borderStyle.setStyle(_primitives.Name.get('D'));
337
+ it("should set and get a valid style", function () {
338
+ const borderStyle = new _annotation.AnnotationBorderStyle();
339
+ borderStyle.setStyle(_primitives.Name.get("D"));
278
340
  expect(borderStyle.style).toEqual(_util.AnnotationBorderStyleType.DASHED);
279
341
  });
280
- it('should not set and get an invalid style', function () {
281
- var borderStyle = new _annotation.AnnotationBorderStyle();
282
- borderStyle.setStyle('Dashed');
342
+ it("should not set and get an invalid style", function () {
343
+ const borderStyle = new _annotation.AnnotationBorderStyle();
344
+ borderStyle.setStyle("Dashed");
283
345
  expect(borderStyle.style).toEqual(_util.AnnotationBorderStyleType.SOLID);
284
346
  });
285
- it('should set and get a valid dash array', function () {
286
- var borderStyle = new _annotation.AnnotationBorderStyle();
347
+ it("should set and get a valid dash array", function () {
348
+ const borderStyle = new _annotation.AnnotationBorderStyle();
287
349
  borderStyle.setDashArray([1, 2, 3]);
288
350
  expect(borderStyle.dashArray).toEqual([1, 2, 3]);
289
351
  });
290
- it('should not set and get an invalid dash array', function () {
291
- var borderStyle = new _annotation.AnnotationBorderStyle();
352
+ it("should not set and get an invalid dash array", function () {
353
+ const borderStyle = new _annotation.AnnotationBorderStyle();
292
354
  borderStyle.setDashArray([0, 0]);
293
355
  expect(borderStyle.dashArray).toEqual([3]);
294
356
  });
295
- it('should set and get a valid horizontal corner radius', function () {
296
- var borderStyle = new _annotation.AnnotationBorderStyle();
357
+ it("should set and get a valid horizontal corner radius", function () {
358
+ const borderStyle = new _annotation.AnnotationBorderStyle();
297
359
  borderStyle.setHorizontalCornerRadius(3);
298
360
  expect(borderStyle.horizontalCornerRadius).toEqual(3);
299
361
  });
300
- it('should not set and get an invalid horizontal corner radius', function () {
301
- var borderStyle = new _annotation.AnnotationBorderStyle();
302
- borderStyle.setHorizontalCornerRadius('three');
362
+ it("should not set and get an invalid horizontal corner radius", function () {
363
+ const borderStyle = new _annotation.AnnotationBorderStyle();
364
+ borderStyle.setHorizontalCornerRadius("three");
303
365
  expect(borderStyle.horizontalCornerRadius).toEqual(0);
304
366
  });
305
- it('should set and get a valid vertical corner radius', function () {
306
- var borderStyle = new _annotation.AnnotationBorderStyle();
367
+ it("should set and get a valid vertical corner radius", function () {
368
+ const borderStyle = new _annotation.AnnotationBorderStyle();
307
369
  borderStyle.setVerticalCornerRadius(3);
308
370
  expect(borderStyle.verticalCornerRadius).toEqual(3);
309
371
  });
310
- it('should not set and get an invalid vertical corner radius', function () {
311
- var borderStyle = new _annotation.AnnotationBorderStyle();
312
- borderStyle.setVerticalCornerRadius('three');
372
+ it("should not set and get an invalid vertical corner radius", function () {
373
+ const borderStyle = new _annotation.AnnotationBorderStyle();
374
+ borderStyle.setVerticalCornerRadius("three");
313
375
  expect(borderStyle.verticalCornerRadius).toEqual(0);
314
376
  });
315
377
  });
316
- describe('LinkAnnotation', function () {
317
- it('should correctly parse a URI action', function (done) {
318
- var actionDict = new _primitives.Dict();
319
- actionDict.set('Type', _primitives.Name.get('Action'));
320
- actionDict.set('S', _primitives.Name.get('URI'));
321
- actionDict.set('URI', 'http://www.ctan.org/tex-archive/info/lshort');
322
- var annotationDict = new _primitives.Dict();
323
- annotationDict.set('Type', _primitives.Name.get('Annot'));
324
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
325
- annotationDict.set('A', actionDict);
326
- var annotationRef = new _primitives.Ref(820, 0);
327
- var xref = new _test_utils.XRefMock([{
378
+ describe("MarkupAnnotation", function () {
379
+ let dict, ref;
380
+ beforeAll(function (done) {
381
+ dict = new _primitives.Dict();
382
+ ref = _primitives.Ref.get(1, 0);
383
+ done();
384
+ });
385
+ afterAll(function () {
386
+ dict = ref = null;
387
+ });
388
+ it("should set and get a valid creation date", function () {
389
+ const markupAnnotation = new _annotation.MarkupAnnotation({
390
+ dict,
391
+ ref
392
+ });
393
+ markupAnnotation.setCreationDate("D:20190422");
394
+ expect(markupAnnotation.creationDate).toEqual("D:20190422");
395
+ });
396
+ it("should not set and get an invalid creation date", function () {
397
+ const markupAnnotation = new _annotation.MarkupAnnotation({
398
+ dict,
399
+ ref
400
+ });
401
+ markupAnnotation.setCreationDate(undefined);
402
+ expect(markupAnnotation.creationDate).toEqual(null);
403
+ });
404
+ it("should not parse IRT/RT when not defined", function (done) {
405
+ dict.set("Type", _primitives.Name.get("Annot"));
406
+ dict.set("Subtype", _primitives.Name.get("Text"));
407
+ const xref = new _test_utils.XRefMock([{
408
+ ref,
409
+ data: dict
410
+ }]);
411
+
412
+ _annotation.AnnotationFactory.create(xref, ref, pdfManagerMock, idFactoryMock).then(({
413
+ data
414
+ }) => {
415
+ expect(data.inReplyTo).toBeUndefined();
416
+ expect(data.replyType).toBeUndefined();
417
+ done();
418
+ }, done.fail);
419
+ });
420
+ it("should parse IRT and set default RT when not defined.", function (done) {
421
+ const annotationRef = _primitives.Ref.get(819, 0);
422
+
423
+ const annotationDict = new _primitives.Dict();
424
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
425
+ annotationDict.set("Subtype", _primitives.Name.get("Text"));
426
+
427
+ const replyRef = _primitives.Ref.get(820, 0);
428
+
429
+ const replyDict = new _primitives.Dict();
430
+ replyDict.set("Type", _primitives.Name.get("Annot"));
431
+ replyDict.set("Subtype", _primitives.Name.get("Text"));
432
+ replyDict.set("IRT", annotationRef);
433
+ const xref = new _test_utils.XRefMock([{
434
+ ref: annotationRef,
435
+ data: annotationDict
436
+ }, {
437
+ ref: replyRef,
438
+ data: replyDict
439
+ }]);
440
+ annotationDict.assignXref(xref);
441
+ replyDict.assignXref(xref);
442
+
443
+ _annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(({
444
+ data
445
+ }) => {
446
+ expect(data.inReplyTo).toEqual(annotationRef.toString());
447
+ expect(data.replyType).toEqual("R");
448
+ done();
449
+ }, done.fail);
450
+ });
451
+ it("should parse IRT/RT for a group type", function (done) {
452
+ const annotationRef = _primitives.Ref.get(819, 0);
453
+
454
+ const annotationDict = new _primitives.Dict();
455
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
456
+ annotationDict.set("Subtype", _primitives.Name.get("Text"));
457
+ annotationDict.set("T", "ParentTitle");
458
+ annotationDict.set("Contents", "ParentText");
459
+ annotationDict.set("CreationDate", "D:20180423");
460
+ annotationDict.set("M", "D:20190423");
461
+ annotationDict.set("C", [0, 0, 1]);
462
+
463
+ const popupRef = _primitives.Ref.get(820, 0);
464
+
465
+ const popupDict = new _primitives.Dict();
466
+ popupDict.set("Type", _primitives.Name.get("Annot"));
467
+ popupDict.set("Subtype", _primitives.Name.get("Popup"));
468
+ popupDict.set("Parent", annotationRef);
469
+ annotationDict.set("Popup", popupRef);
470
+
471
+ const replyRef = _primitives.Ref.get(821, 0);
472
+
473
+ const replyDict = new _primitives.Dict();
474
+ replyDict.set("Type", _primitives.Name.get("Annot"));
475
+ replyDict.set("Subtype", _primitives.Name.get("Text"));
476
+ replyDict.set("IRT", annotationRef);
477
+ replyDict.set("RT", _primitives.Name.get("Group"));
478
+ replyDict.set("T", "ReplyTitle");
479
+ replyDict.set("Contents", "ReplyText");
480
+ replyDict.set("CreationDate", "D:20180523");
481
+ replyDict.set("M", "D:20190523");
482
+ replyDict.set("C", [0.4]);
483
+ const xref = new _test_utils.XRefMock([{
484
+ ref: annotationRef,
485
+ data: annotationDict
486
+ }, {
487
+ ref: popupRef,
488
+ data: popupDict
489
+ }, {
490
+ ref: replyRef,
491
+ data: replyDict
492
+ }]);
493
+ annotationDict.assignXref(xref);
494
+ popupDict.assignXref(xref);
495
+ replyDict.assignXref(xref);
496
+
497
+ _annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(({
498
+ data
499
+ }) => {
500
+ expect(data.inReplyTo).toEqual(annotationRef.toString());
501
+ expect(data.replyType).toEqual("Group");
502
+ expect(data.title).toEqual("ParentTitle");
503
+ expect(data.contents).toEqual("ParentText");
504
+ expect(data.creationDate).toEqual("D:20180423");
505
+ expect(data.modificationDate).toEqual("D:20190423");
506
+ expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
507
+ expect(data.hasPopup).toEqual(true);
508
+ done();
509
+ }, done.fail);
510
+ });
511
+ it("should parse IRT/RT for a reply type", function (done) {
512
+ const annotationRef = _primitives.Ref.get(819, 0);
513
+
514
+ const annotationDict = new _primitives.Dict();
515
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
516
+ annotationDict.set("Subtype", _primitives.Name.get("Text"));
517
+ annotationDict.set("T", "ParentTitle");
518
+ annotationDict.set("Contents", "ParentText");
519
+ annotationDict.set("CreationDate", "D:20180423");
520
+ annotationDict.set("M", "D:20190423");
521
+ annotationDict.set("C", [0, 0, 1]);
522
+
523
+ const popupRef = _primitives.Ref.get(820, 0);
524
+
525
+ const popupDict = new _primitives.Dict();
526
+ popupDict.set("Type", _primitives.Name.get("Annot"));
527
+ popupDict.set("Subtype", _primitives.Name.get("Popup"));
528
+ popupDict.set("Parent", annotationRef);
529
+ annotationDict.set("Popup", popupRef);
530
+
531
+ const replyRef = _primitives.Ref.get(821, 0);
532
+
533
+ const replyDict = new _primitives.Dict();
534
+ replyDict.set("Type", _primitives.Name.get("Annot"));
535
+ replyDict.set("Subtype", _primitives.Name.get("Text"));
536
+ replyDict.set("IRT", annotationRef);
537
+ replyDict.set("RT", _primitives.Name.get("R"));
538
+ replyDict.set("T", "ReplyTitle");
539
+ replyDict.set("Contents", "ReplyText");
540
+ replyDict.set("CreationDate", "D:20180523");
541
+ replyDict.set("M", "D:20190523");
542
+ replyDict.set("C", [0.4]);
543
+ const xref = new _test_utils.XRefMock([{
544
+ ref: annotationRef,
545
+ data: annotationDict
546
+ }, {
547
+ ref: popupRef,
548
+ data: popupDict
549
+ }, {
550
+ ref: replyRef,
551
+ data: replyDict
552
+ }]);
553
+ annotationDict.assignXref(xref);
554
+ popupDict.assignXref(xref);
555
+ replyDict.assignXref(xref);
556
+
557
+ _annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(({
558
+ data
559
+ }) => {
560
+ expect(data.inReplyTo).toEqual(annotationRef.toString());
561
+ expect(data.replyType).toEqual("R");
562
+ expect(data.title).toEqual("ReplyTitle");
563
+ expect(data.contents).toEqual("ReplyText");
564
+ expect(data.creationDate).toEqual("D:20180523");
565
+ expect(data.modificationDate).toEqual("D:20190523");
566
+ expect(data.color).toEqual(new Uint8ClampedArray([102, 102, 102]));
567
+ expect(data.hasPopup).toEqual(false);
568
+ done();
569
+ }, done.fail);
570
+ });
571
+ });
572
+ describe("TextAnnotation", function () {
573
+ it("should not parse state model and state when not defined", function (done) {
574
+ const annotationRef = _primitives.Ref.get(819, 0);
575
+
576
+ const annotationDict = new _primitives.Dict();
577
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
578
+ annotationDict.set("Subtype", _primitives.Name.get("Text"));
579
+ annotationDict.set("Contents", "TestText");
580
+
581
+ const replyRef = _primitives.Ref.get(820, 0);
582
+
583
+ const replyDict = new _primitives.Dict();
584
+ replyDict.set("Type", _primitives.Name.get("Annot"));
585
+ replyDict.set("Subtype", _primitives.Name.get("Text"));
586
+ replyDict.set("IRT", annotationRef);
587
+ replyDict.set("RT", _primitives.Name.get("R"));
588
+ replyDict.set("Contents", "ReplyText");
589
+ const xref = new _test_utils.XRefMock([{
590
+ ref: annotationRef,
591
+ data: annotationDict
592
+ }, {
593
+ ref: replyRef,
594
+ data: replyDict
595
+ }]);
596
+ annotationDict.assignXref(xref);
597
+ replyDict.assignXref(xref);
598
+
599
+ _annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(({
600
+ data
601
+ }) => {
602
+ expect(data.stateModel).toBeNull();
603
+ expect(data.state).toBeNull();
604
+ done();
605
+ }, done.fail);
606
+ });
607
+ it("should correctly parse state model and state when defined", function (done) {
608
+ const annotationRef = _primitives.Ref.get(819, 0);
609
+
610
+ const annotationDict = new _primitives.Dict();
611
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
612
+ annotationDict.set("Subtype", _primitives.Name.get("Text"));
613
+
614
+ const replyRef = _primitives.Ref.get(820, 0);
615
+
616
+ const replyDict = new _primitives.Dict();
617
+ replyDict.set("Type", _primitives.Name.get("Annot"));
618
+ replyDict.set("Subtype", _primitives.Name.get("Text"));
619
+ replyDict.set("IRT", annotationRef);
620
+ replyDict.set("RT", _primitives.Name.get("R"));
621
+ replyDict.set("StateModel", "Review");
622
+ replyDict.set("State", "Rejected");
623
+ const xref = new _test_utils.XRefMock([{
624
+ ref: annotationRef,
625
+ data: annotationDict
626
+ }, {
627
+ ref: replyRef,
628
+ data: replyDict
629
+ }]);
630
+ annotationDict.assignXref(xref);
631
+ replyDict.assignXref(xref);
632
+
633
+ _annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(({
634
+ data
635
+ }) => {
636
+ expect(data.stateModel).toEqual("Review");
637
+ expect(data.state).toEqual("Rejected");
638
+ done();
639
+ }, done.fail);
640
+ });
641
+ });
642
+ describe("LinkAnnotation", function () {
643
+ it("should correctly parse a URI action", function (done) {
644
+ const actionDict = new _primitives.Dict();
645
+ actionDict.set("Type", _primitives.Name.get("Action"));
646
+ actionDict.set("S", _primitives.Name.get("URI"));
647
+ actionDict.set("URI", "http://www.ctan.org/tex-archive/info/lshort");
648
+ const annotationDict = new _primitives.Dict();
649
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
650
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
651
+ annotationDict.set("A", actionDict);
652
+
653
+ const annotationRef = _primitives.Ref.get(820, 0);
654
+
655
+ const xref = new _test_utils.XRefMock([{
328
656
  ref: annotationRef,
329
657
  data: annotationDict
330
658
  }]);
331
659
 
332
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref5) {
333
- var data = _ref5.data;
660
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
661
+ data
662
+ }) => {
334
663
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
335
- expect(data.url).toEqual('http://www.ctan.org/tex-archive/info/lshort');
336
- expect(data.unsafeUrl).toEqual('http://www.ctan.org/tex-archive/info/lshort');
664
+ expect(data.url).toEqual("http://www.ctan.org/tex-archive/info/lshort");
665
+ expect(data.unsafeUrl).toEqual("http://www.ctan.org/tex-archive/info/lshort");
337
666
  expect(data.dest).toBeUndefined();
338
667
  done();
339
668
  }, done.fail);
340
669
  });
341
- it('should correctly parse a URI action, where the URI entry ' + 'is missing a protocol', function (done) {
342
- var actionDict = new _primitives.Dict();
343
- actionDict.set('Type', _primitives.Name.get('Action'));
344
- actionDict.set('S', _primitives.Name.get('URI'));
345
- actionDict.set('URI', 'www.hmrc.gov.uk');
346
- var annotationDict = new _primitives.Dict();
347
- annotationDict.set('Type', _primitives.Name.get('Annot'));
348
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
349
- annotationDict.set('A', actionDict);
350
- var annotationRef = new _primitives.Ref(353, 0);
351
- var xref = new _test_utils.XRefMock([{
670
+ it("should correctly parse a URI action, where the URI entry " + "is missing a protocol", function (done) {
671
+ const actionDict = new _primitives.Dict();
672
+ actionDict.set("Type", _primitives.Name.get("Action"));
673
+ actionDict.set("S", _primitives.Name.get("URI"));
674
+ actionDict.set("URI", "www.hmrc.gov.uk");
675
+ const annotationDict = new _primitives.Dict();
676
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
677
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
678
+ annotationDict.set("A", actionDict);
679
+
680
+ const annotationRef = _primitives.Ref.get(353, 0);
681
+
682
+ const xref = new _test_utils.XRefMock([{
352
683
  ref: annotationRef,
353
684
  data: annotationDict
354
685
  }]);
355
686
 
356
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref6) {
357
- var data = _ref6.data;
687
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
688
+ data
689
+ }) => {
358
690
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
359
- expect(data.url).toEqual('http://www.hmrc.gov.uk/');
360
- expect(data.unsafeUrl).toEqual('http://www.hmrc.gov.uk');
691
+ expect(data.url).toEqual("http://www.hmrc.gov.uk/");
692
+ expect(data.unsafeUrl).toEqual("http://www.hmrc.gov.uk");
361
693
  expect(data.dest).toBeUndefined();
362
694
  done();
363
695
  }, done.fail);
364
696
  });
365
- it('should correctly parse a URI action, where the URI entry ' + 'has an incorrect encoding (bug 1122280)', function (done) {
366
- var actionStream = new _stream.StringStream('<<\n' + '/Type /Action\n' + '/S /URI\n' + '/URI (http://www.example.com/\\303\\274\\303\\266\\303\\244)\n' + '>>\n');
367
- var lexer = new _parser.Lexer(actionStream);
368
- var parser = new _parser.Parser(lexer);
369
- var actionDict = parser.getObj();
370
- var annotationDict = new _primitives.Dict();
371
- annotationDict.set('Type', _primitives.Name.get('Annot'));
372
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
373
- annotationDict.set('A', actionDict);
374
- var annotationRef = new _primitives.Ref(8, 0);
375
- var xref = new _test_utils.XRefMock([{
697
+ it("should correctly parse a URI action, where the URI entry " + "has an incorrect encoding (bug 1122280)", function (done) {
698
+ const actionStream = new _stream.StringStream("<<\n" + "/Type /Action\n" + "/S /URI\n" + "/URI (http://www.example.com/\\303\\274\\303\\266\\303\\244)\n" + ">>\n");
699
+ const parser = new _parser.Parser({
700
+ lexer: new _parser.Lexer(actionStream),
701
+ xref: null
702
+ });
703
+ const actionDict = parser.getObj();
704
+ const annotationDict = new _primitives.Dict();
705
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
706
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
707
+ annotationDict.set("A", actionDict);
708
+
709
+ const annotationRef = _primitives.Ref.get(8, 0);
710
+
711
+ const xref = new _test_utils.XRefMock([{
376
712
  ref: annotationRef,
377
713
  data: annotationDict
378
714
  }]);
379
715
 
380
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref7) {
381
- var data = _ref7.data;
716
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
717
+ data
718
+ }) => {
382
719
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
383
- expect(data.url).toEqual(new URL((0, _util.stringToUTF8String)('http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4')).href);
384
- expect(data.unsafeUrl).toEqual((0, _util.stringToUTF8String)('http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4'));
720
+ expect(data.url).toEqual(new URL((0, _util.stringToUTF8String)("http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4")).href);
721
+ expect(data.unsafeUrl).toEqual((0, _util.stringToUTF8String)("http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4"));
385
722
  expect(data.dest).toBeUndefined();
386
723
  done();
387
724
  }, done.fail);
388
725
  });
389
- it('should correctly parse a GoTo action', function (done) {
390
- var actionDict = new _primitives.Dict();
391
- actionDict.set('Type', _primitives.Name.get('Action'));
392
- actionDict.set('S', _primitives.Name.get('GoTo'));
393
- actionDict.set('D', 'page.157');
394
- var annotationDict = new _primitives.Dict();
395
- annotationDict.set('Type', _primitives.Name.get('Annot'));
396
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
397
- annotationDict.set('A', actionDict);
398
- var annotationRef = new _primitives.Ref(798, 0);
399
- var xref = new _test_utils.XRefMock([{
726
+ it("should correctly parse a GoTo action", function (done) {
727
+ const actionDict = new _primitives.Dict();
728
+ actionDict.set("Type", _primitives.Name.get("Action"));
729
+ actionDict.set("S", _primitives.Name.get("GoTo"));
730
+ actionDict.set("D", "page.157");
731
+ const annotationDict = new _primitives.Dict();
732
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
733
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
734
+ annotationDict.set("A", actionDict);
735
+
736
+ const annotationRef = _primitives.Ref.get(798, 0);
737
+
738
+ const xref = new _test_utils.XRefMock([{
400
739
  ref: annotationRef,
401
740
  data: annotationDict
402
741
  }]);
403
742
 
404
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref8) {
405
- var data = _ref8.data;
743
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
744
+ data
745
+ }) => {
406
746
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
407
747
  expect(data.url).toBeUndefined();
408
748
  expect(data.unsafeUrl).toBeUndefined();
409
- expect(data.dest).toEqual('page.157');
749
+ expect(data.dest).toEqual("page.157");
410
750
  done();
411
751
  }, done.fail);
412
752
  });
413
- it('should correctly parse a GoToR action, where the FileSpec entry ' + 'is a string containing a relative URL', function (done) {
414
- var actionDict = new _primitives.Dict();
415
- actionDict.set('Type', _primitives.Name.get('Action'));
416
- actionDict.set('S', _primitives.Name.get('GoToR'));
417
- actionDict.set('F', '../../0013/001346/134685E.pdf');
418
- actionDict.set('D', '4.3');
419
- actionDict.set('NewWindow', true);
420
- var annotationDict = new _primitives.Dict();
421
- annotationDict.set('Type', _primitives.Name.get('Annot'));
422
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
423
- annotationDict.set('A', actionDict);
424
- var annotationRef = new _primitives.Ref(489, 0);
425
- var xref = new _test_utils.XRefMock([{
753
+ it("should correctly parse a GoToR action, where the FileSpec entry " + "is a string containing a relative URL", function (done) {
754
+ const actionDict = new _primitives.Dict();
755
+ actionDict.set("Type", _primitives.Name.get("Action"));
756
+ actionDict.set("S", _primitives.Name.get("GoToR"));
757
+ actionDict.set("F", "../../0013/001346/134685E.pdf");
758
+ actionDict.set("D", "4.3");
759
+ actionDict.set("NewWindow", true);
760
+ const annotationDict = new _primitives.Dict();
761
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
762
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
763
+ annotationDict.set("A", actionDict);
764
+
765
+ const annotationRef = _primitives.Ref.get(489, 0);
766
+
767
+ const xref = new _test_utils.XRefMock([{
426
768
  ref: annotationRef,
427
769
  data: annotationDict
428
770
  }]);
429
771
 
430
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref9) {
431
- var data = _ref9.data;
772
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
773
+ data
774
+ }) => {
432
775
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
433
776
  expect(data.url).toBeUndefined();
434
- expect(data.unsafeUrl).toEqual('../../0013/001346/134685E.pdf#4.3');
777
+ expect(data.unsafeUrl).toEqual("../../0013/001346/134685E.pdf#4.3");
435
778
  expect(data.dest).toBeUndefined();
436
779
  expect(data.newWindow).toEqual(true);
437
780
  done();
438
781
  }, done.fail);
439
782
  });
440
- it('should correctly parse a GoToR action, containing a relative URL, ' + 'with the "docBaseUrl" parameter specified', function (done) {
441
- var actionDict = new _primitives.Dict();
442
- actionDict.set('Type', _primitives.Name.get('Action'));
443
- actionDict.set('S', _primitives.Name.get('GoToR'));
444
- actionDict.set('F', '../../0013/001346/134685E.pdf');
445
- actionDict.set('D', '4.3');
446
- var annotationDict = new _primitives.Dict();
447
- annotationDict.set('Type', _primitives.Name.get('Annot'));
448
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
449
- annotationDict.set('A', actionDict);
450
- var annotationRef = new _primitives.Ref(489, 0);
451
- var xref = new _test_utils.XRefMock([{
783
+ it("should correctly parse a GoToR action, containing a relative URL, " + 'with the "docBaseUrl" parameter specified', function (done) {
784
+ const actionDict = new _primitives.Dict();
785
+ actionDict.set("Type", _primitives.Name.get("Action"));
786
+ actionDict.set("S", _primitives.Name.get("GoToR"));
787
+ actionDict.set("F", "../../0013/001346/134685E.pdf");
788
+ actionDict.set("D", "4.3");
789
+ const annotationDict = new _primitives.Dict();
790
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
791
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
792
+ annotationDict.set("A", actionDict);
793
+
794
+ const annotationRef = _primitives.Ref.get(489, 0);
795
+
796
+ const xref = new _test_utils.XRefMock([{
452
797
  ref: annotationRef,
453
798
  data: annotationDict
454
799
  }]);
455
- var pdfManager = new PDFManagerMock({
456
- docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf'
800
+ const pdfManager = new PDFManagerMock({
801
+ docBaseUrl: "http://www.example.com/test/pdfs/qwerty.pdf"
457
802
  });
458
803
 
459
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(function (_ref10) {
460
- var data = _ref10.data;
804
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(({
805
+ data
806
+ }) => {
461
807
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
462
- expect(data.url).toEqual('http://www.example.com/0013/001346/134685E.pdf#4.3');
463
- expect(data.unsafeUrl).toEqual('../../0013/001346/134685E.pdf#4.3');
808
+ expect(data.url).toEqual("http://www.example.com/0013/001346/134685E.pdf#4.3");
809
+ expect(data.unsafeUrl).toEqual("../../0013/001346/134685E.pdf#4.3");
464
810
  expect(data.dest).toBeUndefined();
465
811
  done();
466
812
  }, done.fail);
467
813
  });
468
- it('should correctly parse a GoToR action, with named destination', function (done) {
469
- var actionDict = new _primitives.Dict();
470
- actionDict.set('Type', _primitives.Name.get('Action'));
471
- actionDict.set('S', _primitives.Name.get('GoToR'));
472
- actionDict.set('F', 'http://www.example.com/test.pdf');
473
- actionDict.set('D', '15');
474
- var annotationDict = new _primitives.Dict();
475
- annotationDict.set('Type', _primitives.Name.get('Annot'));
476
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
477
- annotationDict.set('A', actionDict);
478
- var annotationRef = new _primitives.Ref(495, 0);
479
- var xref = new _test_utils.XRefMock([{
814
+ it("should correctly parse a GoToR action, with named destination", function (done) {
815
+ const actionDict = new _primitives.Dict();
816
+ actionDict.set("Type", _primitives.Name.get("Action"));
817
+ actionDict.set("S", _primitives.Name.get("GoToR"));
818
+ actionDict.set("F", "http://www.example.com/test.pdf");
819
+ actionDict.set("D", "15");
820
+ const annotationDict = new _primitives.Dict();
821
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
822
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
823
+ annotationDict.set("A", actionDict);
824
+
825
+ const annotationRef = _primitives.Ref.get(495, 0);
826
+
827
+ const xref = new _test_utils.XRefMock([{
480
828
  ref: annotationRef,
481
829
  data: annotationDict
482
830
  }]);
483
831
 
484
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref11) {
485
- var data = _ref11.data;
832
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
833
+ data
834
+ }) => {
486
835
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
487
- expect(data.url).toEqual('http://www.example.com/test.pdf#15');
488
- expect(data.unsafeUrl).toEqual('http://www.example.com/test.pdf#15');
836
+ expect(data.url).toEqual("http://www.example.com/test.pdf#15");
837
+ expect(data.unsafeUrl).toEqual("http://www.example.com/test.pdf#15");
489
838
  expect(data.dest).toBeUndefined();
490
839
  expect(data.newWindow).toBeFalsy();
491
840
  done();
492
841
  }, done.fail);
493
842
  });
494
- it('should correctly parse a GoToR action, with explicit destination array', function (done) {
495
- var actionDict = new _primitives.Dict();
496
- actionDict.set('Type', _primitives.Name.get('Action'));
497
- actionDict.set('S', _primitives.Name.get('GoToR'));
498
- actionDict.set('F', 'http://www.example.com/test.pdf');
499
- actionDict.set('D', [14, _primitives.Name.get('XYZ'), null, 298.043, null]);
500
- var annotationDict = new _primitives.Dict();
501
- annotationDict.set('Type', _primitives.Name.get('Annot'));
502
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
503
- annotationDict.set('A', actionDict);
504
- var annotationRef = new _primitives.Ref(489, 0);
505
- var xref = new _test_utils.XRefMock([{
843
+ it("should correctly parse a GoToR action, with explicit destination array", function (done) {
844
+ const actionDict = new _primitives.Dict();
845
+ actionDict.set("Type", _primitives.Name.get("Action"));
846
+ actionDict.set("S", _primitives.Name.get("GoToR"));
847
+ actionDict.set("F", "http://www.example.com/test.pdf");
848
+ actionDict.set("D", [14, _primitives.Name.get("XYZ"), null, 298.043, null]);
849
+ const annotationDict = new _primitives.Dict();
850
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
851
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
852
+ annotationDict.set("A", actionDict);
853
+
854
+ const annotationRef = _primitives.Ref.get(489, 0);
855
+
856
+ const xref = new _test_utils.XRefMock([{
506
857
  ref: annotationRef,
507
858
  data: annotationDict
508
859
  }]);
509
860
 
510
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref12) {
511
- var data = _ref12.data;
861
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
862
+ data
863
+ }) => {
512
864
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
513
- expect(data.url).toEqual(new URL('http://www.example.com/test.pdf#' + '[14,{"name":"XYZ"},null,298.043,null]').href);
514
- expect(data.unsafeUrl).toEqual('http://www.example.com/test.pdf#' + '[14,{"name":"XYZ"},null,298.043,null]');
865
+ expect(data.url).toEqual(new URL("http://www.example.com/test.pdf#" + '[14,{"name":"XYZ"},null,298.043,null]').href);
866
+ expect(data.unsafeUrl).toEqual("http://www.example.com/test.pdf#" + '[14,{"name":"XYZ"},null,298.043,null]');
515
867
  expect(data.dest).toBeUndefined();
516
868
  expect(data.newWindow).toBeFalsy();
517
869
  done();
518
870
  }, done.fail);
519
871
  });
520
- it('should correctly parse a Launch action, where the FileSpec dict ' + 'contains a relative URL, with the "docBaseUrl" parameter specified', function (done) {
521
- var fileSpecDict = new _primitives.Dict();
522
- fileSpecDict.set('Type', _primitives.Name.get('FileSpec'));
523
- fileSpecDict.set('F', 'Part II/Part II.pdf');
524
- fileSpecDict.set('UF', 'Part II/Part II.pdf');
525
- var actionDict = new _primitives.Dict();
526
- actionDict.set('Type', _primitives.Name.get('Action'));
527
- actionDict.set('S', _primitives.Name.get('Launch'));
528
- actionDict.set('F', fileSpecDict);
529
- actionDict.set('NewWindow', true);
530
- var annotationDict = new _primitives.Dict();
531
- annotationDict.set('Type', _primitives.Name.get('Annot'));
532
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
533
- annotationDict.set('A', actionDict);
534
- var annotationRef = new _primitives.Ref(88, 0);
535
- var xref = new _test_utils.XRefMock([{
872
+ it("should correctly parse a Launch action, where the FileSpec dict " + 'contains a relative URL, with the "docBaseUrl" parameter specified', function (done) {
873
+ const fileSpecDict = new _primitives.Dict();
874
+ fileSpecDict.set("Type", _primitives.Name.get("FileSpec"));
875
+ fileSpecDict.set("F", "Part II/Part II.pdf");
876
+ fileSpecDict.set("UF", "Part II/Part II.pdf");
877
+ const actionDict = new _primitives.Dict();
878
+ actionDict.set("Type", _primitives.Name.get("Action"));
879
+ actionDict.set("S", _primitives.Name.get("Launch"));
880
+ actionDict.set("F", fileSpecDict);
881
+ actionDict.set("NewWindow", true);
882
+ const annotationDict = new _primitives.Dict();
883
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
884
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
885
+ annotationDict.set("A", actionDict);
886
+
887
+ const annotationRef = _primitives.Ref.get(88, 0);
888
+
889
+ const xref = new _test_utils.XRefMock([{
536
890
  ref: annotationRef,
537
891
  data: annotationDict
538
892
  }]);
539
- var pdfManager = new PDFManagerMock({
540
- docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf'
893
+ const pdfManager = new PDFManagerMock({
894
+ docBaseUrl: "http://www.example.com/test/pdfs/qwerty.pdf"
541
895
  });
542
896
 
543
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(function (_ref13) {
544
- var data = _ref13.data;
897
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(({
898
+ data
899
+ }) => {
545
900
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
546
- expect(data.url).toEqual(new URL('http://www.example.com/test/pdfs/Part II/Part II.pdf').href);
547
- expect(data.unsafeUrl).toEqual('Part II/Part II.pdf');
901
+ expect(data.url).toEqual(new URL("http://www.example.com/test/pdfs/Part II/Part II.pdf").href);
902
+ expect(data.unsafeUrl).toEqual("Part II/Part II.pdf");
548
903
  expect(data.dest).toBeUndefined();
549
904
  expect(data.newWindow).toEqual(true);
550
905
  done();
551
906
  }, done.fail);
552
907
  });
553
- it('should recover valid URLs from JavaScript actions having certain ' + 'white-listed formats', function (done) {
908
+ it("should recover valid URLs from JavaScript actions having certain " + "white-listed formats", function (done) {
554
909
  function checkJsAction(params) {
555
- var jsEntry = params.jsEntry;
556
- var expectedUrl = params.expectedUrl;
557
- var expectedUnsafeUrl = params.expectedUnsafeUrl;
558
- var expectedNewWindow = params.expectedNewWindow;
559
- var actionDict = new _primitives.Dict();
560
- actionDict.set('Type', _primitives.Name.get('Action'));
561
- actionDict.set('S', _primitives.Name.get('JavaScript'));
562
- actionDict.set('JS', jsEntry);
563
- var annotationDict = new _primitives.Dict();
564
- annotationDict.set('Type', _primitives.Name.get('Annot'));
565
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
566
- annotationDict.set('A', actionDict);
567
- var annotationRef = new _primitives.Ref(46, 0);
568
- var xref = new _test_utils.XRefMock([{
910
+ const jsEntry = params.jsEntry;
911
+ const expectedUrl = params.expectedUrl;
912
+ const expectedUnsafeUrl = params.expectedUnsafeUrl;
913
+ const expectedNewWindow = params.expectedNewWindow;
914
+ const actionDict = new _primitives.Dict();
915
+ actionDict.set("Type", _primitives.Name.get("Action"));
916
+ actionDict.set("S", _primitives.Name.get("JavaScript"));
917
+ actionDict.set("JS", jsEntry);
918
+ const annotationDict = new _primitives.Dict();
919
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
920
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
921
+ annotationDict.set("A", actionDict);
922
+
923
+ const annotationRef = _primitives.Ref.get(46, 0);
924
+
925
+ const xref = new _test_utils.XRefMock([{
569
926
  ref: annotationRef,
570
927
  data: annotationDict
571
928
  }]);
572
- return _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref14) {
573
- var data = _ref14.data;
929
+ return _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
930
+ data
931
+ }) => {
574
932
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
575
933
  expect(data.url).toEqual(expectedUrl);
576
934
  expect(data.unsafeUrl).toEqual(expectedUnsafeUrl);
@@ -579,83 +937,92 @@ describe('annotation', function () {
579
937
  });
580
938
  }
581
939
 
582
- var annotation1 = checkJsAction({
940
+ const annotation1 = checkJsAction({
583
941
  jsEntry: 'function someFun() { return "qwerty"; } someFun();',
584
942
  expectedUrl: undefined,
585
943
  expectedUnsafeUrl: undefined,
586
944
  expectedNewWindow: undefined
587
945
  });
588
- var annotation2 = checkJsAction({
589
- jsEntry: 'window.open(\'http://www.example.com/test.pdf\')',
590
- expectedUrl: new URL('http://www.example.com/test.pdf').href,
591
- expectedUnsafeUrl: 'http://www.example.com/test.pdf',
946
+ const annotation2 = checkJsAction({
947
+ jsEntry: "window.open('http://www.example.com/test.pdf')",
948
+ expectedUrl: new URL("http://www.example.com/test.pdf").href,
949
+ expectedUnsafeUrl: "http://www.example.com/test.pdf",
592
950
  expectedNewWindow: undefined
593
951
  });
594
- var annotation3 = checkJsAction({
952
+ const annotation3 = checkJsAction({
595
953
  jsEntry: new _stream.StringStream('app.launchURL("http://www.example.com/test.pdf", true)'),
596
- expectedUrl: new URL('http://www.example.com/test.pdf').href,
597
- expectedUnsafeUrl: 'http://www.example.com/test.pdf',
954
+ expectedUrl: new URL("http://www.example.com/test.pdf").href,
955
+ expectedUnsafeUrl: "http://www.example.com/test.pdf",
598
956
  expectedNewWindow: true
599
957
  });
600
958
  Promise.all([annotation1, annotation2, annotation3]).then(done, done.fail);
601
959
  });
602
- it('should correctly parse a Named action', function (done) {
603
- var actionDict = new _primitives.Dict();
604
- actionDict.set('Type', _primitives.Name.get('Action'));
605
- actionDict.set('S', _primitives.Name.get('Named'));
606
- actionDict.set('N', _primitives.Name.get('GoToPage'));
607
- var annotationDict = new _primitives.Dict();
608
- annotationDict.set('Type', _primitives.Name.get('Annot'));
609
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
610
- annotationDict.set('A', actionDict);
611
- var annotationRef = new _primitives.Ref(12, 0);
612
- var xref = new _test_utils.XRefMock([{
960
+ it("should correctly parse a Named action", function (done) {
961
+ const actionDict = new _primitives.Dict();
962
+ actionDict.set("Type", _primitives.Name.get("Action"));
963
+ actionDict.set("S", _primitives.Name.get("Named"));
964
+ actionDict.set("N", _primitives.Name.get("GoToPage"));
965
+ const annotationDict = new _primitives.Dict();
966
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
967
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
968
+ annotationDict.set("A", actionDict);
969
+
970
+ const annotationRef = _primitives.Ref.get(12, 0);
971
+
972
+ const xref = new _test_utils.XRefMock([{
613
973
  ref: annotationRef,
614
974
  data: annotationDict
615
975
  }]);
616
976
 
617
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref15) {
618
- var data = _ref15.data;
977
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
978
+ data
979
+ }) => {
619
980
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
620
981
  expect(data.url).toBeUndefined();
621
982
  expect(data.unsafeUrl).toBeUndefined();
622
- expect(data.action).toEqual('GoToPage');
983
+ expect(data.action).toEqual("GoToPage");
623
984
  done();
624
985
  }, done.fail);
625
986
  });
626
- it('should correctly parse a simple Dest', function (done) {
627
- var annotationDict = new _primitives.Dict();
628
- annotationDict.set('Type', _primitives.Name.get('Annot'));
629
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
630
- annotationDict.set('Dest', _primitives.Name.get('LI0'));
631
- var annotationRef = new _primitives.Ref(583, 0);
632
- var xref = new _test_utils.XRefMock([{
987
+ it("should correctly parse a simple Dest", function (done) {
988
+ const annotationDict = new _primitives.Dict();
989
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
990
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
991
+ annotationDict.set("Dest", _primitives.Name.get("LI0"));
992
+
993
+ const annotationRef = _primitives.Ref.get(583, 0);
994
+
995
+ const xref = new _test_utils.XRefMock([{
633
996
  ref: annotationRef,
634
997
  data: annotationDict
635
998
  }]);
636
999
 
637
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref16) {
638
- var data = _ref16.data;
1000
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
1001
+ data
1002
+ }) => {
639
1003
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
640
1004
  expect(data.url).toBeUndefined();
641
1005
  expect(data.unsafeUrl).toBeUndefined();
642
- expect(data.dest).toEqual('LI0');
1006
+ expect(data.dest).toEqual("LI0");
643
1007
  done();
644
1008
  }, done.fail);
645
1009
  });
646
- it('should correctly parse a simple Dest, with explicit destination array', function (done) {
647
- var annotationDict = new _primitives.Dict();
648
- annotationDict.set('Type', _primitives.Name.get('Annot'));
649
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
650
- annotationDict.set('Dest', [new _primitives.Ref(17, 0), _primitives.Name.get('XYZ'), 0, 841.89, null]);
651
- var annotationRef = new _primitives.Ref(10, 0);
652
- var xref = new _test_utils.XRefMock([{
1010
+ it("should correctly parse a simple Dest, with explicit destination array", function (done) {
1011
+ const annotationDict = new _primitives.Dict();
1012
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
1013
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
1014
+ annotationDict.set("Dest", [_primitives.Ref.get(17, 0), _primitives.Name.get("XYZ"), 0, 841.89, null]);
1015
+
1016
+ const annotationRef = _primitives.Ref.get(10, 0);
1017
+
1018
+ const xref = new _test_utils.XRefMock([{
653
1019
  ref: annotationRef,
654
1020
  data: annotationDict
655
1021
  }]);
656
1022
 
657
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref17) {
658
- var data = _ref17.data;
1023
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
1024
+ data
1025
+ }) => {
659
1026
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
660
1027
  expect(data.url).toBeUndefined();
661
1028
  expect(data.unsafeUrl).toBeUndefined();
@@ -663,138 +1030,208 @@ describe('annotation', function () {
663
1030
  num: 17,
664
1031
  gen: 0
665
1032
  }, {
666
- name: 'XYZ'
1033
+ name: "XYZ"
667
1034
  }, 0, 841.89, null]);
668
1035
  done();
669
1036
  }, done.fail);
670
1037
  });
671
- it('should correctly parse a Dest, which violates the specification ' + 'by containing a dictionary', function (done) {
672
- var destDict = new _primitives.Dict();
673
- destDict.set('Type', _primitives.Name.get('Action'));
674
- destDict.set('S', _primitives.Name.get('GoTo'));
675
- destDict.set('D', 'page.157');
676
- var annotationDict = new _primitives.Dict();
677
- annotationDict.set('Type', _primitives.Name.get('Annot'));
678
- annotationDict.set('Subtype', _primitives.Name.get('Link'));
679
- annotationDict.set('Dest', destDict);
680
- var annotationRef = new _primitives.Ref(798, 0);
681
- var xref = new _test_utils.XRefMock([{
1038
+ it("should correctly parse a Dest, which violates the specification " + "by containing a dictionary", function (done) {
1039
+ const destDict = new _primitives.Dict();
1040
+ destDict.set("Type", _primitives.Name.get("Action"));
1041
+ destDict.set("S", _primitives.Name.get("GoTo"));
1042
+ destDict.set("D", "page.157");
1043
+ const annotationDict = new _primitives.Dict();
1044
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
1045
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
1046
+ annotationDict.set("Dest", destDict);
1047
+
1048
+ const annotationRef = _primitives.Ref.get(798, 0);
1049
+
1050
+ const xref = new _test_utils.XRefMock([{
682
1051
  ref: annotationRef,
683
1052
  data: annotationDict
684
1053
  }]);
685
1054
 
686
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref18) {
687
- var data = _ref18.data;
1055
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
1056
+ data
1057
+ }) => {
688
1058
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
689
1059
  expect(data.url).toBeUndefined();
690
1060
  expect(data.unsafeUrl).toBeUndefined();
691
- expect(data.dest).toEqual('page.157');
1061
+ expect(data.dest).toEqual("page.157");
1062
+ done();
1063
+ }, done.fail);
1064
+ });
1065
+ it("should not set quadpoints if not defined", function (done) {
1066
+ const annotationDict = new _primitives.Dict();
1067
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
1068
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
1069
+
1070
+ const annotationRef = _primitives.Ref.get(121, 0);
1071
+
1072
+ const xref = new _test_utils.XRefMock([{
1073
+ ref: annotationRef,
1074
+ data: annotationDict
1075
+ }]);
1076
+
1077
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
1078
+ data
1079
+ }) => {
1080
+ expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
1081
+ expect(data.quadPoints).toBeUndefined();
1082
+ done();
1083
+ }, done.fail);
1084
+ });
1085
+ it("should set quadpoints if defined", function (done) {
1086
+ const annotationDict = new _primitives.Dict();
1087
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
1088
+ annotationDict.set("Subtype", _primitives.Name.get("Link"));
1089
+ annotationDict.set("Rect", [10, 10, 20, 20]);
1090
+ annotationDict.set("QuadPoints", [11, 11, 12, 12, 13, 13, 14, 14]);
1091
+
1092
+ const annotationRef = _primitives.Ref.get(121, 0);
1093
+
1094
+ const xref = new _test_utils.XRefMock([{
1095
+ ref: annotationRef,
1096
+ data: annotationDict
1097
+ }]);
1098
+
1099
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
1100
+ data
1101
+ }) => {
1102
+ expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
1103
+ expect(data.quadPoints).toEqual([[{
1104
+ x: 11,
1105
+ y: 11
1106
+ }, {
1107
+ x: 12,
1108
+ y: 12
1109
+ }, {
1110
+ x: 13,
1111
+ y: 13
1112
+ }, {
1113
+ x: 14,
1114
+ y: 14
1115
+ }]]);
692
1116
  done();
693
1117
  }, done.fail);
694
1118
  });
695
1119
  });
696
- describe('WidgetAnnotation', function () {
697
- var widgetDict;
1120
+ describe("WidgetAnnotation", function () {
1121
+ let widgetDict;
698
1122
  beforeEach(function (done) {
699
1123
  widgetDict = new _primitives.Dict();
700
- widgetDict.set('Type', _primitives.Name.get('Annot'));
701
- widgetDict.set('Subtype', _primitives.Name.get('Widget'));
1124
+ widgetDict.set("Type", _primitives.Name.get("Annot"));
1125
+ widgetDict.set("Subtype", _primitives.Name.get("Widget"));
702
1126
  done();
703
1127
  });
704
1128
  afterEach(function () {
705
1129
  widgetDict = null;
706
1130
  });
707
- it('should handle unknown field names', function (done) {
708
- var widgetRef = new _primitives.Ref(20, 0);
709
- var xref = new _test_utils.XRefMock([{
1131
+ it("should handle unknown field names", function (done) {
1132
+ const widgetRef = _primitives.Ref.get(20, 0);
1133
+
1134
+ const xref = new _test_utils.XRefMock([{
710
1135
  ref: widgetRef,
711
1136
  data: widgetDict
712
1137
  }]);
713
1138
 
714
- _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref19) {
715
- var data = _ref19.data;
1139
+ _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(({
1140
+ data
1141
+ }) => {
716
1142
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
717
- expect(data.fieldName).toEqual('');
1143
+ expect(data.fieldName).toEqual("");
718
1144
  done();
719
1145
  }, done.fail);
720
1146
  });
721
- it('should construct the field name when there are no ancestors', function (done) {
722
- widgetDict.set('T', 'foo');
723
- var widgetRef = new _primitives.Ref(21, 0);
724
- var xref = new _test_utils.XRefMock([{
1147
+ it("should construct the field name when there are no ancestors", function (done) {
1148
+ widgetDict.set("T", "foo");
1149
+
1150
+ const widgetRef = _primitives.Ref.get(21, 0);
1151
+
1152
+ const xref = new _test_utils.XRefMock([{
725
1153
  ref: widgetRef,
726
1154
  data: widgetDict
727
1155
  }]);
728
1156
 
729
- _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref20) {
730
- var data = _ref20.data;
1157
+ _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(({
1158
+ data
1159
+ }) => {
731
1160
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
732
- expect(data.fieldName).toEqual('foo');
1161
+ expect(data.fieldName).toEqual("foo");
733
1162
  done();
734
1163
  }, done.fail);
735
1164
  });
736
- it('should construct the field name when there are ancestors', function (done) {
737
- var firstParent = new _primitives.Dict();
738
- firstParent.set('T', 'foo');
739
- var secondParent = new _primitives.Dict();
740
- secondParent.set('Parent', firstParent);
741
- secondParent.set('T', 'bar');
742
- widgetDict.set('Parent', secondParent);
743
- widgetDict.set('T', 'baz');
744
- var widgetRef = new _primitives.Ref(22, 0);
745
- var xref = new _test_utils.XRefMock([{
1165
+ it("should construct the field name when there are ancestors", function (done) {
1166
+ const firstParent = new _primitives.Dict();
1167
+ firstParent.set("T", "foo");
1168
+ const secondParent = new _primitives.Dict();
1169
+ secondParent.set("Parent", firstParent);
1170
+ secondParent.set("T", "bar");
1171
+ widgetDict.set("Parent", secondParent);
1172
+ widgetDict.set("T", "baz");
1173
+
1174
+ const widgetRef = _primitives.Ref.get(22, 0);
1175
+
1176
+ const xref = new _test_utils.XRefMock([{
746
1177
  ref: widgetRef,
747
1178
  data: widgetDict
748
1179
  }]);
749
1180
 
750
- _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref21) {
751
- var data = _ref21.data;
1181
+ _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(({
1182
+ data
1183
+ }) => {
752
1184
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
753
- expect(data.fieldName).toEqual('foo.bar.baz');
1185
+ expect(data.fieldName).toEqual("foo.bar.baz");
754
1186
  done();
755
1187
  }, done.fail);
756
1188
  });
757
- it('should construct the field name if a parent is not a dictionary ' + '(issue 8143)', function (done) {
758
- var parentDict = new _primitives.Dict();
759
- parentDict.set('Parent', null);
760
- parentDict.set('T', 'foo');
761
- widgetDict.set('Parent', parentDict);
762
- widgetDict.set('T', 'bar');
763
- var widgetRef = new _primitives.Ref(22, 0);
764
- var xref = new _test_utils.XRefMock([{
1189
+ it("should construct the field name if a parent is not a dictionary " + "(issue 8143)", function (done) {
1190
+ const parentDict = new _primitives.Dict();
1191
+ parentDict.set("Parent", null);
1192
+ parentDict.set("T", "foo");
1193
+ widgetDict.set("Parent", parentDict);
1194
+ widgetDict.set("T", "bar");
1195
+
1196
+ const widgetRef = _primitives.Ref.get(22, 0);
1197
+
1198
+ const xref = new _test_utils.XRefMock([{
765
1199
  ref: widgetRef,
766
1200
  data: widgetDict
767
1201
  }]);
768
1202
 
769
- _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref22) {
770
- var data = _ref22.data;
1203
+ _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(({
1204
+ data
1205
+ }) => {
771
1206
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
772
- expect(data.fieldName).toEqual('foo.bar');
1207
+ expect(data.fieldName).toEqual("foo.bar");
773
1208
  done();
774
1209
  }, done.fail);
775
1210
  });
776
1211
  });
777
- describe('TextWidgetAnnotation', function () {
778
- var textWidgetDict;
1212
+ describe("TextWidgetAnnotation", function () {
1213
+ let textWidgetDict;
779
1214
  beforeEach(function (done) {
780
1215
  textWidgetDict = new _primitives.Dict();
781
- textWidgetDict.set('Type', _primitives.Name.get('Annot'));
782
- textWidgetDict.set('Subtype', _primitives.Name.get('Widget'));
783
- textWidgetDict.set('FT', _primitives.Name.get('Tx'));
1216
+ textWidgetDict.set("Type", _primitives.Name.get("Annot"));
1217
+ textWidgetDict.set("Subtype", _primitives.Name.get("Widget"));
1218
+ textWidgetDict.set("FT", _primitives.Name.get("Tx"));
784
1219
  done();
785
1220
  });
786
1221
  afterEach(function () {
787
1222
  textWidgetDict = null;
788
1223
  });
789
- it('should handle unknown text alignment, maximum length and flags', function (done) {
790
- var textWidgetRef = new _primitives.Ref(124, 0);
791
- var xref = new _test_utils.XRefMock([{
1224
+ it("should handle unknown text alignment, maximum length and flags", function (done) {
1225
+ const textWidgetRef = _primitives.Ref.get(124, 0);
1226
+
1227
+ const xref = new _test_utils.XRefMock([{
792
1228
  ref: textWidgetRef,
793
1229
  data: textWidgetDict
794
1230
  }]);
795
1231
 
796
- _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref23) {
797
- var data = _ref23.data;
1232
+ _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(({
1233
+ data
1234
+ }) => {
798
1235
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
799
1236
  expect(data.textAlignment).toEqual(null);
800
1237
  expect(data.maxLen).toEqual(null);
@@ -804,18 +1241,21 @@ describe('annotation', function () {
804
1241
  done();
805
1242
  }, done.fail);
806
1243
  });
807
- it('should not set invalid text alignment, maximum length and flags', function (done) {
808
- textWidgetDict.set('Q', 'center');
809
- textWidgetDict.set('MaxLen', 'five');
810
- textWidgetDict.set('Ff', 'readonly');
811
- var textWidgetRef = new _primitives.Ref(43, 0);
812
- var xref = new _test_utils.XRefMock([{
1244
+ it("should not set invalid text alignment, maximum length and flags", function (done) {
1245
+ textWidgetDict.set("Q", "center");
1246
+ textWidgetDict.set("MaxLen", "five");
1247
+ textWidgetDict.set("Ff", "readonly");
1248
+
1249
+ const textWidgetRef = _primitives.Ref.get(43, 0);
1250
+
1251
+ const xref = new _test_utils.XRefMock([{
813
1252
  ref: textWidgetRef,
814
1253
  data: textWidgetDict
815
1254
  }]);
816
1255
 
817
- _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref24) {
818
- var data = _ref24.data;
1256
+ _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(({
1257
+ data
1258
+ }) => {
819
1259
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
820
1260
  expect(data.textAlignment).toEqual(null);
821
1261
  expect(data.maxLen).toEqual(null);
@@ -825,18 +1265,21 @@ describe('annotation', function () {
825
1265
  done();
826
1266
  }, done.fail);
827
1267
  });
828
- it('should set valid text alignment, maximum length and flags', function (done) {
829
- textWidgetDict.set('Q', 1);
830
- textWidgetDict.set('MaxLen', 20);
831
- textWidgetDict.set('Ff', _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.MULTILINE);
832
- var textWidgetRef = new _primitives.Ref(84, 0);
833
- var xref = new _test_utils.XRefMock([{
1268
+ it("should set valid text alignment, maximum length and flags", function (done) {
1269
+ textWidgetDict.set("Q", 1);
1270
+ textWidgetDict.set("MaxLen", 20);
1271
+ textWidgetDict.set("Ff", _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.MULTILINE);
1272
+
1273
+ const textWidgetRef = _primitives.Ref.get(84, 0);
1274
+
1275
+ const xref = new _test_utils.XRefMock([{
834
1276
  ref: textWidgetRef,
835
1277
  data: textWidgetDict
836
1278
  }]);
837
1279
 
838
- _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref25) {
839
- var data = _ref25.data;
1280
+ _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(({
1281
+ data
1282
+ }) => {
840
1283
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
841
1284
  expect(data.textAlignment).toEqual(1);
842
1285
  expect(data.maxLen).toEqual(20);
@@ -845,55 +1288,64 @@ describe('annotation', function () {
845
1288
  done();
846
1289
  }, done.fail);
847
1290
  });
848
- it('should reject comb fields without a maximum length', function (done) {
849
- textWidgetDict.set('Ff', _util.AnnotationFieldFlag.COMB);
850
- var textWidgetRef = new _primitives.Ref(46, 0);
851
- var xref = new _test_utils.XRefMock([{
1291
+ it("should reject comb fields without a maximum length", function (done) {
1292
+ textWidgetDict.set("Ff", _util.AnnotationFieldFlag.COMB);
1293
+
1294
+ const textWidgetRef = _primitives.Ref.get(46, 0);
1295
+
1296
+ const xref = new _test_utils.XRefMock([{
852
1297
  ref: textWidgetRef,
853
1298
  data: textWidgetDict
854
1299
  }]);
855
1300
 
856
- _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref26) {
857
- var data = _ref26.data;
1301
+ _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(({
1302
+ data
1303
+ }) => {
858
1304
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
859
1305
  expect(data.comb).toEqual(false);
860
1306
  done();
861
1307
  }, done.fail);
862
1308
  });
863
- it('should accept comb fields with a maximum length', function (done) {
864
- textWidgetDict.set('MaxLen', 20);
865
- textWidgetDict.set('Ff', _util.AnnotationFieldFlag.COMB);
866
- var textWidgetRef = new _primitives.Ref(46, 0);
867
- var xref = new _test_utils.XRefMock([{
1309
+ it("should accept comb fields with a maximum length", function (done) {
1310
+ textWidgetDict.set("MaxLen", 20);
1311
+ textWidgetDict.set("Ff", _util.AnnotationFieldFlag.COMB);
1312
+
1313
+ const textWidgetRef = _primitives.Ref.get(46, 0);
1314
+
1315
+ const xref = new _test_utils.XRefMock([{
868
1316
  ref: textWidgetRef,
869
1317
  data: textWidgetDict
870
1318
  }]);
871
1319
 
872
- _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref27) {
873
- var data = _ref27.data;
1320
+ _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(({
1321
+ data
1322
+ }) => {
874
1323
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
875
1324
  expect(data.comb).toEqual(true);
876
1325
  done();
877
1326
  }, done.fail);
878
1327
  });
879
- it('should only accept comb fields when the flags are valid', function (done) {
880
- var invalidFieldFlags = [_util.AnnotationFieldFlag.MULTILINE, _util.AnnotationFieldFlag.PASSWORD, _util.AnnotationFieldFlag.FILESELECT];
881
- var flags = _util.AnnotationFieldFlag.COMB + _util.AnnotationFieldFlag.MULTILINE + _util.AnnotationFieldFlag.PASSWORD + _util.AnnotationFieldFlag.FILESELECT;
882
- var promise = Promise.resolve();
883
-
884
- for (var i = 0, ii = invalidFieldFlags.length; i <= ii; i++) {
885
- promise = promise.then(function () {
886
- textWidgetDict.set('MaxLen', 20);
887
- textWidgetDict.set('Ff', flags);
888
- var textWidgetRef = new _primitives.Ref(93, 0);
889
- var xref = new _test_utils.XRefMock([{
1328
+ it("should only accept comb fields when the flags are valid", function (done) {
1329
+ const invalidFieldFlags = [_util.AnnotationFieldFlag.MULTILINE, _util.AnnotationFieldFlag.PASSWORD, _util.AnnotationFieldFlag.FILESELECT];
1330
+ let flags = _util.AnnotationFieldFlag.COMB + _util.AnnotationFieldFlag.MULTILINE + _util.AnnotationFieldFlag.PASSWORD + _util.AnnotationFieldFlag.FILESELECT;
1331
+ let promise = Promise.resolve();
1332
+
1333
+ for (let i = 0, ii = invalidFieldFlags.length; i <= ii; i++) {
1334
+ promise = promise.then(() => {
1335
+ textWidgetDict.set("MaxLen", 20);
1336
+ textWidgetDict.set("Ff", flags);
1337
+
1338
+ const textWidgetRef = _primitives.Ref.get(93, 0);
1339
+
1340
+ const xref = new _test_utils.XRefMock([{
890
1341
  ref: textWidgetRef,
891
1342
  data: textWidgetDict
892
1343
  }]);
893
- return _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref28) {
894
- var data = _ref28.data;
1344
+ return _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(({
1345
+ data
1346
+ }) => {
895
1347
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
896
- var valid = invalidFieldFlags.length === 0;
1348
+ const valid = invalidFieldFlags.length === 0;
897
1349
  expect(data.comb).toEqual(valid);
898
1350
 
899
1351
  if (!valid) {
@@ -906,151 +1358,170 @@ describe('annotation', function () {
906
1358
  promise.then(done, done.fail);
907
1359
  });
908
1360
  });
909
- describe('ButtonWidgetAnnotation', function () {
910
- var buttonWidgetDict;
1361
+ describe("ButtonWidgetAnnotation", function () {
1362
+ let buttonWidgetDict;
911
1363
  beforeEach(function (done) {
912
1364
  buttonWidgetDict = new _primitives.Dict();
913
- buttonWidgetDict.set('Type', _primitives.Name.get('Annot'));
914
- buttonWidgetDict.set('Subtype', _primitives.Name.get('Widget'));
915
- buttonWidgetDict.set('FT', _primitives.Name.get('Btn'));
1365
+ buttonWidgetDict.set("Type", _primitives.Name.get("Annot"));
1366
+ buttonWidgetDict.set("Subtype", _primitives.Name.get("Widget"));
1367
+ buttonWidgetDict.set("FT", _primitives.Name.get("Btn"));
916
1368
  done();
917
1369
  });
918
1370
  afterEach(function () {
919
1371
  buttonWidgetDict = null;
920
1372
  });
921
- it('should handle checkboxes with export value', function (done) {
922
- buttonWidgetDict.set('V', _primitives.Name.get('1'));
923
- var appearanceStatesDict = new _primitives.Dict();
924
- var exportValueOptionsDict = new _primitives.Dict();
925
- exportValueOptionsDict.set('Off', 0);
926
- exportValueOptionsDict.set('Checked', 1);
927
- appearanceStatesDict.set('D', exportValueOptionsDict);
928
- buttonWidgetDict.set('AP', appearanceStatesDict);
929
- var buttonWidgetRef = new _primitives.Ref(124, 0);
930
- var xref = new _test_utils.XRefMock([{
1373
+ it("should handle checkboxes with export value", function (done) {
1374
+ buttonWidgetDict.set("V", _primitives.Name.get("1"));
1375
+ const appearanceStatesDict = new _primitives.Dict();
1376
+ const exportValueOptionsDict = new _primitives.Dict();
1377
+ exportValueOptionsDict.set("Off", 0);
1378
+ exportValueOptionsDict.set("Checked", 1);
1379
+ appearanceStatesDict.set("D", exportValueOptionsDict);
1380
+ buttonWidgetDict.set("AP", appearanceStatesDict);
1381
+
1382
+ const buttonWidgetRef = _primitives.Ref.get(124, 0);
1383
+
1384
+ const xref = new _test_utils.XRefMock([{
931
1385
  ref: buttonWidgetRef,
932
1386
  data: buttonWidgetDict
933
1387
  }]);
934
1388
 
935
- _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref29) {
936
- var data = _ref29.data;
1389
+ _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(({
1390
+ data
1391
+ }) => {
937
1392
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
938
1393
  expect(data.checkBox).toEqual(true);
939
- expect(data.fieldValue).toEqual('1');
1394
+ expect(data.fieldValue).toEqual("1");
940
1395
  expect(data.radioButton).toEqual(false);
941
- expect(data.exportValue).toEqual('Checked');
1396
+ expect(data.exportValue).toEqual("Checked");
942
1397
  done();
943
1398
  }, done.fail);
944
1399
  });
945
- it('should handle checkboxes without export value', function (done) {
946
- buttonWidgetDict.set('V', _primitives.Name.get('1'));
947
- var buttonWidgetRef = new _primitives.Ref(124, 0);
948
- var xref = new _test_utils.XRefMock([{
1400
+ it("should handle checkboxes without export value", function (done) {
1401
+ buttonWidgetDict.set("V", _primitives.Name.get("1"));
1402
+
1403
+ const buttonWidgetRef = _primitives.Ref.get(124, 0);
1404
+
1405
+ const xref = new _test_utils.XRefMock([{
949
1406
  ref: buttonWidgetRef,
950
1407
  data: buttonWidgetDict
951
1408
  }]);
952
1409
 
953
- _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref30) {
954
- var data = _ref30.data;
1410
+ _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(({
1411
+ data
1412
+ }) => {
955
1413
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
956
1414
  expect(data.checkBox).toEqual(true);
957
- expect(data.fieldValue).toEqual('1');
1415
+ expect(data.fieldValue).toEqual("1");
958
1416
  expect(data.radioButton).toEqual(false);
959
1417
  done();
960
1418
  }, done.fail);
961
1419
  });
962
- it('should handle radio buttons with a field value', function (done) {
963
- var parentDict = new _primitives.Dict();
964
- parentDict.set('V', _primitives.Name.get('1'));
965
- var normalAppearanceStateDict = new _primitives.Dict();
966
- normalAppearanceStateDict.set('2', null);
967
- var appearanceStatesDict = new _primitives.Dict();
968
- appearanceStatesDict.set('N', normalAppearanceStateDict);
969
- buttonWidgetDict.set('Ff', _util.AnnotationFieldFlag.RADIO);
970
- buttonWidgetDict.set('Parent', parentDict);
971
- buttonWidgetDict.set('AP', appearanceStatesDict);
972
- var buttonWidgetRef = new _primitives.Ref(124, 0);
973
- var xref = new _test_utils.XRefMock([{
1420
+ it("should handle radio buttons with a field value", function (done) {
1421
+ const parentDict = new _primitives.Dict();
1422
+ parentDict.set("V", _primitives.Name.get("1"));
1423
+ const normalAppearanceStateDict = new _primitives.Dict();
1424
+ normalAppearanceStateDict.set("2", null);
1425
+ const appearanceStatesDict = new _primitives.Dict();
1426
+ appearanceStatesDict.set("N", normalAppearanceStateDict);
1427
+ buttonWidgetDict.set("Ff", _util.AnnotationFieldFlag.RADIO);
1428
+ buttonWidgetDict.set("Parent", parentDict);
1429
+ buttonWidgetDict.set("AP", appearanceStatesDict);
1430
+
1431
+ const buttonWidgetRef = _primitives.Ref.get(124, 0);
1432
+
1433
+ const xref = new _test_utils.XRefMock([{
974
1434
  ref: buttonWidgetRef,
975
1435
  data: buttonWidgetDict
976
1436
  }]);
977
1437
 
978
- _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref31) {
979
- var data = _ref31.data;
1438
+ _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(({
1439
+ data
1440
+ }) => {
980
1441
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
981
1442
  expect(data.checkBox).toEqual(false);
982
1443
  expect(data.radioButton).toEqual(true);
983
- expect(data.fieldValue).toEqual('1');
984
- expect(data.buttonValue).toEqual('2');
1444
+ expect(data.fieldValue).toEqual("1");
1445
+ expect(data.buttonValue).toEqual("2");
985
1446
  done();
986
1447
  }, done.fail);
987
1448
  });
988
- it('should handle radio buttons without a field value', function (done) {
989
- var normalAppearanceStateDict = new _primitives.Dict();
990
- normalAppearanceStateDict.set('2', null);
991
- var appearanceStatesDict = new _primitives.Dict();
992
- appearanceStatesDict.set('N', normalAppearanceStateDict);
993
- buttonWidgetDict.set('Ff', _util.AnnotationFieldFlag.RADIO);
994
- buttonWidgetDict.set('AP', appearanceStatesDict);
995
- var buttonWidgetRef = new _primitives.Ref(124, 0);
996
- var xref = new _test_utils.XRefMock([{
1449
+ it("should handle radio buttons without a field value", function (done) {
1450
+ const normalAppearanceStateDict = new _primitives.Dict();
1451
+ normalAppearanceStateDict.set("2", null);
1452
+ const appearanceStatesDict = new _primitives.Dict();
1453
+ appearanceStatesDict.set("N", normalAppearanceStateDict);
1454
+ buttonWidgetDict.set("Ff", _util.AnnotationFieldFlag.RADIO);
1455
+ buttonWidgetDict.set("AP", appearanceStatesDict);
1456
+
1457
+ const buttonWidgetRef = _primitives.Ref.get(124, 0);
1458
+
1459
+ const xref = new _test_utils.XRefMock([{
997
1460
  ref: buttonWidgetRef,
998
1461
  data: buttonWidgetDict
999
1462
  }]);
1000
1463
 
1001
- _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref32) {
1002
- var data = _ref32.data;
1464
+ _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(({
1465
+ data
1466
+ }) => {
1003
1467
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1004
1468
  expect(data.checkBox).toEqual(false);
1005
1469
  expect(data.radioButton).toEqual(true);
1006
1470
  expect(data.fieldValue).toEqual(null);
1007
- expect(data.buttonValue).toEqual('2');
1471
+ expect(data.buttonValue).toEqual("2");
1008
1472
  done();
1009
1473
  }, done.fail);
1010
1474
  });
1011
1475
  });
1012
- describe('ChoiceWidgetAnnotation', function () {
1013
- var choiceWidgetDict;
1476
+ describe("ChoiceWidgetAnnotation", function () {
1477
+ let choiceWidgetDict;
1014
1478
  beforeEach(function (done) {
1015
1479
  choiceWidgetDict = new _primitives.Dict();
1016
- choiceWidgetDict.set('Type', _primitives.Name.get('Annot'));
1017
- choiceWidgetDict.set('Subtype', _primitives.Name.get('Widget'));
1018
- choiceWidgetDict.set('FT', _primitives.Name.get('Ch'));
1480
+ choiceWidgetDict.set("Type", _primitives.Name.get("Annot"));
1481
+ choiceWidgetDict.set("Subtype", _primitives.Name.get("Widget"));
1482
+ choiceWidgetDict.set("FT", _primitives.Name.get("Ch"));
1019
1483
  done();
1020
1484
  });
1021
1485
  afterEach(function () {
1022
1486
  choiceWidgetDict = null;
1023
1487
  });
1024
- it('should handle missing option arrays', function (done) {
1025
- var choiceWidgetRef = new _primitives.Ref(122, 0);
1026
- var xref = new _test_utils.XRefMock([{
1488
+ it("should handle missing option arrays", function (done) {
1489
+ const choiceWidgetRef = _primitives.Ref.get(122, 0);
1490
+
1491
+ const xref = new _test_utils.XRefMock([{
1027
1492
  ref: choiceWidgetRef,
1028
1493
  data: choiceWidgetDict
1029
1494
  }]);
1030
1495
 
1031
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref33) {
1032
- var data = _ref33.data;
1496
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
1497
+ data
1498
+ }) => {
1033
1499
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1034
1500
  expect(data.options).toEqual([]);
1035
1501
  done();
1036
1502
  }, done.fail);
1037
1503
  });
1038
- it('should handle option arrays with array elements', function (done) {
1039
- var optionBarRef = new _primitives.Ref(20, 0);
1040
- var optionBarStr = 'Bar';
1041
- var optionOneRef = new _primitives.Ref(10, 0);
1042
- var optionOneArr = ['bar_export', optionBarRef];
1043
- var options = [['foo_export', 'Foo'], optionOneRef];
1044
- var expected = [{
1045
- exportValue: 'foo_export',
1046
- displayValue: 'Foo'
1504
+ it("should handle option arrays with array elements", function (done) {
1505
+ const optionBarRef = _primitives.Ref.get(20, 0);
1506
+
1507
+ const optionBarStr = "Bar";
1508
+
1509
+ const optionOneRef = _primitives.Ref.get(10, 0);
1510
+
1511
+ const optionOneArr = ["bar_export", optionBarRef];
1512
+ const options = [["foo_export", "Foo"], optionOneRef];
1513
+ const expected = [{
1514
+ exportValue: "foo_export",
1515
+ displayValue: "Foo"
1047
1516
  }, {
1048
- exportValue: 'bar_export',
1049
- displayValue: 'Bar'
1517
+ exportValue: "bar_export",
1518
+ displayValue: "Bar"
1050
1519
  }];
1051
- choiceWidgetDict.set('Opt', options);
1052
- var choiceWidgetRef = new _primitives.Ref(123, 0);
1053
- var xref = new _test_utils.XRefMock([{
1520
+ choiceWidgetDict.set("Opt", options);
1521
+
1522
+ const choiceWidgetRef = _primitives.Ref.get(123, 0);
1523
+
1524
+ const xref = new _test_utils.XRefMock([{
1054
1525
  ref: choiceWidgetRef,
1055
1526
  data: choiceWidgetDict
1056
1527
  }, {
@@ -1061,27 +1532,31 @@ describe('annotation', function () {
1061
1532
  data: optionOneArr
1062
1533
  }]);
1063
1534
 
1064
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref34) {
1065
- var data = _ref34.data;
1535
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
1536
+ data
1537
+ }) => {
1066
1538
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1067
1539
  expect(data.options).toEqual(expected);
1068
1540
  done();
1069
1541
  }, done.fail);
1070
1542
  });
1071
- it('should handle option arrays with string elements', function (done) {
1072
- var optionBarRef = new _primitives.Ref(10, 0);
1073
- var optionBarStr = 'Bar';
1074
- var options = ['Foo', optionBarRef];
1075
- var expected = [{
1076
- exportValue: 'Foo',
1077
- displayValue: 'Foo'
1543
+ it("should handle option arrays with string elements", function (done) {
1544
+ const optionBarRef = _primitives.Ref.get(10, 0);
1545
+
1546
+ const optionBarStr = "Bar";
1547
+ const options = ["Foo", optionBarRef];
1548
+ const expected = [{
1549
+ exportValue: "Foo",
1550
+ displayValue: "Foo"
1078
1551
  }, {
1079
- exportValue: 'Bar',
1080
- displayValue: 'Bar'
1552
+ exportValue: "Bar",
1553
+ displayValue: "Bar"
1081
1554
  }];
1082
- choiceWidgetDict.set('Opt', options);
1083
- var choiceWidgetRef = new _primitives.Ref(981, 0);
1084
- var xref = new _test_utils.XRefMock([{
1555
+ choiceWidgetDict.set("Opt", options);
1556
+
1557
+ const choiceWidgetRef = _primitives.Ref.get(981, 0);
1558
+
1559
+ const xref = new _test_utils.XRefMock([{
1085
1560
  ref: choiceWidgetRef,
1086
1561
  data: choiceWidgetDict
1087
1562
  }, {
@@ -1089,99 +1564,114 @@ describe('annotation', function () {
1089
1564
  data: optionBarStr
1090
1565
  }]);
1091
1566
 
1092
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref35) {
1093
- var data = _ref35.data;
1567
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
1568
+ data
1569
+ }) => {
1094
1570
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1095
1571
  expect(data.options).toEqual(expected);
1096
1572
  done();
1097
1573
  }, done.fail);
1098
1574
  });
1099
- it('should handle inherited option arrays (issue 8094)', function (done) {
1100
- var options = [['Value1', 'Description1'], ['Value2', 'Description2']];
1101
- var expected = [{
1102
- exportValue: 'Value1',
1103
- displayValue: 'Description1'
1575
+ it("should handle inherited option arrays (issue 8094)", function (done) {
1576
+ const options = [["Value1", "Description1"], ["Value2", "Description2"]];
1577
+ const expected = [{
1578
+ exportValue: "Value1",
1579
+ displayValue: "Description1"
1104
1580
  }, {
1105
- exportValue: 'Value2',
1106
- displayValue: 'Description2'
1581
+ exportValue: "Value2",
1582
+ displayValue: "Description2"
1107
1583
  }];
1108
- var parentDict = new _primitives.Dict();
1109
- parentDict.set('Opt', options);
1110
- choiceWidgetDict.set('Parent', parentDict);
1111
- var choiceWidgetRef = new _primitives.Ref(123, 0);
1112
- var xref = new _test_utils.XRefMock([{
1584
+ const parentDict = new _primitives.Dict();
1585
+ parentDict.set("Opt", options);
1586
+ choiceWidgetDict.set("Parent", parentDict);
1587
+
1588
+ const choiceWidgetRef = _primitives.Ref.get(123, 0);
1589
+
1590
+ const xref = new _test_utils.XRefMock([{
1113
1591
  ref: choiceWidgetRef,
1114
1592
  data: choiceWidgetDict
1115
1593
  }]);
1116
1594
 
1117
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref36) {
1118
- var data = _ref36.data;
1595
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
1596
+ data
1597
+ }) => {
1119
1598
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1120
1599
  expect(data.options).toEqual(expected);
1121
1600
  done();
1122
1601
  }, done.fail);
1123
1602
  });
1124
- it('should sanitize display values in option arrays (issue 8947)', function (done) {
1125
- var options = ['\xFE\xFF\x00F\x00o\x00o'];
1126
- var expected = [{
1127
- exportValue: '\xFE\xFF\x00F\x00o\x00o',
1128
- displayValue: 'Foo'
1603
+ it("should sanitize display values in option arrays (issue 8947)", function (done) {
1604
+ const options = ["\xFE\xFF\x00F\x00o\x00o"];
1605
+ const expected = [{
1606
+ exportValue: "\xFE\xFF\x00F\x00o\x00o",
1607
+ displayValue: "Foo"
1129
1608
  }];
1130
- choiceWidgetDict.set('Opt', options);
1131
- var choiceWidgetRef = new _primitives.Ref(984, 0);
1132
- var xref = new _test_utils.XRefMock([{
1609
+ choiceWidgetDict.set("Opt", options);
1610
+
1611
+ const choiceWidgetRef = _primitives.Ref.get(984, 0);
1612
+
1613
+ const xref = new _test_utils.XRefMock([{
1133
1614
  ref: choiceWidgetRef,
1134
1615
  data: choiceWidgetDict
1135
1616
  }]);
1136
1617
 
1137
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref37) {
1138
- var data = _ref37.data;
1618
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
1619
+ data
1620
+ }) => {
1139
1621
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1140
1622
  expect(data.options).toEqual(expected);
1141
1623
  done();
1142
1624
  }, done.fail);
1143
1625
  });
1144
- it('should handle array field values', function (done) {
1145
- var fieldValue = ['Foo', 'Bar'];
1146
- choiceWidgetDict.set('V', fieldValue);
1147
- var choiceWidgetRef = new _primitives.Ref(968, 0);
1148
- var xref = new _test_utils.XRefMock([{
1626
+ it("should handle array field values", function (done) {
1627
+ const fieldValue = ["Foo", "Bar"];
1628
+ choiceWidgetDict.set("V", fieldValue);
1629
+
1630
+ const choiceWidgetRef = _primitives.Ref.get(968, 0);
1631
+
1632
+ const xref = new _test_utils.XRefMock([{
1149
1633
  ref: choiceWidgetRef,
1150
1634
  data: choiceWidgetDict
1151
1635
  }]);
1152
1636
 
1153
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref38) {
1154
- var data = _ref38.data;
1637
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
1638
+ data
1639
+ }) => {
1155
1640
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1156
1641
  expect(data.fieldValue).toEqual(fieldValue);
1157
1642
  done();
1158
1643
  }, done.fail);
1159
1644
  });
1160
- it('should handle string field values', function (done) {
1161
- var fieldValue = 'Foo';
1162
- choiceWidgetDict.set('V', fieldValue);
1163
- var choiceWidgetRef = new _primitives.Ref(978, 0);
1164
- var xref = new _test_utils.XRefMock([{
1645
+ it("should handle string field values", function (done) {
1646
+ const fieldValue = "Foo";
1647
+ choiceWidgetDict.set("V", fieldValue);
1648
+
1649
+ const choiceWidgetRef = _primitives.Ref.get(978, 0);
1650
+
1651
+ const xref = new _test_utils.XRefMock([{
1165
1652
  ref: choiceWidgetRef,
1166
1653
  data: choiceWidgetDict
1167
1654
  }]);
1168
1655
 
1169
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref39) {
1170
- var data = _ref39.data;
1656
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
1657
+ data
1658
+ }) => {
1171
1659
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1172
1660
  expect(data.fieldValue).toEqual([fieldValue]);
1173
1661
  done();
1174
1662
  }, done.fail);
1175
1663
  });
1176
- it('should handle unknown flags', function (done) {
1177
- var choiceWidgetRef = new _primitives.Ref(166, 0);
1178
- var xref = new _test_utils.XRefMock([{
1664
+ it("should handle unknown flags", function (done) {
1665
+ const choiceWidgetRef = _primitives.Ref.get(166, 0);
1666
+
1667
+ const xref = new _test_utils.XRefMock([{
1179
1668
  ref: choiceWidgetRef,
1180
1669
  data: choiceWidgetDict
1181
1670
  }]);
1182
1671
 
1183
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref40) {
1184
- var data = _ref40.data;
1672
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
1673
+ data
1674
+ }) => {
1185
1675
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1186
1676
  expect(data.readOnly).toEqual(false);
1187
1677
  expect(data.combo).toEqual(false);
@@ -1189,16 +1679,19 @@ describe('annotation', function () {
1189
1679
  done();
1190
1680
  }, done.fail);
1191
1681
  });
1192
- it('should not set invalid flags', function (done) {
1193
- choiceWidgetDict.set('Ff', 'readonly');
1194
- var choiceWidgetRef = new _primitives.Ref(165, 0);
1195
- var xref = new _test_utils.XRefMock([{
1682
+ it("should not set invalid flags", function (done) {
1683
+ choiceWidgetDict.set("Ff", "readonly");
1684
+
1685
+ const choiceWidgetRef = _primitives.Ref.get(165, 0);
1686
+
1687
+ const xref = new _test_utils.XRefMock([{
1196
1688
  ref: choiceWidgetRef,
1197
1689
  data: choiceWidgetDict
1198
1690
  }]);
1199
1691
 
1200
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref41) {
1201
- var data = _ref41.data;
1692
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
1693
+ data
1694
+ }) => {
1202
1695
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1203
1696
  expect(data.readOnly).toEqual(false);
1204
1697
  expect(data.combo).toEqual(false);
@@ -1206,16 +1699,19 @@ describe('annotation', function () {
1206
1699
  done();
1207
1700
  }, done.fail);
1208
1701
  });
1209
- it('should set valid flags', function (done) {
1210
- choiceWidgetDict.set('Ff', _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.COMBO + _util.AnnotationFieldFlag.MULTISELECT);
1211
- var choiceWidgetRef = new _primitives.Ref(512, 0);
1212
- var xref = new _test_utils.XRefMock([{
1702
+ it("should set valid flags", function (done) {
1703
+ choiceWidgetDict.set("Ff", _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.COMBO + _util.AnnotationFieldFlag.MULTISELECT);
1704
+
1705
+ const choiceWidgetRef = _primitives.Ref.get(512, 0);
1706
+
1707
+ const xref = new _test_utils.XRefMock([{
1213
1708
  ref: choiceWidgetRef,
1214
1709
  data: choiceWidgetDict
1215
1710
  }]);
1216
1711
 
1217
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref42) {
1218
- var data = _ref42.data;
1712
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
1713
+ data
1714
+ }) => {
1219
1715
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1220
1716
  expect(data.readOnly).toEqual(true);
1221
1717
  expect(data.combo).toEqual(true);
@@ -1224,49 +1720,61 @@ describe('annotation', function () {
1224
1720
  }, done.fail);
1225
1721
  });
1226
1722
  });
1227
- describe('LineAnnotation', function () {
1228
- it('should set the line coordinates', function (done) {
1229
- var lineDict = new _primitives.Dict();
1230
- lineDict.set('Type', _primitives.Name.get('Annot'));
1231
- lineDict.set('Subtype', _primitives.Name.get('Line'));
1232
- lineDict.set('L', [1, 2, 3, 4]);
1233
- var lineRef = new _primitives.Ref(122, 0);
1234
- var xref = new _test_utils.XRefMock([{
1723
+ describe("LineAnnotation", function () {
1724
+ it("should set the line coordinates", function (done) {
1725
+ const lineDict = new _primitives.Dict();
1726
+ lineDict.set("Type", _primitives.Name.get("Annot"));
1727
+ lineDict.set("Subtype", _primitives.Name.get("Line"));
1728
+ lineDict.set("L", [1, 2, 3, 4]);
1729
+
1730
+ const lineRef = _primitives.Ref.get(122, 0);
1731
+
1732
+ const xref = new _test_utils.XRefMock([{
1235
1733
  ref: lineRef,
1236
1734
  data: lineDict
1237
1735
  }]);
1238
1736
 
1239
- _annotation.AnnotationFactory.create(xref, lineRef, pdfManagerMock, idFactoryMock).then(function (_ref43) {
1240
- var data = _ref43.data;
1737
+ _annotation.AnnotationFactory.create(xref, lineRef, pdfManagerMock, idFactoryMock).then(({
1738
+ data
1739
+ }) => {
1241
1740
  expect(data.annotationType).toEqual(_util.AnnotationType.LINE);
1242
1741
  expect(data.lineCoordinates).toEqual([1, 2, 3, 4]);
1243
1742
  done();
1244
1743
  }, done.fail);
1245
1744
  });
1246
1745
  });
1247
- describe('FileAttachmentAnnotation', function () {
1248
- it('should correctly parse a file attachment', function (done) {
1249
- var fileStream = new _stream.StringStream('<<\n' + '/Type /EmbeddedFile\n' + '/Subtype /text#2Fplain\n' + '>>\n' + 'stream\n' + 'Test attachment' + 'endstream\n');
1250
- var lexer = new _parser.Lexer(fileStream);
1251
- var parser = new _parser.Parser(lexer, true);
1252
- var fileStreamRef = new _primitives.Ref(18, 0);
1253
- var fileStreamDict = parser.getObj();
1254
- var embeddedFileDict = new _primitives.Dict();
1255
- embeddedFileDict.set('F', fileStreamRef);
1256
- var fileSpecRef = new _primitives.Ref(19, 0);
1257
- var fileSpecDict = new _primitives.Dict();
1258
- fileSpecDict.set('Type', _primitives.Name.get('Filespec'));
1259
- fileSpecDict.set('Desc', '');
1260
- fileSpecDict.set('EF', embeddedFileDict);
1261
- fileSpecDict.set('UF', 'Test.txt');
1262
- var fileAttachmentRef = new _primitives.Ref(20, 0);
1263
- var fileAttachmentDict = new _primitives.Dict();
1264
- fileAttachmentDict.set('Type', _primitives.Name.get('Annot'));
1265
- fileAttachmentDict.set('Subtype', _primitives.Name.get('FileAttachment'));
1266
- fileAttachmentDict.set('FS', fileSpecRef);
1267
- fileAttachmentDict.set('T', 'Topic');
1268
- fileAttachmentDict.set('Contents', 'Test.txt');
1269
- var xref = new _test_utils.XRefMock([{
1746
+ describe("FileAttachmentAnnotation", function () {
1747
+ it("should correctly parse a file attachment", function (done) {
1748
+ const fileStream = new _stream.StringStream("<<\n" + "/Type /EmbeddedFile\n" + "/Subtype /text#2Fplain\n" + ">>\n" + "stream\n" + "Test attachment" + "endstream\n");
1749
+ const parser = new _parser.Parser({
1750
+ lexer: new _parser.Lexer(fileStream),
1751
+ xref: null,
1752
+ allowStreams: true
1753
+ });
1754
+
1755
+ const fileStreamRef = _primitives.Ref.get(18, 0);
1756
+
1757
+ const fileStreamDict = parser.getObj();
1758
+ const embeddedFileDict = new _primitives.Dict();
1759
+ embeddedFileDict.set("F", fileStreamRef);
1760
+
1761
+ const fileSpecRef = _primitives.Ref.get(19, 0);
1762
+
1763
+ const fileSpecDict = new _primitives.Dict();
1764
+ fileSpecDict.set("Type", _primitives.Name.get("Filespec"));
1765
+ fileSpecDict.set("Desc", "");
1766
+ fileSpecDict.set("EF", embeddedFileDict);
1767
+ fileSpecDict.set("UF", "Test.txt");
1768
+
1769
+ const fileAttachmentRef = _primitives.Ref.get(20, 0);
1770
+
1771
+ const fileAttachmentDict = new _primitives.Dict();
1772
+ fileAttachmentDict.set("Type", _primitives.Name.get("Annot"));
1773
+ fileAttachmentDict.set("Subtype", _primitives.Name.get("FileAttachment"));
1774
+ fileAttachmentDict.set("FS", fileSpecRef);
1775
+ fileAttachmentDict.set("T", "Topic");
1776
+ fileAttachmentDict.set("Contents", "Test.txt");
1777
+ const xref = new _test_utils.XRefMock([{
1270
1778
  ref: fileStreamRef,
1271
1779
  data: fileStreamDict
1272
1780
  }, {
@@ -1280,56 +1788,175 @@ describe('annotation', function () {
1280
1788
  fileSpecDict.assignXref(xref);
1281
1789
  fileAttachmentDict.assignXref(xref);
1282
1790
 
1283
- _annotation.AnnotationFactory.create(xref, fileAttachmentRef, pdfManagerMock, idFactoryMock).then(function (_ref44) {
1284
- var data = _ref44.data;
1791
+ _annotation.AnnotationFactory.create(xref, fileAttachmentRef, pdfManagerMock, idFactoryMock).then(({
1792
+ data
1793
+ }) => {
1285
1794
  expect(data.annotationType).toEqual(_util.AnnotationType.FILEATTACHMENT);
1286
- expect(data.file.filename).toEqual('Test.txt');
1287
- expect(data.file.content).toEqual((0, _util.stringToBytes)('Test attachment'));
1795
+ expect(data.file.filename).toEqual("Test.txt");
1796
+ expect(data.file.content).toEqual((0, _util.stringToBytes)("Test attachment"));
1288
1797
  done();
1289
1798
  }, done.fail);
1290
1799
  });
1291
1800
  });
1292
- describe('PopupAnnotation', function () {
1293
- it('should inherit the parent flags when the Popup is not viewable, ' + 'but the parent is (PR 7352)', function (done) {
1294
- var parentDict = new _primitives.Dict();
1295
- parentDict.set('Type', _primitives.Name.get('Annot'));
1296
- parentDict.set('Subtype', _primitives.Name.get('Text'));
1297
- parentDict.set('F', 28);
1298
- var popupDict = new _primitives.Dict();
1299
- popupDict.set('Type', _primitives.Name.get('Annot'));
1300
- popupDict.set('Subtype', _primitives.Name.get('Popup'));
1301
- popupDict.set('F', 25);
1302
- popupDict.set('Parent', parentDict);
1303
- var popupRef = new _primitives.Ref(13, 0);
1304
- var xref = new _test_utils.XRefMock([{
1801
+ describe("PopupAnnotation", function () {
1802
+ it("should inherit properties from its parent", function (done) {
1803
+ const parentDict = new _primitives.Dict();
1804
+ parentDict.set("Type", _primitives.Name.get("Annot"));
1805
+ parentDict.set("Subtype", _primitives.Name.get("Text"));
1806
+ parentDict.set("M", "D:20190423");
1807
+ parentDict.set("C", [0, 0, 1]);
1808
+ const popupDict = new _primitives.Dict();
1809
+ popupDict.set("Type", _primitives.Name.get("Annot"));
1810
+ popupDict.set("Subtype", _primitives.Name.get("Popup"));
1811
+ popupDict.set("Parent", parentDict);
1812
+
1813
+ const popupRef = _primitives.Ref.get(13, 0);
1814
+
1815
+ const xref = new _test_utils.XRefMock([{
1305
1816
  ref: popupRef,
1306
1817
  data: popupDict
1307
1818
  }]);
1308
1819
 
1309
- _annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref45) {
1310
- var data = _ref45.data,
1311
- viewable = _ref45.viewable;
1820
+ _annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(({
1821
+ data,
1822
+ viewable
1823
+ }) => {
1824
+ expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
1825
+ expect(data.modificationDate).toEqual("D:20190423");
1826
+ expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
1827
+ done();
1828
+ }, done.fail);
1829
+ });
1830
+ it("should handle missing parent properties", function (done) {
1831
+ const parentDict = new _primitives.Dict();
1832
+ parentDict.set("Type", _primitives.Name.get("Annot"));
1833
+ parentDict.set("Subtype", _primitives.Name.get("Text"));
1834
+ const popupDict = new _primitives.Dict();
1835
+ popupDict.set("Type", _primitives.Name.get("Annot"));
1836
+ popupDict.set("Subtype", _primitives.Name.get("Popup"));
1837
+ popupDict.set("Parent", parentDict);
1838
+
1839
+ const popupRef = _primitives.Ref.get(13, 0);
1840
+
1841
+ const xref = new _test_utils.XRefMock([{
1842
+ ref: popupRef,
1843
+ data: popupDict
1844
+ }]);
1845
+
1846
+ _annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(({
1847
+ data,
1848
+ viewable
1849
+ }) => {
1850
+ expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
1851
+ expect(data.modificationDate).toEqual(null);
1852
+ expect(data.color).toEqual(null);
1853
+ done();
1854
+ }, done.fail);
1855
+ });
1856
+ it("should inherit the parent flags when the Popup is not viewable, " + "but the parent is (PR 7352)", function (done) {
1857
+ const parentDict = new _primitives.Dict();
1858
+ parentDict.set("Type", _primitives.Name.get("Annot"));
1859
+ parentDict.set("Subtype", _primitives.Name.get("Text"));
1860
+ parentDict.set("F", 28);
1861
+ const popupDict = new _primitives.Dict();
1862
+ popupDict.set("Type", _primitives.Name.get("Annot"));
1863
+ popupDict.set("Subtype", _primitives.Name.get("Popup"));
1864
+ popupDict.set("F", 25);
1865
+ popupDict.set("Parent", parentDict);
1866
+
1867
+ const popupRef = _primitives.Ref.get(13, 0);
1868
+
1869
+ const xref = new _test_utils.XRefMock([{
1870
+ ref: popupRef,
1871
+ data: popupDict
1872
+ }]);
1873
+
1874
+ _annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(({
1875
+ data,
1876
+ viewable
1877
+ }) => {
1312
1878
  expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
1313
1879
  expect(data.annotationFlags).toEqual(25);
1314
1880
  expect(viewable).toEqual(true);
1315
1881
  done();
1316
1882
  }, done.fail);
1317
1883
  });
1884
+ it("should correctly inherit Contents from group-master annotation " + "if parent has ReplyType == Group", function (done) {
1885
+ const annotationRef = _primitives.Ref.get(819, 0);
1886
+
1887
+ const annotationDict = new _primitives.Dict();
1888
+ annotationDict.set("Type", _primitives.Name.get("Annot"));
1889
+ annotationDict.set("Subtype", _primitives.Name.get("Text"));
1890
+ annotationDict.set("T", "Correct Title");
1891
+ annotationDict.set("Contents", "Correct Text");
1892
+ annotationDict.set("M", "D:20190423");
1893
+ annotationDict.set("C", [0, 0, 1]);
1894
+
1895
+ const replyRef = _primitives.Ref.get(820, 0);
1896
+
1897
+ const replyDict = new _primitives.Dict();
1898
+ replyDict.set("Type", _primitives.Name.get("Annot"));
1899
+ replyDict.set("Subtype", _primitives.Name.get("Text"));
1900
+ replyDict.set("IRT", annotationRef);
1901
+ replyDict.set("RT", _primitives.Name.get("Group"));
1902
+ replyDict.set("T", "Reply Title");
1903
+ replyDict.set("Contents", "Reply Text");
1904
+ replyDict.set("M", "D:20190523");
1905
+ replyDict.set("C", [0.4]);
1906
+
1907
+ const popupRef = _primitives.Ref.get(821, 0);
1908
+
1909
+ const popupDict = new _primitives.Dict();
1910
+ popupDict.set("Type", _primitives.Name.get("Annot"));
1911
+ popupDict.set("Subtype", _primitives.Name.get("Popup"));
1912
+ popupDict.set("T", "Wrong Title");
1913
+ popupDict.set("Contents", "Wrong Text");
1914
+ popupDict.set("Parent", replyRef);
1915
+ popupDict.set("M", "D:20190623");
1916
+ popupDict.set("C", [0.8]);
1917
+ replyDict.set("Popup", popupRef);
1918
+ const xref = new _test_utils.XRefMock([{
1919
+ ref: annotationRef,
1920
+ data: annotationDict
1921
+ }, {
1922
+ ref: replyRef,
1923
+ data: replyDict
1924
+ }, {
1925
+ ref: popupRef,
1926
+ data: popupDict
1927
+ }]);
1928
+ annotationDict.assignXref(xref);
1929
+ popupDict.assignXref(xref);
1930
+ replyDict.assignXref(xref);
1931
+
1932
+ _annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(({
1933
+ data
1934
+ }) => {
1935
+ expect(data.title).toEqual("Correct Title");
1936
+ expect(data.contents).toEqual("Correct Text");
1937
+ expect(data.modificationDate).toEqual("D:20190423");
1938
+ expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
1939
+ done();
1940
+ }, done.fail);
1941
+ });
1318
1942
  });
1319
- describe('InkAnnotation', function () {
1320
- it('should handle a single ink list', function (done) {
1321
- var inkDict = new _primitives.Dict();
1322
- inkDict.set('Type', _primitives.Name.get('Annot'));
1323
- inkDict.set('Subtype', _primitives.Name.get('Ink'));
1324
- inkDict.set('InkList', [[1, 1, 1, 2, 2, 2, 3, 3]]);
1325
- var inkRef = new _primitives.Ref(142, 0);
1326
- var xref = new _test_utils.XRefMock([{
1943
+ describe("InkAnnotation", function () {
1944
+ it("should handle a single ink list", function (done) {
1945
+ const inkDict = new _primitives.Dict();
1946
+ inkDict.set("Type", _primitives.Name.get("Annot"));
1947
+ inkDict.set("Subtype", _primitives.Name.get("Ink"));
1948
+ inkDict.set("InkList", [[1, 1, 1, 2, 2, 2, 3, 3]]);
1949
+
1950
+ const inkRef = _primitives.Ref.get(142, 0);
1951
+
1952
+ const xref = new _test_utils.XRefMock([{
1327
1953
  ref: inkRef,
1328
1954
  data: inkDict
1329
1955
  }]);
1330
1956
 
1331
- _annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(function (_ref46) {
1332
- var data = _ref46.data;
1957
+ _annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(({
1958
+ data
1959
+ }) => {
1333
1960
  expect(data.annotationType).toEqual(_util.AnnotationType.INK);
1334
1961
  expect(data.inkLists.length).toEqual(1);
1335
1962
  expect(data.inkLists[0]).toEqual([{
@@ -1348,19 +1975,22 @@ describe('annotation', function () {
1348
1975
  done();
1349
1976
  }, done.fail);
1350
1977
  });
1351
- it('should handle multiple ink lists', function (done) {
1352
- var inkDict = new _primitives.Dict();
1353
- inkDict.set('Type', _primitives.Name.get('Annot'));
1354
- inkDict.set('Subtype', _primitives.Name.get('Ink'));
1355
- inkDict.set('InkList', [[1, 1, 1, 2], [3, 3, 4, 5]]);
1356
- var inkRef = new _primitives.Ref(143, 0);
1357
- var xref = new _test_utils.XRefMock([{
1978
+ it("should handle multiple ink lists", function (done) {
1979
+ const inkDict = new _primitives.Dict();
1980
+ inkDict.set("Type", _primitives.Name.get("Annot"));
1981
+ inkDict.set("Subtype", _primitives.Name.get("Ink"));
1982
+ inkDict.set("InkList", [[1, 1, 1, 2], [3, 3, 4, 5]]);
1983
+
1984
+ const inkRef = _primitives.Ref.get(143, 0);
1985
+
1986
+ const xref = new _test_utils.XRefMock([{
1358
1987
  ref: inkRef,
1359
1988
  data: inkDict
1360
1989
  }]);
1361
1990
 
1362
- _annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(function (_ref47) {
1363
- var data = _ref47.data;
1991
+ _annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(({
1992
+ data
1993
+ }) => {
1364
1994
  expect(data.annotationType).toEqual(_util.AnnotationType.INK);
1365
1995
  expect(data.inkLists.length).toEqual(2);
1366
1996
  expect(data.inkLists[0]).toEqual([{
@@ -1381,4 +2011,228 @@ describe('annotation', function () {
1381
2011
  }, done.fail);
1382
2012
  });
1383
2013
  });
2014
+ describe("HightlightAnnotation", function () {
2015
+ it("should not set quadpoints if not defined", function (done) {
2016
+ const highlightDict = new _primitives.Dict();
2017
+ highlightDict.set("Type", _primitives.Name.get("Annot"));
2018
+ highlightDict.set("Subtype", _primitives.Name.get("Highlight"));
2019
+
2020
+ const highlightRef = _primitives.Ref.get(121, 0);
2021
+
2022
+ const xref = new _test_utils.XRefMock([{
2023
+ ref: highlightRef,
2024
+ data: highlightDict
2025
+ }]);
2026
+
2027
+ _annotation.AnnotationFactory.create(xref, highlightRef, pdfManagerMock, idFactoryMock).then(({
2028
+ data
2029
+ }) => {
2030
+ expect(data.annotationType).toEqual(_util.AnnotationType.HIGHLIGHT);
2031
+ expect(data.quadPoints).toBeUndefined();
2032
+ done();
2033
+ }, done.fail);
2034
+ });
2035
+ it("should set quadpoints if defined", function (done) {
2036
+ const highlightDict = new _primitives.Dict();
2037
+ highlightDict.set("Type", _primitives.Name.get("Annot"));
2038
+ highlightDict.set("Subtype", _primitives.Name.get("Highlight"));
2039
+ highlightDict.set("Rect", [10, 10, 20, 20]);
2040
+ highlightDict.set("QuadPoints", [11, 11, 12, 12, 13, 13, 14, 14]);
2041
+
2042
+ const highlightRef = _primitives.Ref.get(121, 0);
2043
+
2044
+ const xref = new _test_utils.XRefMock([{
2045
+ ref: highlightRef,
2046
+ data: highlightDict
2047
+ }]);
2048
+
2049
+ _annotation.AnnotationFactory.create(xref, highlightRef, pdfManagerMock, idFactoryMock).then(({
2050
+ data
2051
+ }) => {
2052
+ expect(data.annotationType).toEqual(_util.AnnotationType.HIGHLIGHT);
2053
+ expect(data.quadPoints).toEqual([[{
2054
+ x: 11,
2055
+ y: 11
2056
+ }, {
2057
+ x: 12,
2058
+ y: 12
2059
+ }, {
2060
+ x: 13,
2061
+ y: 13
2062
+ }, {
2063
+ x: 14,
2064
+ y: 14
2065
+ }]]);
2066
+ done();
2067
+ }, done.fail);
2068
+ });
2069
+ });
2070
+ describe("UnderlineAnnotation", function () {
2071
+ it("should not set quadpoints if not defined", function (done) {
2072
+ const underlineDict = new _primitives.Dict();
2073
+ underlineDict.set("Type", _primitives.Name.get("Annot"));
2074
+ underlineDict.set("Subtype", _primitives.Name.get("Underline"));
2075
+
2076
+ const underlineRef = _primitives.Ref.get(121, 0);
2077
+
2078
+ const xref = new _test_utils.XRefMock([{
2079
+ ref: underlineRef,
2080
+ data: underlineDict
2081
+ }]);
2082
+
2083
+ _annotation.AnnotationFactory.create(xref, underlineRef, pdfManagerMock, idFactoryMock).then(({
2084
+ data
2085
+ }) => {
2086
+ expect(data.annotationType).toEqual(_util.AnnotationType.UNDERLINE);
2087
+ expect(data.quadPoints).toBeUndefined();
2088
+ done();
2089
+ }, done.fail);
2090
+ });
2091
+ it("should set quadpoints if defined", function (done) {
2092
+ const underlineDict = new _primitives.Dict();
2093
+ underlineDict.set("Type", _primitives.Name.get("Annot"));
2094
+ underlineDict.set("Subtype", _primitives.Name.get("Underline"));
2095
+ underlineDict.set("Rect", [10, 10, 20, 20]);
2096
+ underlineDict.set("QuadPoints", [11, 11, 12, 12, 13, 13, 14, 14]);
2097
+
2098
+ const underlineRef = _primitives.Ref.get(121, 0);
2099
+
2100
+ const xref = new _test_utils.XRefMock([{
2101
+ ref: underlineRef,
2102
+ data: underlineDict
2103
+ }]);
2104
+
2105
+ _annotation.AnnotationFactory.create(xref, underlineRef, pdfManagerMock, idFactoryMock).then(({
2106
+ data
2107
+ }) => {
2108
+ expect(data.annotationType).toEqual(_util.AnnotationType.UNDERLINE);
2109
+ expect(data.quadPoints).toEqual([[{
2110
+ x: 11,
2111
+ y: 11
2112
+ }, {
2113
+ x: 12,
2114
+ y: 12
2115
+ }, {
2116
+ x: 13,
2117
+ y: 13
2118
+ }, {
2119
+ x: 14,
2120
+ y: 14
2121
+ }]]);
2122
+ done();
2123
+ }, done.fail);
2124
+ });
2125
+ });
2126
+ describe("SquigglyAnnotation", function () {
2127
+ it("should not set quadpoints if not defined", function (done) {
2128
+ const squigglyDict = new _primitives.Dict();
2129
+ squigglyDict.set("Type", _primitives.Name.get("Annot"));
2130
+ squigglyDict.set("Subtype", _primitives.Name.get("Squiggly"));
2131
+
2132
+ const squigglyRef = _primitives.Ref.get(121, 0);
2133
+
2134
+ const xref = new _test_utils.XRefMock([{
2135
+ ref: squigglyRef,
2136
+ data: squigglyDict
2137
+ }]);
2138
+
2139
+ _annotation.AnnotationFactory.create(xref, squigglyRef, pdfManagerMock, idFactoryMock).then(({
2140
+ data
2141
+ }) => {
2142
+ expect(data.annotationType).toEqual(_util.AnnotationType.SQUIGGLY);
2143
+ expect(data.quadPoints).toBeUndefined();
2144
+ done();
2145
+ }, done.fail);
2146
+ });
2147
+ it("should set quadpoints if defined", function (done) {
2148
+ const squigglyDict = new _primitives.Dict();
2149
+ squigglyDict.set("Type", _primitives.Name.get("Annot"));
2150
+ squigglyDict.set("Subtype", _primitives.Name.get("Squiggly"));
2151
+ squigglyDict.set("Rect", [10, 10, 20, 20]);
2152
+ squigglyDict.set("QuadPoints", [11, 11, 12, 12, 13, 13, 14, 14]);
2153
+
2154
+ const squigglyRef = _primitives.Ref.get(121, 0);
2155
+
2156
+ const xref = new _test_utils.XRefMock([{
2157
+ ref: squigglyRef,
2158
+ data: squigglyDict
2159
+ }]);
2160
+
2161
+ _annotation.AnnotationFactory.create(xref, squigglyRef, pdfManagerMock, idFactoryMock).then(({
2162
+ data
2163
+ }) => {
2164
+ expect(data.annotationType).toEqual(_util.AnnotationType.SQUIGGLY);
2165
+ expect(data.quadPoints).toEqual([[{
2166
+ x: 11,
2167
+ y: 11
2168
+ }, {
2169
+ x: 12,
2170
+ y: 12
2171
+ }, {
2172
+ x: 13,
2173
+ y: 13
2174
+ }, {
2175
+ x: 14,
2176
+ y: 14
2177
+ }]]);
2178
+ done();
2179
+ }, done.fail);
2180
+ });
2181
+ });
2182
+ describe("StrikeOutAnnotation", function () {
2183
+ it("should not set quadpoints if not defined", function (done) {
2184
+ const strikeOutDict = new _primitives.Dict();
2185
+ strikeOutDict.set("Type", _primitives.Name.get("Annot"));
2186
+ strikeOutDict.set("Subtype", _primitives.Name.get("StrikeOut"));
2187
+
2188
+ const strikeOutRef = _primitives.Ref.get(121, 0);
2189
+
2190
+ const xref = new _test_utils.XRefMock([{
2191
+ ref: strikeOutRef,
2192
+ data: strikeOutDict
2193
+ }]);
2194
+
2195
+ _annotation.AnnotationFactory.create(xref, strikeOutRef, pdfManagerMock, idFactoryMock).then(({
2196
+ data
2197
+ }) => {
2198
+ expect(data.annotationType).toEqual(_util.AnnotationType.STRIKEOUT);
2199
+ expect(data.quadPoints).toBeUndefined();
2200
+ done();
2201
+ }, done.fail);
2202
+ });
2203
+ it("should set quadpoints if defined", function (done) {
2204
+ const strikeOutDict = new _primitives.Dict();
2205
+ strikeOutDict.set("Type", _primitives.Name.get("Annot"));
2206
+ strikeOutDict.set("Subtype", _primitives.Name.get("StrikeOut"));
2207
+ strikeOutDict.set("Rect", [10, 10, 20, 20]);
2208
+ strikeOutDict.set("QuadPoints", [11, 11, 12, 12, 13, 13, 14, 14]);
2209
+
2210
+ const strikeOutRef = _primitives.Ref.get(121, 0);
2211
+
2212
+ const xref = new _test_utils.XRefMock([{
2213
+ ref: strikeOutRef,
2214
+ data: strikeOutDict
2215
+ }]);
2216
+
2217
+ _annotation.AnnotationFactory.create(xref, strikeOutRef, pdfManagerMock, idFactoryMock).then(({
2218
+ data
2219
+ }) => {
2220
+ expect(data.annotationType).toEqual(_util.AnnotationType.STRIKEOUT);
2221
+ expect(data.quadPoints).toEqual([[{
2222
+ x: 11,
2223
+ y: 11
2224
+ }, {
2225
+ x: 12,
2226
+ y: 12
2227
+ }, {
2228
+ x: 13,
2229
+ y: 13
2230
+ }, {
2231
+ x: 14,
2232
+ y: 14
2233
+ }]]);
2234
+ done();
2235
+ }, done.fail);
2236
+ });
2237
+ });
1384
2238
  });