forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-webcrypto.js
More file actions
53 lines (46 loc) · 1.17 KB
/
test-webcrypto.js
File metadata and controls
53 lines (46 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const { WPTRunner } = require('../common/wpt');
const runner = new WPTRunner('WebCryptoAPI');
// Set Node.js flags required for the tests.
runner.setFlags(['--expose-internals']);
// Set a script that will be executed in the worker before running the tests.
runner.setInitScript(`
const {
Crypto,
SubtleCrypto,
crypto,
} = require('internal/crypto/webcrypto');
const { internalBinding } = require('internal/test/binding');
const { DOMException } = internalBinding('messaging');
global.DOMException = DOMException;
Object.defineProperties(global, {
Crypto: {
value: Crypto,
configurable: true,
writable: true,
enumerable: false,
},
SubtleCrypto: {
value: SubtleCrypto,
configurable: true,
writable: true,
enumerable: false,
},
CryptoKey: {
value: crypto.CryptoKey,
configurable: true,
writable: true,
enumerable: false,
},
crypto: {
value: crypto,
configurable: true,
writable: true,
enumerable: false,
},
});
`);
runner.runJsTests();