From f632b4a92e4e2c552cf31749792075bad0814c22 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Thu, 4 Jul 2024 17:40:51 +0200 Subject: [PATCH] feat(ext/crypto): make deriveBits length parameter optional and nullable (#24426) Updates SubtleCrypto.prototype.deriveBits as per https://github.com/w3c/webcrypto/pull/345 (WPT update in https://github.com/web-platform-tests/wpt/pull/43400) --- ext/crypto/00_crypto.js | 4 ++-- tests/wpt/runner/expectation.json | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ext/crypto/00_crypto.js b/ext/crypto/00_crypto.js index 8f9c431edf..80a2e11c7c 100644 --- a/ext/crypto/00_crypto.js +++ b/ext/crypto/00_crypto.js @@ -1131,10 +1131,10 @@ class SubtleCrypto { * @param {number | null} length * @returns {Promise} */ - async deriveBits(algorithm, baseKey, length) { + async deriveBits(algorithm, baseKey, length = null) { webidl.assertBranded(this, SubtleCryptoPrototype); const prefix = "Failed to execute 'deriveBits' on 'SubtleCrypto'"; - webidl.requiredArguments(arguments.length, 3, prefix); + webidl.requiredArguments(arguments.length, 2, prefix); algorithm = webidl.converters.AlgorithmIdentifier( algorithm, prefix, diff --git a/tests/wpt/runner/expectation.json b/tests/wpt/runner/expectation.json index 74eef81594..cd212f9c4e 100644 --- a/tests/wpt/runner/expectation.json +++ b/tests/wpt/runner/expectation.json @@ -909,10 +909,12 @@ "historical.any.html": false, "historical.any.worker.html": false, "idlharness.https.any.html": [ - "Window interface: attribute crypto" + "Window interface: attribute crypto", + "SubtleCrypto interface: operation deriveBits(AlgorithmIdentifier, CryptoKey, unsigned long)" ], "idlharness.https.any.worker.html": [ - "WorkerGlobalScope interface: attribute crypto" + "WorkerGlobalScope interface: attribute crypto", + "SubtleCrypto interface: operation deriveBits(AlgorithmIdentifier, CryptoKey, unsigned long)" ], "import_export": { "ec_importKey.https.any.html": [