Issue #2690 - Replace SyntaxError with TypeError for derive_bits_keys.

This commit is contained in:
Moonchild 2025-02-05 19:56:46 +01:00 committed by roytam1
commit 7039b5a95d

View file

@ -170,7 +170,7 @@ Coerce(JSContext* aCx, T& aTarget, const OOS& aAlgorithm)
JS::RootedValue 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;
@ -401,9 +401,14 @@ WebCryptoTask::FailWithError(nsresult aRv)
{
MOZ_ASSERT(IsOnOriginalThread());
// 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;
mWorkerHolder = nullptr;
@ -2927,7 +2932,7 @@ public:
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;
}