Commit 3ad6dd49d97 for nodejs
commit 3ad6dd49d97a192eafa9cc7269fedb6c40b661c2
Author: Node.js GitHub Bot <github-bot@iojs.org>
Date: Mon Sep 21 20:58:50 2026 -0400
test: update WPT for WebCryptoAPI to a6a0a0292a
PR-URL: https://github.com/nodejs/node/pull/66142
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
diff --git a/test/fixtures/wpt/WebCryptoAPI/digest/digest.https.any.js b/test/fixtures/wpt/WebCryptoAPI/digest/digest.https.any.js
index 26711b2880d..d22b41702b6 100644
--- a/test/fixtures/wpt/WebCryptoAPI/digest/digest.https.any.js
+++ b/test/fixtures/wpt/WebCryptoAPI/digest/digest.https.any.js
@@ -51,7 +51,6 @@
emptyExpected: digestedData[alg].empty,
label: upCase + " with " + size + " source data",
mutations: true,
- transferBeforeCall: true,
});
vectors.push({
algorithm: {name: downCase},
diff --git a/test/fixtures/wpt/WebCryptoAPI/digest/digest.js b/test/fixtures/wpt/WebCryptoAPI/digest/digest.js
index 9ef9c69a180..63dfd86ebf1 100644
--- a/test/fixtures/wpt/WebCryptoAPI/digest/digest.js
+++ b/test/fixtures/wpt/WebCryptoAPI/digest/digest.js
@@ -58,15 +58,10 @@ function runDigestTests(subtle, sourceData, getVectors) {
promise_test(function () {
var buffer = new Uint8Array(sourceData[size]);
- var algorithm = vector.transferBeforeCall
- ? vector.algorithm
- : withNameGetter(vector.algorithm, function () {
- buffer.buffer.transfer();
- return algorithmName(vector.algorithm);
- });
- if (vector.transferBeforeCall) {
+ var algorithm = withNameGetter(vector.algorithm, function () {
buffer.buffer.transfer();
- }
+ return algorithmName(vector.algorithm);
+ });
return subtle.digest(algorithm, buffer).then(function (result) {
assert_true(
equalBuffers(result, vector.emptyExpected),
diff --git a/test/fixtures/wpt/WebCryptoAPI/export-key-error-order.https.any.js b/test/fixtures/wpt/WebCryptoAPI/export-key-error-order.https.any.js
new file mode 100644
index 00000000000..3dadfe93652
--- /dev/null
+++ b/test/fixtures/wpt/WebCryptoAPI/export-key-error-order.https.any.js
@@ -0,0 +1,53 @@
+// META: title=WebCryptoAPI: exportKey() and wrapKey() check export support first
+
+// HKDF and PBKDF2 are not registered for the export key operation, and their
+// keys can only be imported as non-extractable. Both error conditions are
+// therefore always true at once, which makes the order observable.
+//
+// exportKey: step 6 (NotSupportedError) precedes step 7 (InvalidAccessError).
+// https://w3c.github.io/webcrypto/#SubtleCrypto-method-exportKey
+//
+// wrapKey: step 11 (NotSupportedError) precedes step 12 (InvalidAccessError).
+// https://w3c.github.io/webcrypto/#SubtleCrypto-method-wrapKey
+
+function importDeriveKey(name) {
+ return crypto.subtle.importKey('raw', new Uint8Array([]), name, false,
+ ['deriveBits']);
+}
+
+function importAesKey(name, usages) {
+ return crypto.subtle.importKey('raw', new Uint8Array(16), name, false,
+ usages);
+}
+
+for (const name of ['HKDF', 'PBKDF2']) {
+ promise_test(async (t) => {
+ const key = await importDeriveKey(name);
+ return promise_rejects_dom(t, 'NotSupportedError',
+ crypto.subtle.exportKey('raw', key));
+ }, `exportKey() with a ${name} key throws NotSupportedError`);
+
+ promise_test(async (t) => {
+ const key = await importDeriveKey(name);
+ const wrappingKey = await importAesKey('AES-KW', ['wrapKey']);
+ return promise_rejects_dom(
+ t, 'NotSupportedError',
+ crypto.subtle.wrapKey('raw', key, wrappingKey, 'AES-KW'));
+ }, `wrapKey() with a ${name} key throws NotSupportedError`);
+}
+
+// An algorithm that does support the export key operation must still report
+// the extractable check.
+promise_test(async (t) => {
+ const key = await importAesKey('AES-CBC', ['encrypt']);
+ return promise_rejects_dom(t, 'InvalidAccessError',
+ crypto.subtle.exportKey('raw', key));
+}, 'exportKey() with a non-extractable AES-CBC key throws InvalidAccessError');
+
+promise_test(async (t) => {
+ const key = await importAesKey('AES-CBC', ['encrypt']);
+ const wrappingKey = await importAesKey('AES-KW', ['wrapKey']);
+ return promise_rejects_dom(
+ t, 'InvalidAccessError',
+ crypto.subtle.wrapKey('raw', key, wrappingKey, 'AES-KW'));
+}, 'wrapKey() with a non-extractable AES-CBC key throws InvalidAccessError');
diff --git a/test/fixtures/wpt/WebCryptoAPI/sharedarraybuffer.https.any.js b/test/fixtures/wpt/WebCryptoAPI/sharedarraybuffer.https.any.js
new file mode 100644
index 00000000000..45f4b4dbd50
--- /dev/null
+++ b/test/fixtures/wpt/WebCryptoAPI/sharedarraybuffer.https.any.js
@@ -0,0 +1,38 @@
+// META: title=WebCryptoAPI: BufferSource arguments and members reject shared buffers
+
+// None of the BufferSource arguments of SubtleCrypto, or of the dictionaries it
+// takes, are [AllowShared], so a SharedArrayBuffer, or a view onto one, has to
+// throw a TypeError.
+//
+// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`.
+const sharedBuffer = new WebAssembly.Memory({ shared: true, initial: 1, maximum: 1 }).buffer;
+
+function generateAesGcmKey() {
+ return crypto.subtle.generateKey({ name: "AES-GCM", length: 128 }, false, ["encrypt"]);
+}
+
+for (const [kind, buffer] of [["SharedArrayBuffer", sharedBuffer],
+ ["Uint8Array(SharedArrayBuffer)", new Uint8Array(sharedBuffer)]]) {
+ promise_test(t => {
+ return promise_rejects_js(t, TypeError, crypto.subtle.digest("SHA-256", buffer));
+ }, `digest() data is a ${kind}`);
+
+ promise_test(async t => {
+ const key = await generateAesGcmKey();
+ await promise_rejects_js(t, TypeError,
+ crypto.subtle.encrypt({ name: "AES-GCM", iv: new Uint8Array(12) }, key, buffer));
+ }, `encrypt() data is a ${kind}`);
+
+ promise_test(async t => {
+ const key = await generateAesGcmKey();
+ await promise_rejects_js(t, TypeError,
+ crypto.subtle.encrypt({ name: "AES-GCM", iv: buffer }, key, new Uint8Array(1)));
+ }, `encrypt() AesGcmParams.iv is a ${kind}`);
+
+ promise_test(async t => {
+ const key = await generateAesGcmKey();
+ await promise_rejects_js(t, TypeError,
+ crypto.subtle.encrypt({ name: "AES-GCM", iv: new Uint8Array(12), additionalData: buffer },
+ key, new Uint8Array(1)));
+ }, `encrypt() AesGcmParams.additionalData is a ${kind}`);
+}
diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json
index 9e7979e5546..f6773d17497 100644
--- a/test/fixtures/wpt/versions.json
+++ b/test/fixtures/wpt/versions.json
@@ -100,7 +100,7 @@
"path": "web-locks"
},
"WebCryptoAPI": {
- "commit": "55ce71bb9deaf4b8a30fe80f95558a10699fb433",
+ "commit": "a6a0a0292a4706866328488ffaaace00400edcc6",
"path": "WebCryptoAPI"
},
"webidl": {