pdfjs-dist 2.6.347 → 2.7.570
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/README.md +3 -3
- package/bower.json +1 -1
- package/build/pdf.js +2050 -1087
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +18219 -10436
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/es5/build/pdf.d.ts +1 -0
- package/es5/build/pdf.js +6623 -6654
- package/es5/build/pdf.js.map +1 -1
- package/es5/build/pdf.min.js +1 -1
- package/es5/build/pdf.worker.js +20815 -13888
- package/es5/build/pdf.worker.js.map +1 -1
- package/es5/build/pdf.worker.min.js +1 -1
- package/es5/image_decoders/pdf.image_decoders.js +3817 -4946
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -1
- package/es5/image_decoders/pdf.image_decoders.min.js +1 -1
- package/es5/web/pdf_viewer.css +18 -15
- package/es5/web/pdf_viewer.js +1094 -514
- package/es5/web/pdf_viewer.js.map +1 -1
- package/image_decoders/pdf.image_decoders.js +774 -168
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/core/annotation.js +556 -108
- package/lib/core/cff_parser.js +7 -1
- package/lib/core/charsets.js +1 -1
- package/lib/core/cmap.js +20 -1
- package/lib/core/core_utils.js +162 -3
- package/lib/core/crypto.js +1 -1
- package/lib/core/default_appearance.js +132 -0
- package/lib/core/document.js +115 -9
- package/lib/core/encodings.js +1 -1
- package/lib/core/evaluator.js +168 -74
- package/lib/core/fonts.js +97 -11
- package/lib/core/function.js +5 -10
- package/lib/core/glyphlist.js +11 -4529
- package/lib/core/image_utils.js +30 -1
- package/lib/core/jpg.js +1 -1
- package/lib/core/jpx.js +5 -5
- package/lib/core/murmurhash3.js +1 -1
- package/lib/core/obj.js +123 -39
- package/lib/core/pattern.js +4 -4
- package/lib/core/primitives.js +24 -5
- package/lib/core/standard_fonts.js +1 -1
- package/lib/core/stream.js +5 -1
- package/lib/core/unicode.js +15 -1387
- package/lib/core/worker.js +58 -17
- package/lib/core/writer.js +68 -4
- package/lib/display/annotation_layer.js +712 -119
- package/lib/display/annotation_storage.js +21 -4
- package/lib/display/api.js +88 -18
- package/lib/display/canvas.js +414 -375
- package/lib/display/display_utils.js +11 -4
- package/lib/display/fetch_stream.js +3 -3
- package/lib/display/font_loader.js +2 -3
- package/lib/display/metadata.js +54 -20
- package/lib/display/node_stream.js +1 -1
- package/lib/display/optional_content_config.js +1 -1
- package/lib/display/pattern_helper.js +109 -113
- package/lib/display/svg.js +5 -5
- package/lib/display/text_layer.js +54 -54
- package/lib/display/transport_stream.js +4 -4
- package/lib/display/webgl.js +65 -68
- package/lib/examples/node/domstubs.js +9 -4
- package/lib/pdf.js +2 -2
- package/lib/pdf.sandbox.js +311 -0
- package/lib/pdf.worker.js +2 -2
- package/lib/shared/scripting_utils.js +84 -0
- package/lib/shared/util.js +129 -14
- package/lib/{display → shared}/xml_parser.js +112 -4
- package/lib/test/unit/annotation_spec.js +831 -109
- package/lib/test/unit/annotation_storage_spec.js +28 -10
- package/lib/test/unit/api_spec.js +190 -160
- package/lib/test/unit/bidi_spec.js +6 -6
- package/lib/test/unit/cff_parser_spec.js +73 -73
- package/lib/test/unit/clitests_helper.js +2 -0
- package/lib/test/unit/cmap_spec.js +48 -74
- package/lib/test/unit/core_utils_spec.js +34 -0
- package/lib/test/unit/crypto_spec.js +162 -199
- package/lib/test/unit/custom_spec.js +7 -18
- package/lib/test/unit/default_appearance_spec.js +54 -0
- package/lib/test/unit/display_svg_spec.js +24 -19
- package/lib/test/unit/display_utils_spec.js +1 -1
- package/lib/test/unit/document_spec.js +187 -20
- package/lib/test/unit/evaluator_spec.js +30 -30
- package/lib/test/unit/function_spec.js +165 -165
- package/lib/test/unit/jasmine-boot.js +52 -53
- package/lib/test/unit/metadata_spec.js +2 -2
- package/lib/test/unit/murmurhash3_spec.js +29 -16
- package/lib/test/unit/network_spec.js +21 -21
- package/lib/test/unit/pdf_find_controller_spec.js +131 -69
- package/lib/test/unit/pdf_find_utils_spec.js +10 -10
- package/lib/test/unit/scripting_spec.js +1104 -0
- package/lib/test/unit/stream_spec.js +8 -8
- package/lib/test/unit/test_utils.js +16 -19
- package/lib/test/unit/testreporter.js +11 -4
- package/lib/test/unit/type1_parser_spec.js +23 -23
- package/lib/test/unit/ui_utils_spec.js +78 -35
- package/lib/test/unit/unicode_spec.js +7 -7
- package/lib/test/unit/util_spec.js +26 -3
- package/lib/test/unit/writer_spec.js +16 -1
- package/lib/test/unit/xml_spec.js +117 -0
- package/lib/web/annotation_layer_builder.js +18 -6
- package/lib/web/app.js +579 -161
- package/lib/web/app_options.js +14 -0
- package/lib/web/base_tree_viewer.js +50 -0
- package/lib/web/base_viewer.js +350 -14
- package/lib/web/chromecom.js +9 -1
- package/lib/web/debugger.js +1 -2
- package/lib/web/download_manager.js +0 -15
- package/lib/web/firefox_print_service.js +6 -4
- package/lib/web/firefoxcom.js +84 -69
- package/lib/web/generic_scripting.js +55 -0
- package/lib/web/genericcom.js +9 -1
- package/lib/web/grab_to_pan.js +1 -1
- package/lib/web/interfaces.js +9 -3
- package/lib/web/pdf_attachment_viewer.js +1 -3
- package/lib/web/pdf_cursor_tools.js +20 -13
- package/lib/web/pdf_document_properties.js +48 -61
- package/lib/web/pdf_find_bar.js +1 -3
- package/lib/web/pdf_find_controller.js +58 -12
- package/lib/web/pdf_history.js +43 -21
- package/lib/web/pdf_layer_viewer.js +1 -9
- package/lib/web/pdf_link_service.js +108 -78
- package/lib/web/pdf_outline_viewer.js +166 -10
- package/lib/web/pdf_page_view.js +14 -14
- package/lib/web/pdf_presentation_mode.js +21 -31
- package/lib/web/pdf_rendering_queue.js +8 -1
- package/lib/web/pdf_sidebar.js +62 -107
- package/lib/web/pdf_sidebar_resizer.js +11 -21
- package/lib/web/pdf_single_page_viewer.js +8 -0
- package/lib/web/pdf_thumbnail_view.js +26 -26
- package/lib/web/pdf_thumbnail_viewer.js +13 -2
- package/lib/web/pdf_viewer.component.js +2 -2
- package/lib/web/pdf_viewer.js +3 -1
- package/lib/web/preferences.js +33 -44
- package/lib/web/text_layer_builder.js +2 -9
- package/lib/web/ui_utils.js +78 -46
- package/lib/web/viewer_compatibility.js +1 -2
- package/package.json +4 -1
- package/types/display/annotation_layer.d.ts +18 -3
- package/types/display/api.d.ts +110 -54
- package/types/display/canvas.d.ts +1 -1
- package/types/display/display_utils.d.ts +96 -95
- package/types/display/fetch_stream.d.ts +2 -2
- package/types/display/metadata.d.ts +4 -0
- package/types/display/pattern_helper.d.ts +1 -1
- package/types/display/text_layer.d.ts +7 -7
- package/types/display/transport_stream.d.ts +1 -1
- package/types/shared/scripting_utils.d.ts +12 -0
- package/types/shared/util.d.ts +281 -250
- package/types/shared/xml_parser.d.ts +64 -0
- package/web/pdf_viewer.css +18 -15
- package/web/pdf_viewer.js +809 -408
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +1 -1
- package/types/display/xml_parser.d.ts +0 -35
@@ -29,17 +29,15 @@ var _util = require("../../shared/util.js");
|
|
29
29
|
|
30
30
|
describe("crypto", function () {
|
31
31
|
function hex2binary(s) {
|
32
|
-
|
32
|
+
const digits = "0123456789ABCDEF";
|
33
33
|
s = s.toUpperCase();
|
34
|
-
|
35
|
-
|
36
|
-
j;
|
37
|
-
var result = new Uint8Array(n);
|
34
|
+
const n = s.length >> 1;
|
35
|
+
const result = new Uint8Array(n);
|
38
36
|
|
39
|
-
for (i = 0, j = 0; i < n; ++i) {
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
for (let i = 0, j = 0; i < n; ++i) {
|
38
|
+
const d1 = s.charAt(j++);
|
39
|
+
const d2 = s.charAt(j++);
|
40
|
+
const value = digits.indexOf(d1) << 4 | digits.indexOf(d2);
|
43
41
|
result[i] = value;
|
44
42
|
}
|
45
43
|
|
@@ -48,189 +46,167 @@ describe("crypto", function () {
|
|
48
46
|
|
49
47
|
describe("calculateMD5", function () {
|
50
48
|
it("should pass RFC 1321 test #1", function () {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
expected = hex2binary("d41d8cd98f00b204e9800998ecf8427e");
|
49
|
+
const input = (0, _util.stringToBytes)("");
|
50
|
+
const result = (0, _crypto.calculateMD5)(input, 0, input.length);
|
51
|
+
const expected = hex2binary("d41d8cd98f00b204e9800998ecf8427e");
|
55
52
|
expect(result).toEqual(expected);
|
56
53
|
});
|
57
54
|
it("should pass RFC 1321 test #2", function () {
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
expected = hex2binary("0cc175b9c0f1b6a831c399e269772661");
|
55
|
+
const input = (0, _util.stringToBytes)("a");
|
56
|
+
const result = (0, _crypto.calculateMD5)(input, 0, input.length);
|
57
|
+
const expected = hex2binary("0cc175b9c0f1b6a831c399e269772661");
|
62
58
|
expect(result).toEqual(expected);
|
63
59
|
});
|
64
60
|
it("should pass RFC 1321 test #3", function () {
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
expected = hex2binary("900150983cd24fb0d6963f7d28e17f72");
|
61
|
+
const input = (0, _util.stringToBytes)("abc");
|
62
|
+
const result = (0, _crypto.calculateMD5)(input, 0, input.length);
|
63
|
+
const expected = hex2binary("900150983cd24fb0d6963f7d28e17f72");
|
69
64
|
expect(result).toEqual(expected);
|
70
65
|
});
|
71
66
|
it("should pass RFC 1321 test #4", function () {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
expected = hex2binary("f96b697d7cb7938d525a2f31aaf161d0");
|
67
|
+
const input = (0, _util.stringToBytes)("message digest");
|
68
|
+
const result = (0, _crypto.calculateMD5)(input, 0, input.length);
|
69
|
+
const expected = hex2binary("f96b697d7cb7938d525a2f31aaf161d0");
|
76
70
|
expect(result).toEqual(expected);
|
77
71
|
});
|
78
72
|
it("should pass RFC 1321 test #5", function () {
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
expected = hex2binary("c3fcd3d76192e4007dfb496cca67e13b");
|
73
|
+
const input = (0, _util.stringToBytes)("abcdefghijklmnopqrstuvwxyz");
|
74
|
+
const result = (0, _crypto.calculateMD5)(input, 0, input.length);
|
75
|
+
const expected = hex2binary("c3fcd3d76192e4007dfb496cca67e13b");
|
83
76
|
expect(result).toEqual(expected);
|
84
77
|
});
|
85
78
|
it("should pass RFC 1321 test #6", function () {
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
expected = hex2binary("d174ab98d277d9f5a5611c2c9f419d9f");
|
79
|
+
const input = (0, _util.stringToBytes)("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
|
80
|
+
const result = (0, _crypto.calculateMD5)(input, 0, input.length);
|
81
|
+
const expected = hex2binary("d174ab98d277d9f5a5611c2c9f419d9f");
|
90
82
|
expect(result).toEqual(expected);
|
91
83
|
});
|
92
84
|
it("should pass RFC 1321 test #7", function () {
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
expected = hex2binary("57edf4a22be3c955ac49da2e2107b67a");
|
85
|
+
const input = (0, _util.stringToBytes)("123456789012345678901234567890123456789012345678" + "90123456789012345678901234567890");
|
86
|
+
const result = (0, _crypto.calculateMD5)(input, 0, input.length);
|
87
|
+
const expected = hex2binary("57edf4a22be3c955ac49da2e2107b67a");
|
97
88
|
expect(result).toEqual(expected);
|
98
89
|
});
|
99
90
|
});
|
100
91
|
describe("ARCFourCipher", function () {
|
101
92
|
it("should pass test #1", function () {
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
expected = hex2binary("75b7878099e0c596");
|
93
|
+
const key = hex2binary("0123456789abcdef");
|
94
|
+
const input = hex2binary("0123456789abcdef");
|
95
|
+
const cipher = new _crypto.ARCFourCipher(key);
|
96
|
+
const result = cipher.encryptBlock(input);
|
97
|
+
const expected = hex2binary("75b7878099e0c596");
|
108
98
|
expect(result).toEqual(expected);
|
109
99
|
});
|
110
100
|
it("should pass test #2", function () {
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
expected = hex2binary("7494c2e7104b0879");
|
101
|
+
const key = hex2binary("0123456789abcdef");
|
102
|
+
const input = hex2binary("0000000000000000");
|
103
|
+
const cipher = new _crypto.ARCFourCipher(key);
|
104
|
+
const result = cipher.encryptBlock(input);
|
105
|
+
const expected = hex2binary("7494c2e7104b0879");
|
117
106
|
expect(result).toEqual(expected);
|
118
107
|
});
|
119
108
|
it("should pass test #3", function () {
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
expected = hex2binary("de188941a3375d3a");
|
109
|
+
const key = hex2binary("0000000000000000");
|
110
|
+
const input = hex2binary("0000000000000000");
|
111
|
+
const cipher = new _crypto.ARCFourCipher(key);
|
112
|
+
const result = cipher.encryptBlock(input);
|
113
|
+
const expected = hex2binary("de188941a3375d3a");
|
126
114
|
expect(result).toEqual(expected);
|
127
115
|
});
|
128
116
|
it("should pass test #4", function () {
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
expected = hex2binary("d6a141a7ec3c38dfbd61");
|
117
|
+
const key = hex2binary("ef012345");
|
118
|
+
const input = hex2binary("00000000000000000000");
|
119
|
+
const cipher = new _crypto.ARCFourCipher(key);
|
120
|
+
const result = cipher.encryptBlock(input);
|
121
|
+
const expected = hex2binary("d6a141a7ec3c38dfbd61");
|
135
122
|
expect(result).toEqual(expected);
|
136
123
|
});
|
137
124
|
it("should pass test #5", function () {
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
expected = hex2binary("7595c3e6114a09780c4ad452338e1ffd9a1be9498f813d76" + "533449b6778dcad8c78a8d2ba9ac66085d0e53d59c26c2d1c490c1ebbe0ce66d1b6b" + "1b13b6b919b847c25a91447a95e75e4ef16779cde8bf0a95850e32af9689444fd377" + "108f98fdcbd4e726567500990bcc7e0ca3c4aaa304a387d20f3b8fbbcd42a1bd311d" + "7a4303dda5ab078896ae80c18b0af66dff319616eb784e495ad2ce90d7f772a81747" + "b65f62093b1e0db9e5ba532fafec47508323e671327df9444432cb7367cec82f5d44" + "c0d00b67d650a075cd4b70dedd77eb9b10231b6b5b741347396d62897421d43df9b4" + "2e446e358e9c11a9b2184ecbef0cd8e7a877ef968f1390ec9b3d35a5585cb009290e" + "2fcde7b5ec66d9084be44055a619d9dd7fc3166f9487f7cb272912426445998514c1" + "5d53a18c864ce3a2b7555793988126520eacf2e3066e230c91bee4dd5304f5fd0405" + "b35bd99c73135d3d9bc335ee049ef69b3867bf2d7bd1eaa595d8bfc0066ff8d31509" + "eb0c6caa006c807a623ef84c3d33c195d23ee320c40de0558157c822d4b8c569d849" + "aed59d4e0fd7f379586b4b7ff684ed6a189f7486d49b9c4bad9ba24b96abf924372c" + "8a8fffb10d55354900a77a3db5f205e1b99fcd8660863a159ad4abe40fa48934163d" + "dde542a6585540fd683cbfd8c00f12129a284deacc4cdefe58be7137541c047126c8" + "d49e2755ab181ab7e940b0c0");
|
125
|
+
const key = hex2binary("0123456789abcdef");
|
126
|
+
const input = hex2binary("010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "101010101010101010101");
|
127
|
+
const cipher = new _crypto.ARCFourCipher(key);
|
128
|
+
const result = cipher.encryptBlock(input);
|
129
|
+
const expected = hex2binary("7595c3e6114a09780c4ad452338e1ffd9a1be9498f813d76" + "533449b6778dcad8c78a8d2ba9ac66085d0e53d59c26c2d1c490c1ebbe0ce66d1b6b" + "1b13b6b919b847c25a91447a95e75e4ef16779cde8bf0a95850e32af9689444fd377" + "108f98fdcbd4e726567500990bcc7e0ca3c4aaa304a387d20f3b8fbbcd42a1bd311d" + "7a4303dda5ab078896ae80c18b0af66dff319616eb784e495ad2ce90d7f772a81747" + "b65f62093b1e0db9e5ba532fafec47508323e671327df9444432cb7367cec82f5d44" + "c0d00b67d650a075cd4b70dedd77eb9b10231b6b5b741347396d62897421d43df9b4" + "2e446e358e9c11a9b2184ecbef0cd8e7a877ef968f1390ec9b3d35a5585cb009290e" + "2fcde7b5ec66d9084be44055a619d9dd7fc3166f9487f7cb272912426445998514c1" + "5d53a18c864ce3a2b7555793988126520eacf2e3066e230c91bee4dd5304f5fd0405" + "b35bd99c73135d3d9bc335ee049ef69b3867bf2d7bd1eaa595d8bfc0066ff8d31509" + "eb0c6caa006c807a623ef84c3d33c195d23ee320c40de0558157c822d4b8c569d849" + "aed59d4e0fd7f379586b4b7ff684ed6a189f7486d49b9c4bad9ba24b96abf924372c" + "8a8fffb10d55354900a77a3db5f205e1b99fcd8660863a159ad4abe40fa48934163d" + "dde542a6585540fd683cbfd8c00f12129a284deacc4cdefe58be7137541c047126c8" + "d49e2755ab181ab7e940b0c0");
|
144
130
|
expect(result).toEqual(expected);
|
145
131
|
});
|
146
132
|
it("should pass test #6", function () {
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
expected = hex2binary("f69c5806bd6ce84626bcbefb9474650aad1f7909b0f64d5f" + "58a503a258b7ed22eb0ea64930d3a056a55742fcce141d485f8aa836dea18df42c53" + "80805ad0c61a5d6f58f41040b24b7d1a693856ed0d4398e7aee3bf0e2a2ca8f7");
|
133
|
+
const key = hex2binary("fb029e3031323334");
|
134
|
+
const input = hex2binary("aaaa0300000008004500004e661a00008011be640a0001220af" + "fffff00890089003a000080a601100001000000000000204543454a4548454346434" + "550464545494546464343414341434143414341414100002000011bd0b604");
|
135
|
+
const cipher = new _crypto.ARCFourCipher(key);
|
136
|
+
const result = cipher.encryptBlock(input);
|
137
|
+
const expected = hex2binary("f69c5806bd6ce84626bcbefb9474650aad1f7909b0f64d5f" + "58a503a258b7ed22eb0ea64930d3a056a55742fcce141d485f8aa836dea18df42c53" + "80805ad0c61a5d6f58f41040b24b7d1a693856ed0d4398e7aee3bf0e2a2ca8f7");
|
153
138
|
expect(result).toEqual(expected);
|
154
139
|
});
|
155
140
|
it("should pass test #7", function () {
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
expected = hex2binary("66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf");
|
141
|
+
const key = hex2binary("0123456789abcdef");
|
142
|
+
const input = hex2binary("123456789abcdef0123456789abcdef0123456789abcdef012345678");
|
143
|
+
const cipher = new _crypto.ARCFourCipher(key);
|
144
|
+
const result = cipher.encryptBlock(input);
|
145
|
+
const expected = hex2binary("66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf");
|
162
146
|
expect(result).toEqual(expected);
|
163
147
|
});
|
164
148
|
});
|
165
149
|
describe("calculateSHA256", function () {
|
166
150
|
it("should properly hash abc", function () {
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
expected = hex2binary("BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD");
|
151
|
+
const input = (0, _util.stringToBytes)("abc");
|
152
|
+
const result = (0, _crypto.calculateSHA256)(input, 0, input.length);
|
153
|
+
const expected = hex2binary("BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD");
|
171
154
|
expect(result).toEqual(expected);
|
172
155
|
});
|
173
156
|
it("should properly hash a multiblock input", function () {
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
expected = hex2binary("248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167F6ECEDD419DB06C1");
|
157
|
+
const input = (0, _util.stringToBytes)("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
|
158
|
+
const result = (0, _crypto.calculateSHA256)(input, 0, input.length);
|
159
|
+
const expected = hex2binary("248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167F6ECEDD419DB06C1");
|
178
160
|
expect(result).toEqual(expected);
|
179
161
|
});
|
180
162
|
});
|
181
163
|
describe("calculateSHA384", function () {
|
182
164
|
it("should properly hash abc", function () {
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
expected = hex2binary("CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED163" + "1A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7");
|
165
|
+
const input = (0, _util.stringToBytes)("abc");
|
166
|
+
const result = (0, _crypto.calculateSHA384)(input, 0, input.length);
|
167
|
+
const expected = hex2binary("CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED163" + "1A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7");
|
187
168
|
expect(result).toEqual(expected);
|
188
169
|
});
|
189
170
|
it("should properly hash a multiblock input", function () {
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
expected = hex2binary("09330C33F71147E83D192FC782CD1B4753111B173B3B05D2" + "2FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039");
|
171
|
+
const input = (0, _util.stringToBytes)("abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" + "ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu");
|
172
|
+
const result = (0, _crypto.calculateSHA384)(input, 0, input.length);
|
173
|
+
const expected = hex2binary("09330C33F71147E83D192FC782CD1B4753111B173B3B05D2" + "2FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039");
|
194
174
|
expect(result).toEqual(expected);
|
195
175
|
});
|
196
176
|
});
|
197
177
|
describe("calculateSHA512", function () {
|
198
178
|
it("should properly hash abc", function () {
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
expected = hex2binary("DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA2" + "0A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD" + "454D4423643CE80E2A9AC94FA54CA49F");
|
179
|
+
const input = (0, _util.stringToBytes)("abc");
|
180
|
+
const result = (0, _crypto.calculateSHA512)(input, 0, input.length);
|
181
|
+
const expected = hex2binary("DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA2" + "0A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD" + "454D4423643CE80E2A9AC94FA54CA49F");
|
203
182
|
expect(result).toEqual(expected);
|
204
183
|
});
|
205
184
|
it("should properly hash a multiblock input", function () {
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
expected = hex2binary("8E959B75DAE313DA8CF4F72814FC143F8F7779C6EB9F7FA1" + "7299AEADB6889018501D289E4900F7E4331B99DEC4B5433A" + "C7D329EEB6DD26545E96E55B874BE909");
|
185
|
+
const input = (0, _util.stringToBytes)("abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" + "ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu");
|
186
|
+
const result = (0, _crypto.calculateSHA512)(input, 0, input.length);
|
187
|
+
const expected = hex2binary("8E959B75DAE313DA8CF4F72814FC143F8F7779C6EB9F7FA1" + "7299AEADB6889018501D289E4900F7E4331B99DEC4B5433A" + "C7D329EEB6DD26545E96E55B874BE909");
|
210
188
|
expect(result).toEqual(expected);
|
211
189
|
});
|
212
190
|
});
|
213
191
|
describe("AES128", function () {
|
214
192
|
describe("Encryption", function () {
|
215
193
|
it("should be able to encrypt a block", function () {
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
expected = hex2binary("69c4e0d86a7b0430d8cdb78070b4c55a");
|
194
|
+
const input = hex2binary("00112233445566778899aabbccddeeff");
|
195
|
+
const key = hex2binary("000102030405060708090a0b0c0d0e0f");
|
196
|
+
const iv = hex2binary("00000000000000000000000000000000");
|
197
|
+
const cipher = new _crypto.AES128Cipher(key);
|
198
|
+
const result = cipher.encrypt(input, iv);
|
199
|
+
const expected = hex2binary("69c4e0d86a7b0430d8cdb78070b4c55a");
|
223
200
|
expect(result).toEqual(expected);
|
224
201
|
});
|
225
202
|
});
|
226
203
|
describe("Decryption", function () {
|
227
204
|
it("should be able to decrypt a block with IV in stream", function () {
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
expected = hex2binary("00112233445566778899aabbccddeeff");
|
205
|
+
const input = hex2binary("0000000000000000000000000000000069c4e0d86a7b0430d" + "8cdb78070b4c55a");
|
206
|
+
const key = hex2binary("000102030405060708090a0b0c0d0e0f");
|
207
|
+
const cipher = new _crypto.AES128Cipher(key);
|
208
|
+
const result = cipher.decryptBlock(input);
|
209
|
+
const expected = hex2binary("00112233445566778899aabbccddeeff");
|
234
210
|
expect(result).toEqual(expected);
|
235
211
|
});
|
236
212
|
});
|
@@ -238,130 +214,117 @@ describe("crypto", function () {
|
|
238
214
|
describe("AES256", function () {
|
239
215
|
describe("Encryption", function () {
|
240
216
|
it("should be able to encrypt a block", function () {
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
expected = hex2binary("8ea2b7ca516745bfeafc49904b496089");
|
217
|
+
const input = hex2binary("00112233445566778899aabbccddeeff");
|
218
|
+
const key = hex2binary("000102030405060708090a0b0c0d0e0f101112131415161718" + "191a1b1c1d1e1f");
|
219
|
+
const iv = hex2binary("00000000000000000000000000000000");
|
220
|
+
const cipher = new _crypto.AES256Cipher(key);
|
221
|
+
const result = cipher.encrypt(input, iv);
|
222
|
+
const expected = hex2binary("8ea2b7ca516745bfeafc49904b496089");
|
248
223
|
expect(result).toEqual(expected);
|
249
224
|
});
|
250
225
|
});
|
251
226
|
describe("Decryption", function () {
|
252
227
|
it("should be able to decrypt a block with specified iv", function () {
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
expected = hex2binary("00112233445566778899aabbccddeeff");
|
228
|
+
const input = hex2binary("8ea2b7ca516745bfeafc49904b496089");
|
229
|
+
const key = hex2binary("000102030405060708090a0b0c0d0e0f101112131415161718" + "191a1b1c1d1e1f");
|
230
|
+
const iv = hex2binary("00000000000000000000000000000000");
|
231
|
+
const cipher = new _crypto.AES256Cipher(key);
|
232
|
+
const result = cipher.decryptBlock(input, false, iv);
|
233
|
+
const expected = hex2binary("00112233445566778899aabbccddeeff");
|
260
234
|
expect(result).toEqual(expected);
|
261
235
|
});
|
262
236
|
it("should be able to decrypt a block with IV in stream", function () {
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
expected = hex2binary("00112233445566778899aabbccddeeff");
|
237
|
+
const input = hex2binary("000000000000000000000000000000008ea2b7ca516745bf" + "eafc49904b496089");
|
238
|
+
const key = hex2binary("000102030405060708090a0b0c0d0e0f101112131415161718" + "191a1b1c1d1e1f");
|
239
|
+
const cipher = new _crypto.AES256Cipher(key);
|
240
|
+
const result = cipher.decryptBlock(input, false);
|
241
|
+
const expected = hex2binary("00112233445566778899aabbccddeeff");
|
269
242
|
expect(result).toEqual(expected);
|
270
243
|
});
|
271
244
|
});
|
272
245
|
});
|
273
246
|
describe("PDF17Algorithm", function () {
|
274
247
|
it("should correctly check a user key", function () {
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
result = alg.checkUserPassword(password, userValidation, userPassword);
|
248
|
+
const alg = new _crypto.PDF17();
|
249
|
+
const password = new Uint8Array([117, 115, 101, 114]);
|
250
|
+
const userValidation = new Uint8Array([117, 169, 4, 32, 159, 101, 22, 220]);
|
251
|
+
const userPassword = new Uint8Array([131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144, 241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187, 221]);
|
252
|
+
const result = alg.checkUserPassword(password, userValidation, userPassword);
|
281
253
|
expect(result).toEqual(true);
|
282
254
|
});
|
283
255
|
it("should correctly check an owner key", function () {
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
result = alg.checkOwnerPassword(password, ownerValidation, uBytes, ownerPassword);
|
256
|
+
const alg = new _crypto.PDF17();
|
257
|
+
const password = new Uint8Array([111, 119, 110, 101, 114]);
|
258
|
+
const ownerValidation = new Uint8Array([243, 118, 71, 153, 128, 17, 101, 62]);
|
259
|
+
const ownerPassword = new Uint8Array([60, 98, 137, 35, 51, 101, 200, 152, 210, 178, 226, 228, 134, 205, 163, 24, 204, 126, 177, 36, 106, 50, 36, 125, 210, 172, 171, 120, 222, 108, 139, 115]);
|
260
|
+
const uBytes = new Uint8Array([131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144, 241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187, 221, 117, 169, 4, 32, 159, 101, 22, 220, 168, 94, 215, 192, 100, 38, 188, 40]);
|
261
|
+
const result = alg.checkOwnerPassword(password, ownerValidation, uBytes, ownerPassword);
|
291
262
|
expect(result).toEqual(true);
|
292
263
|
});
|
293
264
|
it("should generate a file encryption key from the user key", function () {
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
expected = new Uint8Array([63, 114, 136, 209, 87, 61, 12, 30, 249, 1, 186, 144, 254, 248, 163, 153, 151, 51, 133, 10, 80, 152, 206, 15, 72, 187, 231, 33, 224, 239, 13, 213]);
|
265
|
+
const alg = new _crypto.PDF17();
|
266
|
+
const password = new Uint8Array([117, 115, 101, 114]);
|
267
|
+
const userKeySalt = new Uint8Array([168, 94, 215, 192, 100, 38, 188, 40]);
|
268
|
+
const userEncryption = new Uint8Array([35, 150, 195, 169, 245, 51, 51, 255, 158, 158, 33, 242, 231, 75, 125, 190, 25, 126, 172, 114, 195, 244, 137, 245, 234, 165, 42, 74, 60, 38, 17, 17]);
|
269
|
+
const result = alg.getUserKey(password, userKeySalt, userEncryption);
|
270
|
+
const expected = new Uint8Array([63, 114, 136, 209, 87, 61, 12, 30, 249, 1, 186, 144, 254, 248, 163, 153, 151, 51, 133, 10, 80, 152, 206, 15, 72, 187, 231, 33, 224, 239, 13, 213]);
|
301
271
|
expect(result).toEqual(expected);
|
302
272
|
});
|
303
273
|
it("should generate a file encryption key from the owner key", function () {
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
result = alg.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
|
312
|
-
expected = new Uint8Array([63, 114, 136, 209, 87, 61, 12, 30, 249, 1, 186, 144, 254, 248, 163, 153, 151, 51, 133, 10, 80, 152, 206, 15, 72, 187, 231, 33, 224, 239, 13, 213]);
|
274
|
+
const alg = new _crypto.PDF17();
|
275
|
+
const password = new Uint8Array([111, 119, 110, 101, 114]);
|
276
|
+
const ownerKeySalt = new Uint8Array([200, 245, 242, 12, 218, 123, 24, 120]);
|
277
|
+
const ownerEncryption = new Uint8Array([213, 202, 14, 189, 110, 76, 70, 191, 6, 195, 10, 190, 157, 100, 144, 85, 8, 62, 123, 178, 156, 229, 50, 40, 229, 216, 54, 222, 34, 38, 106, 223]);
|
278
|
+
const uBytes = new Uint8Array([131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144, 241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187, 221, 117, 169, 4, 32, 159, 101, 22, 220, 168, 94, 215, 192, 100, 38, 188, 40]);
|
279
|
+
const result = alg.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
|
280
|
+
const expected = new Uint8Array([63, 114, 136, 209, 87, 61, 12, 30, 249, 1, 186, 144, 254, 248, 163, 153, 151, 51, 133, 10, 80, 152, 206, 15, 72, 187, 231, 33, 224, 239, 13, 213]);
|
313
281
|
expect(result).toEqual(expected);
|
314
282
|
});
|
315
283
|
});
|
316
284
|
describe("PDF20Algorithm", function () {
|
317
285
|
it("should correctly check a user key", function () {
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
result = alg.checkUserPassword(password, userValidation, userPassword);
|
286
|
+
const alg = new _crypto.PDF20();
|
287
|
+
const password = new Uint8Array([117, 115, 101, 114]);
|
288
|
+
const userValidation = new Uint8Array([83, 245, 146, 101, 198, 247, 34, 198]);
|
289
|
+
const userPassword = new Uint8Array([94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95, 184]);
|
290
|
+
const result = alg.checkUserPassword(password, userValidation, userPassword);
|
324
291
|
expect(result).toEqual(true);
|
325
292
|
});
|
326
293
|
it("should correctly check an owner key", function () {
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
result = alg.checkOwnerPassword(password, ownerValidation, uBytes, ownerPassword);
|
294
|
+
const alg = new _crypto.PDF20();
|
295
|
+
const password = new Uint8Array([111, 119, 110, 101, 114]);
|
296
|
+
const ownerValidation = new Uint8Array([142, 232, 169, 208, 202, 214, 5, 185]);
|
297
|
+
const ownerPassword = new Uint8Array([88, 232, 62, 54, 245, 26, 245, 209, 137, 123, 221, 72, 199, 49, 37, 217, 31, 74, 115, 167, 127, 158, 176, 77, 45, 163, 87, 47, 39, 90, 217, 141]);
|
298
|
+
const uBytes = new Uint8Array([94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95, 184, 83, 245, 146, 101, 198, 247, 34, 198, 191, 11, 16, 94, 237, 216, 20, 175]);
|
299
|
+
const result = alg.checkOwnerPassword(password, ownerValidation, uBytes, ownerPassword);
|
334
300
|
expect(result).toEqual(true);
|
335
301
|
});
|
336
302
|
it("should generate a file encryption key from the user key", function () {
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
expected = new Uint8Array([42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248, 133, 18, 189, 61, 34, 107, 79, 29, 56, 59, 181, 213, 118, 113, 34, 65, 210, 87, 174, 22, 239]);
|
303
|
+
const alg = new _crypto.PDF20();
|
304
|
+
const password = new Uint8Array([117, 115, 101, 114]);
|
305
|
+
const userKeySalt = new Uint8Array([191, 11, 16, 94, 237, 216, 20, 175]);
|
306
|
+
const userEncryption = new Uint8Array([121, 208, 2, 181, 230, 89, 156, 60, 253, 143, 212, 28, 84, 180, 196, 177, 173, 128, 221, 107, 46, 20, 94, 186, 135, 51, 95, 24, 20, 223, 254, 36]);
|
307
|
+
const result = alg.getUserKey(password, userKeySalt, userEncryption);
|
308
|
+
const expected = new Uint8Array([42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248, 133, 18, 189, 61, 34, 107, 79, 29, 56, 59, 181, 213, 118, 113, 34, 65, 210, 87, 174, 22, 239]);
|
344
309
|
expect(result).toEqual(expected);
|
345
310
|
});
|
346
311
|
it("should generate a file encryption key from the owner key", function () {
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
result = alg.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
|
355
|
-
expected = new Uint8Array([42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248, 133, 18, 189, 61, 34, 107, 79, 29, 56, 59, 181, 213, 118, 113, 34, 65, 210, 87, 174, 22, 239]);
|
312
|
+
const alg = new _crypto.PDF20();
|
313
|
+
const password = new Uint8Array([111, 119, 110, 101, 114]);
|
314
|
+
const ownerKeySalt = new Uint8Array([29, 208, 185, 46, 11, 76, 135, 149]);
|
315
|
+
const ownerEncryption = new Uint8Array([209, 73, 224, 77, 103, 155, 201, 181, 190, 68, 223, 20, 62, 90, 56, 210, 5, 240, 178, 128, 238, 124, 68, 254, 253, 244, 62, 108, 208, 135, 10, 251]);
|
316
|
+
const uBytes = new Uint8Array([94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95, 184, 83, 245, 146, 101, 198, 247, 34, 198, 191, 11, 16, 94, 237, 216, 20, 175]);
|
317
|
+
const result = alg.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
|
318
|
+
const expected = new Uint8Array([42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248, 133, 18, 189, 61, 34, 107, 79, 29, 56, 59, 181, 213, 118, 113, 34, 65, 210, 87, 174, 22, 239]);
|
356
319
|
expect(result).toEqual(expected);
|
357
320
|
});
|
358
321
|
});
|
359
322
|
});
|
360
323
|
describe("CipherTransformFactory", function () {
|
361
324
|
function buildDict(map) {
|
362
|
-
|
325
|
+
const dict = new _primitives.Dict();
|
363
326
|
|
364
|
-
for (
|
327
|
+
for (const key in map) {
|
365
328
|
dict.set(key, map[key]);
|
366
329
|
}
|
367
330
|
|
@@ -370,7 +333,7 @@ describe("CipherTransformFactory", function () {
|
|
370
333
|
|
371
334
|
function ensurePasswordCorrect(done, dict, fileId, password) {
|
372
335
|
try {
|
373
|
-
|
336
|
+
const factory = new _crypto.CipherTransformFactory(dict, fileId, password);
|
374
337
|
expect("createCipherTransform" in factory).toEqual(true);
|
375
338
|
} catch (ex) {
|
376
339
|
done.fail("Password should be accepted: " + ex);
|
@@ -414,8 +377,8 @@ describe("CipherTransformFactory", function () {
|
|
414
377
|
expect(string).toEqual(decrypted);
|
415
378
|
}
|
416
379
|
|
417
|
-
|
418
|
-
|
380
|
+
let fileId1, fileId2, dict1, dict2, dict3;
|
381
|
+
let aes256Dict, aes256IsoDict, aes256BlankDict, aes256IsoBlankDict;
|
419
382
|
beforeAll(function (done) {
|
420
383
|
fileId1 = unescape("%F6%C6%AF%17%F3rR%8DRM%9A%80%D1%EF%DF%18");
|
421
384
|
fileId2 = unescape("%3CL_%3AD%96%AF@%9A%9D%B3%3Cx%1Cv%AC");
|
@@ -21,15 +21,9 @@
|
|
21
21
|
*/
|
22
22
|
"use strict";
|
23
23
|
|
24
|
-
var _test_utils = require("./test_utils.js");
|
25
|
-
|
26
|
-
var _display_utils = require("../../display/display_utils.js");
|
27
|
-
|
28
24
|
var _api = require("../../display/api.js");
|
29
25
|
|
30
|
-
var
|
31
|
-
|
32
|
-
var _node_utils = require("../../display/node_utils.js");
|
26
|
+
var _test_utils = require("./test_utils.js");
|
33
27
|
|
34
28
|
function getTopLeftPixel(canvasContext) {
|
35
29
|
const imgData = canvasContext.getImageData(0, 0, 1, 1);
|
@@ -47,12 +41,7 @@ describe("custom canvas rendering", function () {
|
|
47
41
|
let loadingTask;
|
48
42
|
let page;
|
49
43
|
beforeAll(function (done) {
|
50
|
-
|
51
|
-
CanvasFactory = new _node_utils.NodeCanvasFactory();
|
52
|
-
} else {
|
53
|
-
CanvasFactory = new _display_utils.DOMCanvasFactory();
|
54
|
-
}
|
55
|
-
|
44
|
+
CanvasFactory = new _api.DefaultCanvasFactory();
|
56
45
|
loadingTask = (0, _api.getDocument)(transparentGetDocumentParams);
|
57
46
|
loadingTask.promise.then(function (doc) {
|
58
47
|
return doc.getPage(1);
|
@@ -67,10 +56,10 @@ describe("custom canvas rendering", function () {
|
|
67
56
|
loadingTask.destroy().then(done);
|
68
57
|
});
|
69
58
|
it("renders to canvas with a default white background", function (done) {
|
70
|
-
|
59
|
+
const viewport = page.getViewport({
|
71
60
|
scale: 1
|
72
61
|
});
|
73
|
-
|
62
|
+
const canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
|
74
63
|
const renderTask = page.render({
|
75
64
|
canvasContext: canvasAndCtx.context,
|
76
65
|
viewport
|
@@ -87,10 +76,10 @@ describe("custom canvas rendering", function () {
|
|
87
76
|
}).catch(done.fail);
|
88
77
|
});
|
89
78
|
it("renders to canvas with a custom background", function (done) {
|
90
|
-
|
79
|
+
const viewport = page.getViewport({
|
91
80
|
scale: 1
|
92
81
|
});
|
93
|
-
|
82
|
+
const canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
|
94
83
|
const renderTask = page.render({
|
95
84
|
canvasContext: canvasAndCtx.context,
|
96
85
|
viewport,
|
@@ -163,7 +152,7 @@ describe("custom ownerDocument", function () {
|
|
163
152
|
}]
|
164
153
|
}
|
165
154
|
};
|
166
|
-
const CanvasFactory =
|
155
|
+
const CanvasFactory = new _api.DefaultCanvasFactory({
|
167
156
|
ownerDocument
|
168
157
|
});
|
169
158
|
return {
|