Bug 1894027 - Replacing SyntaxError exception with TypeError for derive_bits_keys r=nss-reviewers,jschanck

Differential Revision: https://phabricator.services.mozilla.com/D208914
This commit is contained in:
Anna Weine 2024-05-06 08:44:10 +00:00
parent 2859e9cc30
commit 33701c7ba8
3 changed files with 10 additions and 76 deletions

View file

@ -166,7 +166,7 @@ static nsresult Coerce(JSContext* aCx, T& aTarget, const OOS& aAlgorithm) {
JS::Rooted<JS::Value> value(aCx, JS::ObjectValue(*aAlgorithm.GetAsObject()));
if (!aTarget.Init(aCx, value)) {
return NS_ERROR_DOM_SYNTAX_ERR;
return NS_ERROR_DOM_TYPE_MISMATCH_ERR;
}
return NS_OK;
@ -392,9 +392,14 @@ void WebCryptoTask::FailWithError(nsresult aRv) {
MOZ_ASSERT(IsOnOriginalThread());
Telemetry::Accumulate(Telemetry::WEBCRYPTO_RESOLVED, false);
// Blindly convert nsresult to DOMException
// Individual tasks must ensure they pass the right values
mResultPromise->MaybeReject(aRv);
if (aRv == NS_ERROR_DOM_TYPE_MISMATCH_ERR) {
mResultPromise->MaybeRejectWithTypeError(
"The operation could not be performed.");
} else {
// Blindly convert nsresult to DOMException
// Individual tasks must ensure they pass the right values
mResultPromise->MaybeReject(aRv);
}
// Manually release mResultPromise while we're on the main thread
mResultPromise = nullptr;
mWorkerRef = nullptr;
@ -2750,7 +2755,7 @@ class DeriveEcdhBitsTask : public ReturnArrayBufferViewTask {
RootedDictionary<EcdhKeyDeriveParams> params(aCx);
mEarlyRv = Coerce(aCx, params, aAlgorithm);
if (NS_FAILED(mEarlyRv)) {
mEarlyRv = NS_ERROR_DOM_SYNTAX_ERR;
/* The returned code is installed by Coerce function. */
return;
}

View file

@ -19,24 +19,6 @@
[P-384 non-multiple of 8 bits]
expected: FAIL
[P-521 missing public curve]
expected: FAIL
[P-256 missing public curve]
expected: FAIL
[P-384 missing public curve]
expected: FAIL
[P-521 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-256 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-384 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-521 asking for too many bits]
expected: FAIL
@ -68,24 +50,6 @@
[P-384 non-multiple of 8 bits]
expected: FAIL
[P-521 missing public curve]
expected: FAIL
[P-256 missing public curve]
expected: FAIL
[P-384 missing public curve]
expected: FAIL
[P-521 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-256 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-384 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-521 asking for too many bits]
expected: FAIL

View file

@ -1,42 +1,7 @@
[ecdh_keys.https.any.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[P-521 missing public curve]
expected: FAIL
[P-256 missing public curve]
expected: FAIL
[P-384 missing public curve]
expected: FAIL
[P-521 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-256 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-384 public property of algorithm is not a CryptoKey]
expected: FAIL
[ecdh_keys.https.any.worker.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[P-521 missing public curve]
expected: FAIL
[P-256 missing public curve]
expected: FAIL
[P-384 missing public curve]
expected: FAIL
[P-521 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-256 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-384 public property of algorithm is not a CryptoKey]
expected: FAIL