зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1769290 - Part 9: Apply mozilla-js-handle-rooted-typedef against dom/localstorage,locks,media,midi,notification,payments r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D148282
This commit is contained in:
Родитель
6abe98f452
Коммит
d7301d29b5
|
@ -601,7 +601,7 @@ void SimpleRequestResolver::HandleResponse(bool aResponse) {
|
|||
[[nodiscard]] static bool ToJSValue(JSContext* aCx,
|
||||
const nsTArray<LSItemInfo>& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue) {
|
||||
JS::RootedObject obj(aCx, JS_NewPlainObject(aCx));
|
||||
JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ void SimpleRequestResolver::HandleResponse(bool aResponse) {
|
|||
|
||||
const nsString& key = itemInfo.key();
|
||||
|
||||
JS::RootedValue value(aCx);
|
||||
JS::Rooted<JS::Value> value(aCx);
|
||||
if (!ToJSValue(aCx, itemInfo.value().AsString(), &value)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ void LockRequestChild::RunAbortAlgorithm() {
|
|||
mRequest.mPromise->MaybeRejectWithAbortError("The lock request is aborted");
|
||||
} else {
|
||||
JSContext* cx = jsapi.cx();
|
||||
JS::RootedValue reason(cx);
|
||||
JS::Rooted<JS::Value> reason(cx);
|
||||
Signal()->GetReason(cx, &reason);
|
||||
mRequest.mPromise->MaybeReject(reason);
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ GVAutoplayPermissionRequest::Cancel() {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GVAutoplayPermissionRequest::Allow(JS::HandleValue aChoices) {
|
||||
GVAutoplayPermissionRequest::Allow(JS::Handle<JS::Value> aChoices) {
|
||||
MOZ_ASSERT(mContext, "Do not call 'Allow()' twice!");
|
||||
// As the process of replying of the request is an async task, the status
|
||||
// might have be reset at the time we get the result from parent process.
|
||||
|
|
|
@ -28,7 +28,7 @@ class GVAutoplayPermissionRequest : public ContentPermissionRequestBase {
|
|||
|
||||
// nsIContentPermissionRequest methods
|
||||
NS_IMETHOD Cancel(void) override;
|
||||
NS_IMETHOD Allow(JS::HandleValue choices) override;
|
||||
NS_IMETHOD Allow(JS::Handle<JS::Value> choices) override;
|
||||
|
||||
private:
|
||||
// Only allow to create this request from the requestor.
|
||||
|
|
|
@ -75,7 +75,7 @@ nsresult MediaKeySystemAccessPermissionRequest::Start() {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MediaKeySystemAccessPermissionRequest::Allow(JS::HandleValue aChoices) {
|
||||
MediaKeySystemAccessPermissionRequest::Allow(JS::Handle<JS::Value> aChoices) {
|
||||
AssertIsOnMainThread();
|
||||
mPromiseHolder.ResolveIfExists(true, __func__);
|
||||
return NS_OK;
|
||||
|
|
|
@ -60,7 +60,7 @@ class MediaKeySystemAccessPermissionRequest
|
|||
|
||||
// nsIContentPermissionRequest methods
|
||||
NS_IMETHOD Cancel(void) override;
|
||||
NS_IMETHOD Allow(JS::HandleValue choices) override;
|
||||
NS_IMETHOD Allow(JS::Handle<JS::Value> choices) override;
|
||||
|
||||
private:
|
||||
explicit MediaKeySystemAccessPermissionRequest(nsGlobalWindowInner* aWindow);
|
||||
|
|
|
@ -845,17 +845,17 @@ TEST_F(MP4MetadataTelemetryFixture, Telemetry) {
|
|||
uint32_t>& aExpectedSampleDescriptionEntryCounts,
|
||||
const char* aFileName) {
|
||||
// Get a snapshot of the current histograms
|
||||
JS::RootedValue snapshot(cx.GetJSContext());
|
||||
JS::Rooted<JS::Value> snapshot(cx.GetJSContext());
|
||||
TelemetryTestHelpers::GetSnapshots(cx.GetJSContext(), mTelemetry,
|
||||
"" /* this string is unused */,
|
||||
&snapshot, false /* is_keyed */);
|
||||
|
||||
// We'll use these to pull values out of the histograms.
|
||||
JS::RootedValue values(cx.GetJSContext());
|
||||
JS::RootedValue value(cx.GetJSContext());
|
||||
JS::Rooted<JS::Value> values(cx.GetJSContext());
|
||||
JS::Rooted<JS::Value> value(cx.GetJSContext());
|
||||
|
||||
// Verify our multiple codecs count histogram.
|
||||
JS::RootedValue multipleCodecsHistogram(cx.GetJSContext());
|
||||
JS::Rooted<JS::Value> multipleCodecsHistogram(cx.GetJSContext());
|
||||
TelemetryTestHelpers::GetProperty(
|
||||
cx.GetJSContext(),
|
||||
"MEDIA_MP4_PARSE_SAMPLE_DESCRIPTION_ENTRIES_HAVE_MULTIPLE_CODECS",
|
||||
|
@ -880,7 +880,7 @@ TEST_F(MP4MetadataTelemetryFixture, Telemetry) {
|
|||
<< aFileName;
|
||||
|
||||
// Verify our multiple crypto count histogram.
|
||||
JS::RootedValue multipleCryptoHistogram(cx.GetJSContext());
|
||||
JS::Rooted<JS::Value> multipleCryptoHistogram(cx.GetJSContext());
|
||||
TelemetryTestHelpers::GetProperty(
|
||||
cx.GetJSContext(),
|
||||
"MEDIA_MP4_PARSE_SAMPLE_DESCRIPTION_ENTRIES_HAVE_MULTIPLE_CRYPTO",
|
||||
|
@ -904,7 +904,7 @@ TEST_F(MP4MetadataTelemetryFixture, Telemetry) {
|
|||
<< aFileName;
|
||||
|
||||
// Verify our sample description entry count histogram.
|
||||
JS::RootedValue numSamplesHistogram(cx.GetJSContext());
|
||||
JS::Rooted<JS::Value> numSamplesHistogram(cx.GetJSContext());
|
||||
TelemetryTestHelpers::GetProperty(
|
||||
cx.GetJSContext(), "MEDIA_MP4_PARSE_NUM_SAMPLE_DESCRIPTION_ENTRIES",
|
||||
snapshot, &numSamplesHistogram);
|
||||
|
|
|
@ -71,7 +71,7 @@ void MediaMetadata::GetArtwork(JSContext* aCx, nsTArray<JSObject*>& aRetVal,
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < mArtwork.Length(); ++i) {
|
||||
JS::RootedValue value(aCx);
|
||||
JS::Rooted<JS::Value> value(aCx);
|
||||
if (!ToJSValue(aCx, mArtwork[i], &value)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
|
|
|
@ -267,7 +267,7 @@ static PRTime ReadExpires(JSContext* aCx, const ObjectOrString& aOptions,
|
|||
if (!aOptions.IsObject()) {
|
||||
return EXPIRATION_DEFAULT;
|
||||
}
|
||||
JS::RootedValue value(aCx, JS::ObjectValue(*aOptions.GetAsObject()));
|
||||
JS::Rooted<JS::Value> value(aCx, JS::ObjectValue(*aOptions.GetAsObject()));
|
||||
if (!expiration.Init(aCx, value)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return 0;
|
||||
|
|
|
@ -67,7 +67,7 @@ MIDIPermissionRequest::Cancel() {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MIDIPermissionRequest::Allow(JS::HandleValue aChoices) {
|
||||
MIDIPermissionRequest::Allow(JS::Handle<JS::Value> aChoices) {
|
||||
MOZ_ASSERT(aChoices.isUndefined());
|
||||
MIDIAccessManager* mgr = MIDIAccessManager::Get();
|
||||
mgr->CreateMIDIAccess(mWindow, mNeedsSysex, mPromise);
|
||||
|
|
|
@ -29,7 +29,7 @@ class MIDIPermissionRequest final : public ContentPermissionRequestBase,
|
|||
ContentPermissionRequestBase)
|
||||
// nsIContentPermissionRequest
|
||||
NS_IMETHOD Cancel(void) override;
|
||||
NS_IMETHOD Allow(JS::HandleValue choices) override;
|
||||
NS_IMETHOD Allow(JS::Handle<JS::Value> choices) override;
|
||||
NS_IMETHOD GetTypes(nsIArray** aTypes) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -208,7 +208,7 @@ class NotificationPermissionRequest : public ContentPermissionRequestBase,
|
|||
|
||||
// nsIContentPermissionRequest
|
||||
NS_IMETHOD Cancel(void) override;
|
||||
NS_IMETHOD Allow(JS::HandleValue choices) override;
|
||||
NS_IMETHOD Allow(JS::Handle<JS::Value> choices) override;
|
||||
|
||||
NotificationPermissionRequest(nsIPrincipal* aPrincipal,
|
||||
nsPIDOMWindowInner* aWindow, Promise* aPromise,
|
||||
|
@ -556,7 +556,7 @@ NotificationPermissionRequest::Cancel() {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NotificationPermissionRequest::Allow(JS::HandleValue aChoices) {
|
||||
NotificationPermissionRequest::Allow(JS::Handle<JS::Value> aChoices) {
|
||||
MOZ_ASSERT(aChoices.isUndefined());
|
||||
|
||||
mPermission = NotificationPermission::Granted;
|
||||
|
|
|
@ -41,7 +41,7 @@ bool BasicCardService::IsValidBasicCardRequest(JSContext* aCx, JSObject* aData,
|
|||
if (!aData) {
|
||||
return true;
|
||||
}
|
||||
JS::RootedValue data(aCx, JS::ObjectValue(*aData));
|
||||
JS::Rooted<JS::Value> data(aCx, JS::ObjectValue(*aData));
|
||||
|
||||
BasicCardRequest request;
|
||||
if (!request.Init(aCx, data)) {
|
||||
|
@ -107,7 +107,7 @@ void BasicCardService::CheckForValidBasicCardErrors(JSContext* aCx,
|
|||
JSObject* aData,
|
||||
ErrorResult& aRv) {
|
||||
MOZ_ASSERT(aData, "Don't pass null data");
|
||||
JS::RootedValue data(aCx, JS::ObjectValue(*aData));
|
||||
JS::Rooted<JS::Value> data(aCx, JS::ObjectValue(*aData));
|
||||
|
||||
// XXXbz Just because aData converts to BasicCardErrors right now doesn't mean
|
||||
// it will if someone tries again! Should we be replacing aData with a
|
||||
|
|
|
@ -47,7 +47,7 @@ GeneralResponseData::GetData(nsAString& aData) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GeneralResponseData::InitData(JS::HandleValue aValue, JSContext* aCx) {
|
||||
GeneralResponseData::InitData(JS::Handle<JS::Value> aValue, JSContext* aCx) {
|
||||
if (aValue.isNullOrUndefined()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -381,7 +381,8 @@ GeneralMethodChangeDetails::GetDetails(nsAString& aDetails) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GeneralMethodChangeDetails::InitData(JS::HandleValue aDetails, JSContext* aCx) {
|
||||
GeneralMethodChangeDetails::InitData(JS::Handle<JS::Value> aDetails,
|
||||
JSContext* aCx) {
|
||||
if (aDetails.isNullOrUndefined()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ void PaymentMethodChangeEvent::GetMethodDetails(
|
|||
}
|
||||
}
|
||||
MOZ_ASSERT(aCx);
|
||||
JS::RootedValue value(aCx);
|
||||
JS::Rooted<JS::Value> value(aCx);
|
||||
if (NS_WARN_IF(!basicCardDetails.ToObjectInternal(aCx, &value))) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ PaymentMethodData::GetSupportedMethods(nsAString& aSupportedMethods) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PaymentMethodData::GetData(JSContext* aCx, JS::MutableHandleValue aData) {
|
||||
PaymentMethodData::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData) {
|
||||
if (mData.IsEmpty()) {
|
||||
aData.set(JS::NullValue());
|
||||
return NS_OK;
|
||||
|
@ -205,7 +205,8 @@ PaymentDetailsModifier::GetAdditionalDisplayItems(
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PaymentDetailsModifier::GetData(JSContext* aCx, JS::MutableHandleValue aData) {
|
||||
PaymentDetailsModifier::GetData(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aData) {
|
||||
if (mData.IsEmpty()) {
|
||||
aData.set(JS::NullValue());
|
||||
return NS_OK;
|
||||
|
@ -415,7 +416,7 @@ PaymentDetails::GetError(nsAString& aError) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
PaymentDetails::GetShippingAddressErrors(JSContext* aCx,
|
||||
JS::MutableHandleValue aErrors) {
|
||||
JS::MutableHandle<JS::Value> aErrors) {
|
||||
AddressErrors errors;
|
||||
errors.Init(mShippingAddressErrors);
|
||||
if (!ToJSValue(aCx, errors, aErrors)) {
|
||||
|
@ -425,7 +426,8 @@ PaymentDetails::GetShippingAddressErrors(JSContext* aCx,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PaymentDetails::GetPayerErrors(JSContext* aCx, JS::MutableHandleValue aErrors) {
|
||||
PaymentDetails::GetPayerErrors(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aErrors) {
|
||||
PayerErrors errors;
|
||||
errors.Init(mPayerErrors);
|
||||
if (!ToJSValue(aCx, errors, aErrors)) {
|
||||
|
@ -436,7 +438,7 @@ PaymentDetails::GetPayerErrors(JSContext* aCx, JS::MutableHandleValue aErrors) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
PaymentDetails::GetPaymentMethodErrors(JSContext* aCx,
|
||||
JS::MutableHandleValue aErrors) {
|
||||
JS::MutableHandle<JS::Value> aErrors) {
|
||||
if (mPaymentMethodErrors.IsEmpty()) {
|
||||
aErrors.set(JS::NullValue());
|
||||
return NS_OK;
|
||||
|
|
|
@ -29,7 +29,7 @@ void ConvertMethodData(JSContext* aCx, const PaymentMethodData& aMethodData,
|
|||
// Convert JSObject to a serialized string
|
||||
nsAutoString serializedData;
|
||||
if (aMethodData.mData.WasPassed()) {
|
||||
JS::RootedObject object(aCx, aMethodData.mData.Value());
|
||||
JS::Rooted<JSObject*> object(aCx, aMethodData.mData.Value());
|
||||
if (NS_WARN_IF(
|
||||
NS_FAILED(SerializeFromJSObject(aCx, object, serializedData)))) {
|
||||
aRv.ThrowTypeError(
|
||||
|
@ -60,7 +60,7 @@ void ConvertModifier(JSContext* aCx, const PaymentDetailsModifier& aModifier,
|
|||
// Convert JSObject to a serialized string
|
||||
nsAutoString serializedData;
|
||||
if (aModifier.mData.WasPassed()) {
|
||||
JS::RootedObject object(aCx, aModifier.mData.Value());
|
||||
JS::Rooted<JSObject*> object(aCx, aModifier.mData.Value());
|
||||
if (NS_WARN_IF(
|
||||
NS_FAILED(SerializeFromJSObject(aCx, object, serializedData)))) {
|
||||
aRv.ThrowTypeError("The Modifier.data must be a serializable object");
|
||||
|
@ -204,7 +204,7 @@ void ConvertDetailsUpdate(JSContext* aCx, const PaymentDetailsUpdate& aDetails,
|
|||
|
||||
nsAutoString paymentMethodErrors;
|
||||
if (aDetails.mPaymentMethodErrors.WasPassed()) {
|
||||
JS::RootedObject object(aCx, aDetails.mPaymentMethodErrors.Value());
|
||||
JS::Rooted<JSObject*> object(aCx, aDetails.mPaymentMethodErrors.Value());
|
||||
if (NS_WARN_IF(NS_FAILED(
|
||||
SerializeFromJSObject(aCx, object, paymentMethodErrors)))) {
|
||||
aRv.ThrowTypeError("The PaymentMethodErrors can not be serialized");
|
||||
|
@ -628,7 +628,7 @@ void PaymentRequestManager::RetryPayment(JSContext* aCx,
|
|||
|
||||
nsAutoString paymentMethodErrors;
|
||||
if (aErrors.mPaymentMethod.WasPassed()) {
|
||||
JS::RootedObject object(aCx, aErrors.mPaymentMethod.Value());
|
||||
JS::Rooted<JSObject*> object(aCx, aErrors.mPaymentMethod.Value());
|
||||
if (NS_WARN_IF(NS_FAILED(
|
||||
SerializeFromJSObject(aCx, object, paymentMethodErrors)))) {
|
||||
aRv.ThrowTypeError("The PaymentMethodErrors can not be serialized");
|
||||
|
|
|
@ -12,18 +12,18 @@
|
|||
|
||||
namespace mozilla::dom {
|
||||
|
||||
nsresult SerializeFromJSObject(JSContext* aCx, JS::HandleObject aObject,
|
||||
nsresult SerializeFromJSObject(JSContext* aCx, JS::Handle<JSObject*> aObject,
|
||||
nsAString& aSerializedObject) {
|
||||
MOZ_ASSERT(aCx);
|
||||
JS::RootedValue value(aCx, JS::ObjectValue(*aObject));
|
||||
JS::Rooted<JS::Value> value(aCx, JS::ObjectValue(*aObject));
|
||||
return SerializeFromJSVal(aCx, value, aSerializedObject);
|
||||
}
|
||||
|
||||
nsresult SerializeFromJSVal(JSContext* aCx, JS::HandleValue aValue,
|
||||
nsresult SerializeFromJSVal(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
||||
nsAString& aSerializedValue) {
|
||||
aSerializedValue.Truncate();
|
||||
nsAutoString serializedValue;
|
||||
JS::RootedValue value(aCx, aValue.get());
|
||||
JS::Rooted<JS::Value> value(aCx, aValue.get());
|
||||
NS_ENSURE_TRUE(nsContentUtils::StringifyJSON(aCx, &value, serializedValue),
|
||||
NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
NS_ENSURE_TRUE(!serializedValue.IsEmpty(), NS_ERROR_FAILURE);
|
||||
|
@ -33,9 +33,9 @@ nsresult SerializeFromJSVal(JSContext* aCx, JS::HandleValue aValue,
|
|||
|
||||
nsresult DeserializeToJSObject(const nsAString& aSerializedObject,
|
||||
JSContext* aCx,
|
||||
JS::MutableHandleObject aObject) {
|
||||
JS::MutableHandle<JSObject*> aObject) {
|
||||
MOZ_ASSERT(aCx);
|
||||
JS::RootedValue value(aCx);
|
||||
JS::Rooted<JS::Value> value(aCx);
|
||||
nsresult rv = DeserializeToJSValue(aSerializedObject, aCx, &value);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
|
@ -49,7 +49,8 @@ nsresult DeserializeToJSObject(const nsAString& aSerializedObject,
|
|||
}
|
||||
|
||||
nsresult DeserializeToJSValue(const nsAString& aSerializedObject,
|
||||
JSContext* aCx, JS::MutableHandleValue aValue) {
|
||||
JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aValue) {
|
||||
MOZ_ASSERT(aCx);
|
||||
if (!JS_ParseJSON(aCx, aSerializedObject.BeginReading(),
|
||||
aSerializedObject.Length(), aValue)) {
|
||||
|
|
|
@ -12,17 +12,19 @@
|
|||
|
||||
namespace mozilla::dom {
|
||||
|
||||
nsresult SerializeFromJSObject(JSContext* aCx, JS::HandleObject aObject,
|
||||
nsresult SerializeFromJSObject(JSContext* aCx, JS::Handle<JSObject*> aObject,
|
||||
nsAString& aSerializedObject);
|
||||
|
||||
nsresult SerializeFromJSVal(JSContext* aCx, JS::HandleValue aValue,
|
||||
nsresult SerializeFromJSVal(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
||||
nsAString& aSerializedValue);
|
||||
|
||||
nsresult DeserializeToJSObject(const nsAString& aSerializedObject,
|
||||
JSContext* aCx, JS::MutableHandleObject aObject);
|
||||
JSContext* aCx,
|
||||
JS::MutableHandle<JSObject*> aObject);
|
||||
|
||||
nsresult DeserializeToJSValue(const nsAString& aSerializedObject,
|
||||
JSContext* aCx, JS::MutableHandleValue aValue);
|
||||
JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aValue);
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ void PaymentResponse::GetDetails(JSContext* aCx,
|
|||
rawData.billingAddress.recipient, rawData.billingAddress.phone);
|
||||
}
|
||||
MOZ_ASSERT(aCx);
|
||||
JS::RootedValue value(aCx);
|
||||
JS::Rooted<JS::Value> value(aCx);
|
||||
if (NS_WARN_IF(!basicCardResponse.ToObjectInternal(aCx, &value))) {
|
||||
return;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче