Skip to content

Commit 3da465a

Browse files
authored
test,crypto: update WebCryptoAPI WPT
PR-URL: nodejs#54925 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 028c586 commit 3da465a

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

test/fixtures/wpt/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Last update:
3232
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
3333
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
3434
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
35-
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/6748a0a246/WebCryptoAPI
35+
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/272064ebf9/WebCryptoAPI
3636
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions
3737
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/e97fac4791/webmessaging/broadcastchannel
3838
- webstorage: https://github.com/web-platform-tests/wpt/tree/9dafa89214/webstorage

test/fixtures/wpt/WebCryptoAPI/generateKey/successes.js

+27-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ function run_test(algorithmNames, slowTest) {
55
setup({explicit_timeout: true});
66

77
// These tests check that generateKey successfully creates keys
8-
// when provided any of a wide set of correct parameters.
8+
// when provided any of a wide set of correct parameters
9+
// and that they can be exported afterwards.
910
//
1011
// There are a lot of combinations of possible parameters,
1112
// resulting in a very large number of tests
@@ -68,9 +69,32 @@ function run_test(algorithmNames, slowTest) {
6869
} else {
6970
assert_goodCryptoKey(result, algorithm, extractable, usages, "secret");
7071
}
72+
return result;
7173
}, function(err) {
72-
assert_unreached("Threw an unexpected error: " + err.toString());
73-
});
74+
assert_unreached("generateKey threw an unexpected error: " + err.toString());
75+
})
76+
.then(async function (result) {
77+
if (resultType === "CryptoKeyPair") {
78+
await Promise.all([
79+
subtle.exportKey('jwk', result.publicKey),
80+
subtle.exportKey('spki', result.publicKey),
81+
result.publicKey.algorithm.name.startsWith('RSA') ? undefined : subtle.exportKey('raw', result.publicKey),
82+
...(extractable ? [
83+
subtle.exportKey('jwk', result.privateKey),
84+
subtle.exportKey('pkcs8', result.privateKey),
85+
] : [])
86+
]);
87+
} else {
88+
if (extractable) {
89+
await Promise.all([
90+
subtle.exportKey('raw', result),
91+
subtle.exportKey('jwk', result),
92+
]);
93+
}
94+
}
95+
}, function(err) {
96+
assert_unreached("exportKey threw an unexpected error: " + err.toString());
97+
})
7498
}, testTag + ": generateKey" + parameterString(algorithm, extractable, usages));
7599
}
76100

test/fixtures/wpt/versions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"path": "wasm/webapi"
8989
},
9090
"WebCryptoAPI": {
91-
"commit": "6748a0a24614b01ce6527493a19ef846738bee3a",
91+
"commit": "272064ebf9a3d313a2d4db8bb9ce2790648aa162",
9292
"path": "WebCryptoAPI"
9393
},
9494
"webidl/ecmascript-binding/es-exceptions": {

0 commit comments

Comments
 (0)