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.
- package/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8382 -18492
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +20417 -29816
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25688 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +58239 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +403 -0
- package/es5/web/pdf_viewer.js +7742 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1475 -4897
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +750 -899
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +235 -183
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +447 -542
- package/lib/core/cmap.js +222 -264
- package/lib/core/colorspace.js +699 -863
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +379 -437
- package/lib/core/document.js +573 -660
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +1103 -868
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +570 -491
- package/lib/core/function.js +291 -288
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +145 -149
- package/lib/core/image_utils.js +170 -0
- package/lib/core/jbig2.js +325 -316
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +21 -26
- package/lib/core/jpg.js +284 -232
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2929 -2929
- package/lib/core/murmurhash3.js +90 -101
- package/lib/core/obj.js +1183 -1157
- package/lib/core/operator_list.js +99 -67
- package/lib/core/parser.js +972 -911
- package/lib/core/pattern.js +87 -70
- package/lib/core/pdf_manager.js +150 -315
- package/lib/core/primitives.js +83 -56
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +94 -74
- package/lib/core/type1_parser.js +87 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +193 -390
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +741 -972
- package/lib/display/api.js +1500 -1791
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +165 -165
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +515 -0
- package/lib/display/fetch_stream.js +183 -298
- package/lib/display/font_loader.js +273 -413
- package/lib/display/metadata.js +86 -98
- package/lib/display/network.js +266 -359
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +285 -458
- package/lib/display/pattern_helper.js +113 -65
- package/lib/display/svg.js +1166 -901
- package/lib/display/text_layer.js +156 -132
- package/lib/display/transport_stream.js +262 -278
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +40 -37
- package/lib/pdf.js +226 -59
- package/lib/pdf.worker.js +14 -6
- package/lib/shared/compatibility.js +3 -246
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +327 -332
- package/lib/shared/util.js +266 -416
- package/lib/test/unit/annotation_spec.js +1555 -701
- package/lib/test/unit/api_spec.js +802 -604
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +84 -69
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +74 -76
- package/lib/test/unit/colorspace_spec.js +166 -161
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +181 -181
- package/lib/test/unit/custom_spec.js +20 -22
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +16 -21
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +83 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +46 -30
- package/lib/test/unit/message_handler_spec.js +173 -159
- package/lib/test/unit/metadata_spec.js +69 -69
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +13 -61
- package/lib/test/unit/network_utils_spec.js +183 -119
- package/lib/test/unit/node_stream_spec.js +78 -92
- package/lib/test/unit/parser_spec.js +172 -114
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +140 -125
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +131 -143
- package/lib/test/unit/testreporter.js +19 -19
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +297 -459
- package/lib/test/unit/unicode_spec.js +38 -38
- package/lib/test/unit/util_spec.js +121 -305
- package/lib/web/annotation_layer_builder.js +66 -103
- package/lib/web/app.js +1328 -1214
- package/lib/web/app_options.js +105 -107
- package/lib/web/base_viewer.js +824 -838
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +39 -55
- package/lib/web/firefox_print_service.js +37 -27
- package/lib/web/firefoxcom.js +212 -363
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +32 -30
- package/lib/web/interfaces.js +80 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +113 -131
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +221 -306
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +491 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +140 -175
- package/lib/web/pdf_page_view.js +452 -523
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +90 -104
- package/lib/web/pdf_rendering_queue.js +84 -108
- package/lib/web/pdf_sidebar.js +276 -306
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +276 -297
- package/lib/web/pdf_thumbnail_viewer.js +186 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +82 -286
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +282 -339
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +267 -420
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +35 -25
- package/web/pdf_viewer.js +3489 -4855
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -494
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- 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
|
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,21 +21,21 @@
|
|
21
21
|
*/
|
22
22
|
"use strict";
|
23
23
|
|
24
|
-
var _stream = require("../../core/stream");
|
24
|
+
var _stream = require("../../core/stream.js");
|
25
25
|
|
26
|
-
var _primitives = require("../../core/primitives");
|
26
|
+
var _primitives = require("../../core/primitives.js");
|
27
27
|
|
28
|
-
describe(
|
28
|
+
describe("stream", function () {
|
29
29
|
beforeEach(function () {
|
30
30
|
jasmine.addMatchers({
|
31
|
-
toMatchTypedArray
|
31
|
+
toMatchTypedArray(util, customEqualityTesters) {
|
32
32
|
return {
|
33
|
-
compare
|
33
|
+
compare(actual, expected) {
|
34
34
|
var result = {};
|
35
35
|
|
36
36
|
if (actual.length !== expected.length) {
|
37
37
|
result.pass = false;
|
38
|
-
result.message =
|
38
|
+
result.message = "Array length: " + actual.length + ", expected: " + expected.length;
|
39
39
|
return result;
|
40
40
|
}
|
41
41
|
|
@@ -53,23 +53,25 @@ describe('stream', function () {
|
|
53
53
|
|
54
54
|
return result;
|
55
55
|
}
|
56
|
+
|
56
57
|
};
|
57
58
|
}
|
59
|
+
|
58
60
|
});
|
59
61
|
});
|
60
|
-
describe(
|
61
|
-
it(
|
62
|
+
describe("PredictorStream", function () {
|
63
|
+
it("should decode simple predictor data", function () {
|
62
64
|
var dict = new _primitives.Dict();
|
63
|
-
dict.set(
|
64
|
-
dict.set(
|
65
|
-
dict.set(
|
66
|
-
dict.set(
|
65
|
+
dict.set("Predictor", 12);
|
66
|
+
dict.set("Colors", 1);
|
67
|
+
dict.set("BitsPerComponent", 8);
|
68
|
+
dict.set("Columns", 2);
|
67
69
|
var input = new _stream.Stream(new Uint8Array([2, 100, 3, 2, 1, 255, 2, 1, 255]), 0, 9, dict);
|
68
70
|
var predictor = new _stream.PredictorStream(input, 9, dict);
|
69
71
|
var result = predictor.getBytes(6);
|
70
72
|
expect(result).toMatchTypedArray(new Uint8Array([100, 3, 101, 2, 102, 1]));
|
71
73
|
predictor.reset();
|
72
|
-
|
74
|
+
const clampedResult = predictor.getBytes(6, true);
|
73
75
|
expect(clampedResult).toEqual(new Uint8ClampedArray([100, 3, 101, 2, 102, 1]));
|
74
76
|
});
|
75
77
|
});
|
@@ -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
|
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.
|
@@ -25,205 +25,193 @@ Object.defineProperty(exports, "__esModule", {
|
|
25
25
|
value: true
|
26
26
|
});
|
27
27
|
exports.buildGetDocumentParams = buildGetDocumentParams;
|
28
|
-
exports.
|
28
|
+
exports.createIdFactory = createIdFactory;
|
29
|
+
exports.TEST_PDFS_PATH = exports.XRefMock = exports.NodeCMapReaderFactory = exports.NodeCanvasFactory = exports.NodeFileReaderFactory = exports.DOMFileReaderFactory = void 0;
|
29
30
|
|
30
|
-
var _util = require("../../shared/util");
|
31
|
+
var _util = require("../../shared/util.js");
|
31
32
|
|
32
|
-
var _is_node =
|
33
|
+
var _is_node = require("../../shared/is_node.js");
|
33
34
|
|
34
|
-
var _primitives = require("../../core/primitives");
|
35
|
+
var _primitives = require("../../core/primitives.js");
|
35
36
|
|
36
|
-
|
37
|
+
var _document = require("../../core/document.js");
|
37
38
|
|
38
|
-
|
39
|
+
class DOMFileReaderFactory {
|
40
|
+
static async fetch(params) {
|
41
|
+
const response = await fetch(params.path);
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
+
if (!response.ok) {
|
44
|
+
throw new Error(response.statusText);
|
45
|
+
}
|
43
46
|
|
44
|
-
|
45
|
-
/*#__PURE__*/
|
46
|
-
function () {
|
47
|
-
function NodeFileReaderFactory() {
|
48
|
-
_classCallCheck(this, NodeFileReaderFactory);
|
47
|
+
return new Uint8Array(await response.arrayBuffer());
|
49
48
|
}
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
var fs = require('fs');
|
50
|
+
}
|
51
|
+
|
52
|
+
exports.DOMFileReaderFactory = DOMFileReaderFactory;
|
55
53
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
class NodeFileReaderFactory {
|
55
|
+
static async fetch(params) {
|
56
|
+
const fs = require("fs");
|
57
|
+
|
58
|
+
return new Promise((resolve, reject) => {
|
59
|
+
fs.readFile(params.path, (error, data) => {
|
60
|
+
if (error || !data) {
|
61
|
+
reject(error || new Error(`Empty file for: ${params.path}`));
|
62
|
+
return;
|
63
|
+
}
|
60
64
|
|
61
|
-
|
62
|
-
}
|
65
|
+
resolve(new Uint8Array(data));
|
66
|
+
});
|
67
|
+
});
|
68
|
+
}
|
69
|
+
|
70
|
+
}
|
63
71
|
|
64
72
|
exports.NodeFileReaderFactory = NodeFileReaderFactory;
|
65
|
-
|
66
|
-
dom:
|
67
|
-
node:
|
73
|
+
const TEST_PDFS_PATH = {
|
74
|
+
dom: "../pdfs/",
|
75
|
+
node: "./test/pdfs/"
|
68
76
|
};
|
69
77
|
exports.TEST_PDFS_PATH = TEST_PDFS_PATH;
|
70
78
|
|
71
79
|
function buildGetDocumentParams(filename, options) {
|
72
|
-
|
80
|
+
const params = Object.create(null);
|
73
81
|
|
74
|
-
if (
|
82
|
+
if (_is_node.isNodeJS) {
|
75
83
|
params.url = TEST_PDFS_PATH.node + filename;
|
76
84
|
} else {
|
77
85
|
params.url = new URL(TEST_PDFS_PATH.dom + filename, window.location).href;
|
78
86
|
}
|
79
87
|
|
80
|
-
for (
|
88
|
+
for (const option in options) {
|
81
89
|
params[option] = options[option];
|
82
90
|
}
|
83
91
|
|
84
92
|
return params;
|
85
93
|
}
|
86
94
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
function NodeCanvasFactory() {
|
91
|
-
_classCallCheck(this, NodeCanvasFactory);
|
92
|
-
}
|
93
|
-
|
94
|
-
_createClass(NodeCanvasFactory, [{
|
95
|
-
key: "create",
|
96
|
-
value: function create(width, height) {
|
97
|
-
(0, _util.assert)(width > 0 && height > 0, 'Invalid canvas size');
|
95
|
+
class NodeCanvasFactory {
|
96
|
+
create(width, height) {
|
97
|
+
(0, _util.assert)(width > 0 && height > 0, "Invalid canvas size");
|
98
98
|
|
99
|
-
|
99
|
+
const Canvas = require("canvas");
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
}, {
|
108
|
-
key: "reset",
|
109
|
-
value: function reset(canvasAndContext, width, height) {
|
110
|
-
(0, _util.assert)(canvasAndContext.canvas, 'Canvas is not specified');
|
111
|
-
(0, _util.assert)(width > 0 && height > 0, 'Invalid canvas size');
|
112
|
-
canvasAndContext.canvas.width = width;
|
113
|
-
canvasAndContext.canvas.height = height;
|
114
|
-
}
|
115
|
-
}, {
|
116
|
-
key: "destroy",
|
117
|
-
value: function destroy(canvasAndContext) {
|
118
|
-
(0, _util.assert)(canvasAndContext.canvas, 'Canvas is not specified');
|
119
|
-
canvasAndContext.canvas.width = 0;
|
120
|
-
canvasAndContext.canvas.height = 0;
|
121
|
-
canvasAndContext.canvas = null;
|
122
|
-
canvasAndContext.context = null;
|
123
|
-
}
|
124
|
-
}]);
|
101
|
+
const canvas = Canvas.createCanvas(width, height);
|
102
|
+
return {
|
103
|
+
canvas,
|
104
|
+
context: canvas.getContext("2d")
|
105
|
+
};
|
106
|
+
}
|
125
107
|
|
126
|
-
|
127
|
-
|
108
|
+
reset(canvasAndContext, width, height) {
|
109
|
+
(0, _util.assert)(canvasAndContext.canvas, "Canvas is not specified");
|
110
|
+
(0, _util.assert)(width > 0 && height > 0, "Invalid canvas size");
|
111
|
+
canvasAndContext.canvas.width = width;
|
112
|
+
canvasAndContext.canvas.height = height;
|
113
|
+
}
|
128
114
|
|
129
|
-
|
115
|
+
destroy(canvasAndContext) {
|
116
|
+
(0, _util.assert)(canvasAndContext.canvas, "Canvas is not specified");
|
117
|
+
canvasAndContext.canvas.width = 0;
|
118
|
+
canvasAndContext.canvas.height = 0;
|
119
|
+
canvasAndContext.canvas = null;
|
120
|
+
canvasAndContext.context = null;
|
121
|
+
}
|
130
122
|
|
131
|
-
|
132
|
-
/*#__PURE__*/
|
133
|
-
function () {
|
134
|
-
function NodeCMapReaderFactory(_ref) {
|
135
|
-
var _ref$baseUrl = _ref.baseUrl,
|
136
|
-
baseUrl = _ref$baseUrl === void 0 ? null : _ref$baseUrl,
|
137
|
-
_ref$isCompressed = _ref.isCompressed,
|
138
|
-
isCompressed = _ref$isCompressed === void 0 ? false : _ref$isCompressed;
|
123
|
+
}
|
139
124
|
|
140
|
-
|
125
|
+
exports.NodeCanvasFactory = NodeCanvasFactory;
|
141
126
|
|
127
|
+
class NodeCMapReaderFactory {
|
128
|
+
constructor({
|
129
|
+
baseUrl = null,
|
130
|
+
isCompressed = false
|
131
|
+
}) {
|
142
132
|
this.baseUrl = baseUrl;
|
143
133
|
this.isCompressed = isCompressed;
|
144
134
|
}
|
145
135
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
if (!this.baseUrl) {
|
154
|
-
return Promise.reject(new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.'));
|
155
|
-
}
|
156
|
-
|
157
|
-
if (!name) {
|
158
|
-
return Promise.reject(new Error('CMap name must be specified.'));
|
159
|
-
}
|
136
|
+
async fetch({
|
137
|
+
name
|
138
|
+
}) {
|
139
|
+
if (!this.baseUrl) {
|
140
|
+
throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
|
141
|
+
}
|
160
142
|
|
161
|
-
|
162
|
-
|
143
|
+
if (!name) {
|
144
|
+
throw new Error("CMap name must be specified.");
|
145
|
+
}
|
163
146
|
|
164
|
-
|
147
|
+
const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
|
148
|
+
const compressionType = this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE;
|
149
|
+
return new Promise((resolve, reject) => {
|
150
|
+
const fs = require("fs");
|
165
151
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
152
|
+
fs.readFile(url, (error, data) => {
|
153
|
+
if (error || !data) {
|
154
|
+
reject(new Error(error));
|
155
|
+
return;
|
156
|
+
}
|
171
157
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
});
|
158
|
+
resolve({
|
159
|
+
cMapData: new Uint8Array(data),
|
160
|
+
compressionType
|
176
161
|
});
|
177
162
|
});
|
178
|
-
}
|
179
|
-
|
163
|
+
}).catch(reason => {
|
164
|
+
throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}` + `CMap at: ${url}`);
|
165
|
+
});
|
166
|
+
}
|
180
167
|
|
181
|
-
|
182
|
-
}();
|
168
|
+
}
|
183
169
|
|
184
170
|
exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
|
185
171
|
|
186
|
-
|
187
|
-
|
188
|
-
function () {
|
189
|
-
function XRefMock(array) {
|
190
|
-
_classCallCheck(this, XRefMock);
|
191
|
-
|
172
|
+
class XRefMock {
|
173
|
+
constructor(array) {
|
192
174
|
this._map = Object.create(null);
|
193
175
|
|
194
|
-
for (
|
195
|
-
|
176
|
+
for (const key in array) {
|
177
|
+
const obj = array[key];
|
196
178
|
this._map[obj.ref.toString()] = obj.data;
|
197
179
|
}
|
198
180
|
}
|
199
181
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
return this._map[ref.toString()];
|
204
|
-
}
|
205
|
-
}, {
|
206
|
-
key: "fetchAsync",
|
207
|
-
value: function fetchAsync(ref) {
|
208
|
-
return Promise.resolve(this.fetch(ref));
|
209
|
-
}
|
210
|
-
}, {
|
211
|
-
key: "fetchIfRef",
|
212
|
-
value: function fetchIfRef(obj) {
|
213
|
-
if (!(0, _primitives.isRef)(obj)) {
|
214
|
-
return obj;
|
215
|
-
}
|
182
|
+
fetch(ref) {
|
183
|
+
return this._map[ref.toString()];
|
184
|
+
}
|
216
185
|
|
217
|
-
|
218
|
-
|
219
|
-
}
|
220
|
-
|
221
|
-
|
222
|
-
|
186
|
+
fetchAsync(ref) {
|
187
|
+
return Promise.resolve(this.fetch(ref));
|
188
|
+
}
|
189
|
+
|
190
|
+
fetchIfRef(obj) {
|
191
|
+
if (!(0, _primitives.isRef)(obj)) {
|
192
|
+
return obj;
|
223
193
|
}
|
224
|
-
}]);
|
225
194
|
|
226
|
-
|
227
|
-
}
|
195
|
+
return this.fetch(obj);
|
196
|
+
}
|
197
|
+
|
198
|
+
fetchIfRefAsync(obj) {
|
199
|
+
return Promise.resolve(this.fetchIfRef(obj));
|
200
|
+
}
|
201
|
+
|
202
|
+
}
|
203
|
+
|
204
|
+
exports.XRefMock = XRefMock;
|
205
|
+
|
206
|
+
function createIdFactory(pageIndex) {
|
207
|
+
const page = new _document.Page({
|
208
|
+
pdfManager: {
|
209
|
+
get docId() {
|
210
|
+
return "d0";
|
211
|
+
}
|
228
212
|
|
229
|
-
|
213
|
+
},
|
214
|
+
pageIndex
|
215
|
+
});
|
216
|
+
return page.idFactory;
|
217
|
+
}
|
@@ -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
|
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.
|
@@ -19,13 +19,13 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
|
-
var TestReporter = function
|
24
|
+
var TestReporter = function (browser) {
|
25
25
|
function send(action, json, cb) {
|
26
26
|
var r = new XMLHttpRequest();
|
27
|
-
r.open(
|
28
|
-
r.setRequestHeader(
|
27
|
+
r.open("POST", action, true);
|
28
|
+
r.setRequestHeader("Content-Type", "application/json");
|
29
29
|
|
30
30
|
r.onreadystatechange = function sendTaskResultOnreadystatechange(e) {
|
31
31
|
if (r.readyState === 4) {
|
@@ -39,31 +39,31 @@ var TestReporter = function TestReporter(browser, appPath) {
|
|
39
39
|
}
|
40
40
|
};
|
41
41
|
|
42
|
-
json
|
42
|
+
json.browser = browser;
|
43
43
|
r.send(JSON.stringify(json));
|
44
44
|
}
|
45
45
|
|
46
46
|
function sendInfo(message) {
|
47
|
-
send(
|
48
|
-
message
|
47
|
+
send("/info", {
|
48
|
+
message
|
49
49
|
});
|
50
50
|
}
|
51
51
|
|
52
52
|
function sendResult(status, description, error) {
|
53
53
|
var message = {
|
54
|
-
status
|
55
|
-
description
|
54
|
+
status,
|
55
|
+
description
|
56
56
|
};
|
57
57
|
|
58
|
-
if (typeof error !==
|
59
|
-
message
|
58
|
+
if (typeof error !== "undefined") {
|
59
|
+
message.error = error;
|
60
60
|
}
|
61
61
|
|
62
|
-
send(
|
62
|
+
send("/submit_task_results", message);
|
63
63
|
}
|
64
64
|
|
65
65
|
function sendQuitRequest() {
|
66
|
-
send(
|
66
|
+
send(`/tellMeToQuit?browser=${escape(browser)}`, {});
|
67
67
|
}
|
68
68
|
|
69
69
|
this.now = function () {
|
@@ -72,7 +72,7 @@ var TestReporter = function TestReporter(browser, appPath) {
|
|
72
72
|
|
73
73
|
this.jasmineStarted = function (suiteInfo) {
|
74
74
|
this.runnerStartTime = this.now();
|
75
|
-
sendInfo(
|
75
|
+
sendInfo("Started tests for " + browser + ".");
|
76
76
|
};
|
77
77
|
|
78
78
|
this.suiteStarted = function (result) {};
|
@@ -81,16 +81,16 @@ var TestReporter = function TestReporter(browser, appPath) {
|
|
81
81
|
|
82
82
|
this.specDone = function (result) {
|
83
83
|
if (result.failedExpectations.length === 0) {
|
84
|
-
sendResult(
|
84
|
+
sendResult("TEST-PASSED", result.description);
|
85
85
|
} else {
|
86
|
-
var failedMessages =
|
86
|
+
var failedMessages = "";
|
87
87
|
var items = result.failedExpectations;
|
88
88
|
|
89
89
|
for (var i = 0, ii = items.length; i < ii; i++) {
|
90
|
-
failedMessages += items[i].message +
|
90
|
+
failedMessages += items[i].message + " ";
|
91
91
|
}
|
92
92
|
|
93
|
-
sendResult(
|
93
|
+
sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
|
94
94
|
}
|
95
95
|
};
|
96
96
|
|
@@ -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
|
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,84 +21,84 @@
|
|
21
21
|
*/
|
22
22
|
"use strict";
|
23
23
|
|
24
|
-
var _fonts = require("../../core/fonts");
|
24
|
+
var _fonts = require("../../core/fonts.js");
|
25
25
|
|
26
|
-
var _stream = require("../../core/stream");
|
26
|
+
var _stream = require("../../core/stream.js");
|
27
27
|
|
28
|
-
var _type1_parser = require("../../core/type1_parser");
|
28
|
+
var _type1_parser = require("../../core/type1_parser.js");
|
29
29
|
|
30
|
-
describe(
|
31
|
-
it(
|
32
|
-
var stream = new _stream.StringStream(
|
30
|
+
describe("Type1Parser", function () {
|
31
|
+
it("splits tokens", function () {
|
32
|
+
var stream = new _stream.StringStream("/BlueValues[-17 0]noaccess def");
|
33
33
|
var parser = new _type1_parser.Type1Parser(stream, false, _fonts.SEAC_ANALYSIS_ENABLED);
|
34
|
-
expect(parser.getToken()).toEqual(
|
35
|
-
expect(parser.getToken()).toEqual(
|
36
|
-
expect(parser.getToken()).toEqual(
|
37
|
-
expect(parser.getToken()).toEqual(
|
38
|
-
expect(parser.getToken()).toEqual(
|
39
|
-
expect(parser.getToken()).toEqual(
|
40
|
-
expect(parser.getToken()).toEqual(
|
41
|
-
expect(parser.getToken()).toEqual(
|
34
|
+
expect(parser.getToken()).toEqual("/");
|
35
|
+
expect(parser.getToken()).toEqual("BlueValues");
|
36
|
+
expect(parser.getToken()).toEqual("[");
|
37
|
+
expect(parser.getToken()).toEqual("-17");
|
38
|
+
expect(parser.getToken()).toEqual("0");
|
39
|
+
expect(parser.getToken()).toEqual("]");
|
40
|
+
expect(parser.getToken()).toEqual("noaccess");
|
41
|
+
expect(parser.getToken()).toEqual("def");
|
42
42
|
expect(parser.getToken()).toEqual(null);
|
43
43
|
});
|
44
|
-
it(
|
45
|
-
var stream = new _stream.StringStream(
|
44
|
+
it("handles glued tokens", function () {
|
45
|
+
var stream = new _stream.StringStream("dup/CharStrings");
|
46
46
|
var parser = new _type1_parser.Type1Parser(stream, false, _fonts.SEAC_ANALYSIS_ENABLED);
|
47
|
-
expect(parser.getToken()).toEqual(
|
48
|
-
expect(parser.getToken()).toEqual(
|
49
|
-
expect(parser.getToken()).toEqual(
|
47
|
+
expect(parser.getToken()).toEqual("dup");
|
48
|
+
expect(parser.getToken()).toEqual("/");
|
49
|
+
expect(parser.getToken()).toEqual("CharStrings");
|
50
50
|
});
|
51
|
-
it(
|
52
|
-
var stream = new _stream.StringStream(
|
51
|
+
it("ignores whitespace", function () {
|
52
|
+
var stream = new _stream.StringStream("\nab c\t");
|
53
53
|
var parser = new _type1_parser.Type1Parser(stream, false, _fonts.SEAC_ANALYSIS_ENABLED);
|
54
|
-
expect(parser.getToken()).toEqual(
|
55
|
-
expect(parser.getToken()).toEqual(
|
54
|
+
expect(parser.getToken()).toEqual("ab");
|
55
|
+
expect(parser.getToken()).toEqual("c");
|
56
56
|
});
|
57
|
-
it(
|
58
|
-
var stream = new _stream.StringStream(
|
57
|
+
it("parses numbers", function () {
|
58
|
+
var stream = new _stream.StringStream("123");
|
59
59
|
var parser = new _type1_parser.Type1Parser(stream, false, _fonts.SEAC_ANALYSIS_ENABLED);
|
60
60
|
expect(parser.readNumber()).toEqual(123);
|
61
61
|
});
|
62
|
-
it(
|
63
|
-
var stream = new _stream.StringStream(
|
62
|
+
it("parses booleans", function () {
|
63
|
+
var stream = new _stream.StringStream("true false");
|
64
64
|
var parser = new _type1_parser.Type1Parser(stream, false, _fonts.SEAC_ANALYSIS_ENABLED);
|
65
65
|
expect(parser.readBoolean()).toEqual(1);
|
66
66
|
expect(parser.readBoolean()).toEqual(0);
|
67
67
|
});
|
68
|
-
it(
|
69
|
-
var stream = new _stream.StringStream(
|
68
|
+
it("parses number arrays", function () {
|
69
|
+
var stream = new _stream.StringStream("[1 2]");
|
70
70
|
var parser = new _type1_parser.Type1Parser(stream, false, _fonts.SEAC_ANALYSIS_ENABLED);
|
71
71
|
expect(parser.readNumberArray()).toEqual([1, 2]);
|
72
|
-
stream = new _stream.StringStream(
|
72
|
+
stream = new _stream.StringStream("[ 1 2 ]");
|
73
73
|
parser = new _type1_parser.Type1Parser(stream, false, _fonts.SEAC_ANALYSIS_ENABLED);
|
74
74
|
expect(parser.readNumberArray()).toEqual([1, 2]);
|
75
75
|
});
|
76
|
-
it(
|
77
|
-
var stream = new _stream.StringStream(
|
76
|
+
it("skips comments", function () {
|
77
|
+
var stream = new _stream.StringStream("%!PS-AdobeFont-1.0: CMSY10 003.002\n" + "%%Title: CMSY10\n" + "%Version: 003.002\n" + "FontDirectory");
|
78
78
|
var parser = new _type1_parser.Type1Parser(stream, false, _fonts.SEAC_ANALYSIS_ENABLED);
|
79
|
-
expect(parser.getToken()).toEqual(
|
79
|
+
expect(parser.getToken()).toEqual("FontDirectory");
|
80
80
|
});
|
81
|
-
it(
|
82
|
-
var stream = new _stream.StringStream(
|
81
|
+
it("parses font program", function () {
|
82
|
+
var stream = new _stream.StringStream("/ExpansionFactor 99\n" + "/Subrs 1 array\n" + "dup 0 1 RD x noaccess put\n" + "end\n" + "/CharStrings 46 dict dup begin\n" + "/.notdef 1 RD x ND\n" + "end");
|
83
83
|
var parser = new _type1_parser.Type1Parser(stream, false, _fonts.SEAC_ANALYSIS_ENABLED);
|
84
|
-
var program = parser.extractFontProgram();
|
84
|
+
var program = parser.extractFontProgram({});
|
85
85
|
expect(program.charstrings.length).toEqual(1);
|
86
86
|
expect(program.properties.privateData.ExpansionFactor).toEqual(99);
|
87
87
|
});
|
88
|
-
it(
|
89
|
-
var stream = new _stream.StringStream(
|
88
|
+
it("parses font header font matrix", function () {
|
89
|
+
var stream = new _stream.StringStream("/FontMatrix [0.001 0 0 0.001 0 0 ]readonly def\n");
|
90
90
|
var parser = new _type1_parser.Type1Parser(stream, false, _fonts.SEAC_ANALYSIS_ENABLED);
|
91
91
|
var props = {};
|
92
92
|
parser.extractFontHeader(props);
|
93
93
|
expect(props.fontMatrix).toEqual([0.001, 0, 0, 0.001, 0, 0]);
|
94
94
|
});
|
95
|
-
it(
|
96
|
-
var stream = new _stream.StringStream(
|
95
|
+
it("parses font header encoding", function () {
|
96
|
+
var stream = new _stream.StringStream("/Encoding 256 array\n" + "0 1 255 {1 index exch /.notdef put} for\n" + "dup 33 /arrowright put\n" + "readonly def\n");
|
97
97
|
var parser = new _type1_parser.Type1Parser(stream, false, _fonts.SEAC_ANALYSIS_ENABLED);
|
98
98
|
var props = {
|
99
99
|
overridableEncoding: true
|
100
100
|
};
|
101
101
|
parser.extractFontHeader(props);
|
102
|
-
expect(props.builtInEncoding[33]).toEqual(
|
102
|
+
expect(props.builtInEncoding[33]).toEqual("arrowright");
|
103
103
|
});
|
104
104
|
});
|