Skip to content

Commit 89693b8

Browse files
committed
fixup! [WebCrypto] Make serialization tests global-agnostic
1 parent 2c87296 commit 89693b8

1 file changed

Lines changed: 3 additions & 24 deletions

File tree

WebCryptoAPI/serialization/serialization.js

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,4 @@
11
function run_test(vectors) {
2-
function structuredCloneViaMessageChannel(data, t) {
3-
const channel = new MessageChannel();
4-
t.add_cleanup(() => {
5-
channel.port1.close();
6-
channel.port2.close();
7-
});
8-
9-
const result = waitForEvent(channel.port1, 'message');
10-
channel.port1.start();
11-
channel.port2.postMessage(data);
12-
13-
return result.then(evt => evt.data);
14-
}
15-
16-
function waitForEvent(obj, ev) {
17-
return new Promise((resolve) => {
18-
obj.addEventListener(ev, resolve, {once: true});
19-
});
20-
}
21-
222
function testCryptoKeySerialization(
233
generateKeyAlgorithm, generateKeyUsages, exportFormat) {
244
promise_test(async t => {
@@ -27,8 +7,7 @@ function run_test(vectors) {
277
const keyExported =
288
await crypto.subtle.exportKey(exportFormat, cryptoKey);
299

30-
const {key} = await structuredCloneViaMessageChannel(
31-
{key: cryptoKey}, t);
10+
const {key} = structuredClone({key: cryptoKey});
3211
const newKeyExported =
3312
await crypto.subtle.exportKey(exportFormat, key);
3413
assert_true(equalBuffers(keyExported, newKeyExported));
@@ -46,8 +25,8 @@ function run_test(vectors) {
4625
const privateKeyExported = await crypto.subtle.exportKey(
4726
privateExportFormat, keyPair.privateKey);
4827

49-
const {publicKey, privateKey} = await structuredCloneViaMessageChannel(
50-
{publicKey: keyPair.publicKey, privateKey: keyPair.privateKey}, t);
28+
const {publicKey, privateKey} = structuredClone(
29+
{publicKey: keyPair.publicKey, privateKey: keyPair.privateKey});
5130
const newPublicKeyExported =
5231
await crypto.subtle.exportKey(publicExportFormat, publicKey);
5332
assert_true(equalBuffers(publicKeyExported, newPublicKeyExported));

0 commit comments

Comments
 (0)