diff --git a/WebCryptoAPI/serialization/aes-cbc.https.window.js b/WebCryptoAPI/serialization/aes-cbc.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/aes-cbc.https.window.js rename to WebCryptoAPI/serialization/aes-cbc.https.any.js diff --git a/WebCryptoAPI/serialization/aes-ctr.https.window.js b/WebCryptoAPI/serialization/aes-ctr.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/aes-ctr.https.window.js rename to WebCryptoAPI/serialization/aes-ctr.https.any.js diff --git a/WebCryptoAPI/serialization/aes-gcm.https.window.js b/WebCryptoAPI/serialization/aes-gcm.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/aes-gcm.https.window.js rename to WebCryptoAPI/serialization/aes-gcm.https.any.js diff --git a/WebCryptoAPI/serialization/aes-kw.https.window.js b/WebCryptoAPI/serialization/aes-kw.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/aes-kw.https.window.js rename to WebCryptoAPI/serialization/aes-kw.https.any.js diff --git a/WebCryptoAPI/serialization/aes-ocb.tentative.https.window.js b/WebCryptoAPI/serialization/aes-ocb.tentative.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/aes-ocb.tentative.https.window.js rename to WebCryptoAPI/serialization/aes-ocb.tentative.https.any.js diff --git a/WebCryptoAPI/serialization/chacha20-poly1305.tentative.https.window.js b/WebCryptoAPI/serialization/chacha20-poly1305.tentative.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/chacha20-poly1305.tentative.https.window.js rename to WebCryptoAPI/serialization/chacha20-poly1305.tentative.https.any.js diff --git a/WebCryptoAPI/serialization/ecdh.https.window.js b/WebCryptoAPI/serialization/ecdh.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/ecdh.https.window.js rename to WebCryptoAPI/serialization/ecdh.https.any.js diff --git a/WebCryptoAPI/serialization/ecdsa.https.window.js b/WebCryptoAPI/serialization/ecdsa.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/ecdsa.https.window.js rename to WebCryptoAPI/serialization/ecdsa.https.any.js diff --git a/WebCryptoAPI/serialization/ed25519.https.window.js b/WebCryptoAPI/serialization/ed25519.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/ed25519.https.window.js rename to WebCryptoAPI/serialization/ed25519.https.any.js diff --git a/WebCryptoAPI/serialization/ed448.https.window.js b/WebCryptoAPI/serialization/ed448.tentative.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/ed448.https.window.js rename to WebCryptoAPI/serialization/ed448.tentative.https.any.js diff --git a/WebCryptoAPI/serialization/hmac.https.window.js b/WebCryptoAPI/serialization/hmac.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/hmac.https.window.js rename to WebCryptoAPI/serialization/hmac.https.any.js diff --git a/WebCryptoAPI/serialization/kmac.tentative.https.window.js b/WebCryptoAPI/serialization/kmac.tentative.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/kmac.tentative.https.window.js rename to WebCryptoAPI/serialization/kmac.tentative.https.any.js diff --git a/WebCryptoAPI/serialization/mldsa.tentative.https.window.js b/WebCryptoAPI/serialization/mldsa.tentative.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/mldsa.tentative.https.window.js rename to WebCryptoAPI/serialization/mldsa.tentative.https.any.js diff --git a/WebCryptoAPI/serialization/mlkem.tentative.https.window.js b/WebCryptoAPI/serialization/mlkem.tentative.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/mlkem.tentative.https.window.js rename to WebCryptoAPI/serialization/mlkem.tentative.https.any.js diff --git a/WebCryptoAPI/serialization/resources/post-page.html b/WebCryptoAPI/serialization/resources/post-page.html deleted file mode 100644 index 0226732b15890f..00000000000000 --- a/WebCryptoAPI/serialization/resources/post-page.html +++ /dev/null @@ -1,9 +0,0 @@ - - -Post Target - - diff --git a/WebCryptoAPI/serialization/rsa-oaep.https.window.js b/WebCryptoAPI/serialization/rsa-oaep.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/rsa-oaep.https.window.js rename to WebCryptoAPI/serialization/rsa-oaep.https.any.js diff --git a/WebCryptoAPI/serialization/rsa-pss.https.window.js b/WebCryptoAPI/serialization/rsa-pss.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/rsa-pss.https.window.js rename to WebCryptoAPI/serialization/rsa-pss.https.any.js diff --git a/WebCryptoAPI/serialization/rsassa-pkcs1-v1_5.https.window.js b/WebCryptoAPI/serialization/rsassa-pkcs1-v1_5.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/rsassa-pkcs1-v1_5.https.window.js rename to WebCryptoAPI/serialization/rsassa-pkcs1-v1_5.https.any.js diff --git a/WebCryptoAPI/serialization/serialization.js b/WebCryptoAPI/serialization/serialization.js index 35394e252fd935..a9444032503268 100644 --- a/WebCryptoAPI/serialization/serialization.js +++ b/WebCryptoAPI/serialization/serialization.js @@ -1,10 +1,4 @@ function run_test(vectors) { - function waitForEvent(obj, ev) { - return new Promise((resolve) => { - obj.addEventListener(ev, resolve, {once: true}); - }); - } - function testCryptoKeySerialization( generateKeyAlgorithm, generateKeyUsages, exportFormat) { promise_test(async t => { @@ -13,17 +7,9 @@ function run_test(vectors) { const keyExported = await crypto.subtle.exportKey(exportFormat, cryptoKey); - const popup = window.open('resources/post-page.html'); - t.add_cleanup(() => popup.close()); - - - // Wait for window to load. - await waitForEvent(popup, 'load'); - popup.postMessage({key: cryptoKey}); - // Wait to get key back via post. - let evt = await waitForEvent(window, 'message'); + const {key} = structuredClone({key: cryptoKey}); const newKeyExported = - await crypto.subtle.exportKey(exportFormat, evt.data.key); + await crypto.subtle.exportKey(exportFormat, key); assert_true(equalBuffers(keyExported, newKeyExported)); }, 'serialization test ' + objectToString(generateKeyAlgorithm)); }; @@ -39,20 +25,13 @@ function run_test(vectors) { const privateKeyExported = await crypto.subtle.exportKey( privateExportFormat, keyPair.privateKey); - const popup = window.open('resources/post-page.html'); - t.add_cleanup(() => popup.close()); - - // Wait for window to load. - await waitForEvent(popup, 'load'); - popup.postMessage( + const {publicKey, privateKey} = structuredClone( {publicKey: keyPair.publicKey, privateKey: keyPair.privateKey}); - // Wait to get keys back via post. - let evt = await waitForEvent(window, 'message'); const newPublicKeyExported = - await crypto.subtle.exportKey(publicExportFormat, evt.data.publicKey); + await crypto.subtle.exportKey(publicExportFormat, publicKey); assert_true(equalBuffers(publicKeyExported, newPublicKeyExported)); const newPrivateKeyExported = await crypto.subtle.exportKey( - privateExportFormat, evt.data.privateKey); + privateExportFormat, privateKey); assert_true(equalBuffers(privateKeyExported, newPrivateKeyExported)); }, 'serialization test ' + objectToString(generateKeyAlgorithm)); }; diff --git a/WebCryptoAPI/serialization/x25519.https.window.js b/WebCryptoAPI/serialization/x25519.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/x25519.https.window.js rename to WebCryptoAPI/serialization/x25519.https.any.js diff --git a/WebCryptoAPI/serialization/x448.https.window.js b/WebCryptoAPI/serialization/x448.tentative.https.any.js similarity index 100% rename from WebCryptoAPI/serialization/x448.https.window.js rename to WebCryptoAPI/serialization/x448.tentative.https.any.js