11function 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