Bug 1034191 - Make nsDependentJSString users work with Latin1 strings and nursery-allocated strings. r=bz

This commit is contained in:
Jan de Mooij 2014-07-05 17:30:54 +02:00
parent fc71053614
commit f3876da607
45 changed files with 157 additions and 169 deletions

View File

@ -366,7 +366,7 @@ DOMMultipartFileImpl::InitChromeFile(JSContext* aCx,
JSString* str = JS::ToString(aCx, JS::Handle<JS::Value>::fromMarkedLocation(&aArgv[0])); JSString* str = JS::ToString(aCx, JS::Handle<JS::Value>::fromMarkedLocation(&aArgv[0]));
NS_ENSURE_TRUE(str, NS_ERROR_XPC_BAD_CONVERT_JS); NS_ENSURE_TRUE(str, NS_ERROR_XPC_BAD_CONVERT_JS);
nsDependentJSString xpcomStr; nsAutoJSString xpcomStr;
if (!xpcomStr.init(aCx, str)) { if (!xpcomStr.init(aCx, str)) {
return NS_ERROR_XPC_BAD_CONVERT_JS; return NS_ERROR_XPC_BAD_CONVERT_JS;
} }
@ -434,7 +434,7 @@ DOMMultipartFileImpl::InitFile(JSContext* aCx,
JSString* str = JS::ToString(aCx, JS::Handle<JS::Value>::fromMarkedLocation(&aArgv[1])); JSString* str = JS::ToString(aCx, JS::Handle<JS::Value>::fromMarkedLocation(&aArgv[1]));
NS_ENSURE_TRUE(str, NS_ERROR_XPC_BAD_CONVERT_JS); NS_ENSURE_TRUE(str, NS_ERROR_XPC_BAD_CONVERT_JS);
nsDependentJSString xpcomStr; nsAutoJSString xpcomStr;
if (!xpcomStr.init(aCx, str)) { if (!xpcomStr.init(aCx, str)) {
return NS_ERROR_XPC_BAD_CONVERT_JS; return NS_ERROR_XPC_BAD_CONVERT_JS;
} }
@ -472,7 +472,7 @@ BlobSet::AppendVoidPtr(const void* aData, uint32_t aLength)
nsresult nsresult
BlobSet::AppendString(JSString* aString, bool nativeEOL, JSContext* aCx) BlobSet::AppendString(JSString* aString, bool nativeEOL, JSContext* aCx)
{ {
nsDependentJSString xpcomStr; nsAutoJSString xpcomStr;
if (!xpcomStr.init(aCx, aString)) { if (!xpcomStr.init(aCx, aString)) {
return NS_ERROR_XPC_BAD_CONVERT_JS; return NS_ERROR_XPC_BAD_CONVERT_JS;
} }

View File

@ -5409,7 +5409,7 @@ nsDocument::CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value*
// Function name is the type of the custom element. // Function name is the type of the custom element.
JSString* jsFunName = JSString* jsFunName =
JS_GetFunctionId(JS_ValueToFunction(aCx, args.calleev())); JS_GetFunctionId(JS_ValueToFunction(aCx, args.calleev()));
nsDependentJSString elemName; nsAutoJSString elemName;
if (!elemName.init(aCx, jsFunName)) { if (!elemName.init(aCx, jsFunName)) {
return true; return true;
} }

View File

@ -440,7 +440,7 @@ HTMLCanvasElement::ParseParams(JSContext* aCx,
*usingCustomParseOptions = false; *usingCustomParseOptions = false;
if (aParams.Length() == 0 && aEncoderOptions.isString()) { if (aParams.Length() == 0 && aEncoderOptions.isString()) {
NS_NAMED_LITERAL_STRING(mozParseOptions, "-moz-parse-options:"); NS_NAMED_LITERAL_STRING(mozParseOptions, "-moz-parse-options:");
nsDependentJSString paramString; nsAutoJSString paramString;
if (!paramString.init(aCx, aEncoderOptions.toString())) { if (!paramString.init(aCx, aEncoderOptions.toString())) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }

View File

@ -763,7 +763,7 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const ch
if (!jsKey) { if (!jsKey) {
return NS_OK; return NS_OK;
} }
nsDependentJSString keyStr; nsAutoJSString keyStr;
if (!keyStr.init(cx, jsKey) || keyStr.Find("audio.volume.", 0, false)) { if (!keyStr.init(cx, jsKey) || keyStr.Find("audio.volume.", 0, false)) {
return NS_OK; return NS_OK;
} }

View File

@ -107,7 +107,7 @@ ConsoleStructuredCloneCallbacksWrite(JSContext* aCx,
return false; return false;
} }
nsDependentJSString string; nsAutoJSString string;
if (!string.init(aCx, jsString)) { if (!string.init(aCx, jsString)) {
return false; return false;
} }
@ -1227,7 +1227,7 @@ Console::ProcessArguments(JSContext* aCx,
return; return;
} }
nsDependentJSString string; nsAutoJSString string;
if (!string.init(aCx, jsString)) { if (!string.init(aCx, jsString)) {
return; return;
} }
@ -1378,7 +1378,7 @@ Console::ProcessArguments(JSContext* aCx,
return; return;
} }
nsDependentJSString v; nsAutoJSString v;
if (!v.init(aCx, jsString)) { if (!v.init(aCx, jsString)) {
return; return;
} }
@ -1473,7 +1473,7 @@ Console::ComposeGroupName(JSContext* aCx,
return; return;
} }
nsDependentJSString string; nsAutoJSString string;
if (!string.init(aCx, jsString)) { if (!string.init(aCx, jsString)) {
return; return;
} }
@ -1505,7 +1505,7 @@ Console::StartTimer(JSContext* aCx, const JS::Value& aName,
return JS::UndefinedValue(); return JS::UndefinedValue();
} }
nsDependentJSString key; nsAutoJSString key;
if (!key.init(aCx, jsString)) { if (!key.init(aCx, jsString)) {
return JS::UndefinedValue(); return JS::UndefinedValue();
} }
@ -1539,7 +1539,7 @@ Console::StopTimer(JSContext* aCx, const JS::Value& aName,
return JS::UndefinedValue(); return JS::UndefinedValue();
} }
nsDependentJSString key; nsAutoJSString key;
if (!key.init(aCx, jsString)) { if (!key.init(aCx, jsString)) {
return JS::UndefinedValue(); return JS::UndefinedValue();
} }
@ -1585,7 +1585,7 @@ Console::IncreaseCounter(JSContext* aCx, const ConsoleStackEntry& aFrame,
JS::Rooted<JS::Value> labelValue(aCx, aArguments[0]); JS::Rooted<JS::Value> labelValue(aCx, aArguments[0]);
JS::Rooted<JSString*> jsString(aCx, JS::ToString(aCx, labelValue)); JS::Rooted<JSString*> jsString(aCx, JS::ToString(aCx, labelValue));
nsDependentJSString string; nsAutoJSString string;
if (jsString && string.init(aCx, jsString)) { if (jsString && string.init(aCx, jsString)) {
label = string; label = string;
key = string; key = string;

View File

@ -1953,7 +1953,6 @@ Navigator::DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
JS::Handle<jsid> aId, JS::Handle<jsid> aId,
JS::MutableHandle<JSPropertyDescriptor> aDesc) JS::MutableHandle<JSPropertyDescriptor> aDesc)
{ {
// Note: The infallibleInit call below depends on this check.
if (!JSID_IS_STRING(aId)) { if (!JSID_IS_STRING(aId)) {
return true; return true;
} }
@ -1963,8 +1962,10 @@ Navigator::DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
return Throw(aCx, NS_ERROR_NOT_INITIALIZED); return Throw(aCx, NS_ERROR_NOT_INITIALIZED);
} }
nsDependentJSString name; nsAutoJSString name;
name.infallibleInit(aId); if (!name.init(aCx, JSID_TO_STRING(aId))) {
return false;
}
const nsGlobalNameStruct* name_struct = const nsGlobalNameStruct* name_struct =
nameSpaceManager->LookupNavigatorName(name); nameSpaceManager->LookupNavigatorName(name);

View File

@ -89,7 +89,6 @@ WindowNamedPropertiesHandler::getOwnPropertyDescriptor(JSContext* aCx,
JS::MutableHandle<JSPropertyDescriptor> aDesc) JS::MutableHandle<JSPropertyDescriptor> aDesc)
const const
{ {
// Note: The infallibleInit call below depends on this check.
if (!JSID_IS_STRING(aId)) { if (!JSID_IS_STRING(aId)) {
// Nothing to do if we're resolving a non-string property. // Nothing to do if we're resolving a non-string property.
return true; return true;
@ -100,8 +99,10 @@ WindowNamedPropertiesHandler::getOwnPropertyDescriptor(JSContext* aCx,
return true; return true;
} }
nsDependentJSString str; nsAutoJSString str;
str.infallibleInit(aId); if (!str.init(aCx, JSID_TO_STRING(aId))) {
return false;
}
// Grab the DOM window. // Grab the DOM window.
nsGlobalWindow* win = GetWindowFromGlobal(global); nsGlobalWindow* win = GetWindowFromGlobal(global);

View File

@ -342,7 +342,7 @@ nsContentPermissionRequestProxy::Allow(JS::HandleValue aChoices)
!val.isString()) { !val.isString()) {
// no setting for the permission type, skip it // no setting for the permission type, skip it
} else { } else {
nsDependentJSString choice; nsAutoJSString choice;
if (!choice.init(cx, val)) { if (!choice.init(cx, val)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }

View File

@ -2652,8 +2652,10 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
// Note - Our only caller is nsGlobalWindow::DoNewResolve, which checks that // Note - Our only caller is nsGlobalWindow::DoNewResolve, which checks that
// JSID_IS_STRING(id) is true. // JSID_IS_STRING(id) is true.
nsDependentJSString name; nsAutoJSString name;
name.infallibleInit(id); if (!name.init(cx, JSID_TO_STRING(id))) {
return NS_ERROR_OUT_OF_MEMORY;
}
const char16_t *class_name = nullptr; const char16_t *class_name = nullptr;
const nsGlobalNameStruct *name_struct = const nsGlobalNameStruct *name_struct =
@ -2982,10 +2984,10 @@ LocationSetterGuts(JSContext *cx, JSObject *obj, JS::MutableHandle<JS::Value> vp
return NS_OK; return NS_OK;
} }
nsDependentJSString depStr; nsAutoJSString str;
NS_ENSURE_TRUE(depStr.init(cx, val), NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(str.init(cx, val), NS_ERROR_UNEXPECTED);
return location->SetHref(depStr); return location->SetHref(str);
} }
template<class Interface> template<class Interface>
@ -3436,13 +3438,13 @@ nsStorage2SH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper)); nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
nsDependentJSString depStr; nsAutoJSString autoStr;
NS_ENSURE_TRUE(depStr.init(cx, jsstr), NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(autoStr.init(cx, jsstr), NS_ERROR_UNEXPECTED);
// GetItem() will return null if the caller can't access the session // GetItem() will return null if the caller can't access the session
// storage item. // storage item.
nsAutoString data; nsAutoString data;
nsresult rv = storage->GetItem(depStr, data); nsresult rv = storage->GetItem(autoStr, data);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (!DOMStringIsNull(data)) { if (!DOMStringIsNull(data)) {
@ -3469,7 +3471,7 @@ nsStorage2SH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSString* key = IdToString(cx, id); JSString* key = IdToString(cx, id);
NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
nsDependentJSString keyStr; nsAutoJSString keyStr;
NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
// For native wrappers, do not get random names on storage objects. // For native wrappers, do not get random names on storage objects.
@ -3508,14 +3510,14 @@ nsStorage2SH::SetProperty(nsIXPConnectWrappedNative *wrapper,
JSString *key = IdToString(cx, id); JSString *key = IdToString(cx, id);
NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
nsDependentJSString keyStr; nsAutoJSString keyStr;
NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
JS::Rooted<JS::Value> val(cx, *vp); JS::Rooted<JS::Value> val(cx, *vp);
JSString *value = JS::ToString(cx, val); JSString *value = JS::ToString(cx, val);
NS_ENSURE_TRUE(value, NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(value, NS_ERROR_UNEXPECTED);
nsDependentJSString valueStr; nsAutoJSString valueStr;
NS_ENSURE_TRUE(valueStr.init(cx, value), NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(valueStr.init(cx, value), NS_ERROR_UNEXPECTED);
nsresult rv = storage->SetItem(keyStr, valueStr); nsresult rv = storage->SetItem(keyStr, valueStr);
@ -3538,7 +3540,7 @@ nsStorage2SH::DelProperty(nsIXPConnectWrappedNative *wrapper,
JSString *key = IdToString(cx, id); JSString *key = IdToString(cx, id);
NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
nsDependentJSString keyStr; nsAutoJSString keyStr;
NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
nsresult rv = storage->RemoveItem(keyStr); nsresult rv = storage->RemoveItem(keyStr);

View File

@ -3069,11 +3069,9 @@ nsDOMWindowUtils::GetPCCountScriptSummary(int32_t script, JSContext* cx, nsAStri
if (!text) if (!text)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsDependentJSString str; if (!AssignJSString(cx, result, text))
if (!str.init(cx, text))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
result = str;
return NS_OK; return NS_OK;
} }
@ -3086,11 +3084,9 @@ nsDOMWindowUtils::GetPCCountScriptContents(int32_t script, JSContext* cx, nsAStr
if (!text) if (!text)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsDependentJSString str; if (!AssignJSString(cx, result, text))
if (!str.init(cx, text))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
result = str;
return NS_OK; return NS_OK;
} }

View File

@ -16,6 +16,7 @@
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "jsapi.h" #include "jsapi.h"
#include "jsfriendapi.h"
#include "nsString.h" #include "nsString.h"
class nsIScriptContext; class nsIScriptContext;
@ -137,28 +138,38 @@ public:
} }
}; };
template<typename T>
inline bool
AssignJSString(JSContext *cx, T &dest, JSString *s)
{
size_t len = js::GetStringLength(s);
static_assert(js::MaxStringLength < (1 << 28),
"Shouldn't overflow here or in SetCapacity");
if (MOZ_UNLIKELY(!dest.SetCapacity(len + 1, mozilla::fallible_t()))) {
JS_ReportOutOfMemory(cx);
return false;
}
if (MOZ_UNLIKELY(!js::CopyStringChars(cx, dest.BeginWriting(), s, len))) {
return false;
}
dest.BeginWriting()[len] = '\0';
dest.SetLength(len);
return true;
}
class nsDependentJSString : public nsDependentString class nsAutoJSString : public nsAutoString
{ {
public: public:
/** /**
* nsDependentJSString should be default constructed, which leaves it empty * nsAutoJSString should be default constructed, which leaves it empty
* (this->IsEmpty()), and initialized with one of the init() or infallibleInit() * (this->IsEmpty()), and initialized with one of the init() methods below.
* methods below.
*/ */
nsDependentJSString() {} nsAutoJSString() {}
bool init(JSContext* aContext, JSString* str) bool init(JSContext* aContext, JSString* str)
{ {
size_t length; return AssignJSString(aContext, *this, str);
const jschar* chars = JS_GetStringCharsZAndLength(aContext, str, &length);
if (!chars) {
return false;
}
infallibleInit(chars, length);
return true;
} }
bool init(JSContext* aContext, const JS::Value &v) bool init(JSContext* aContext, const JS::Value &v)
@ -185,27 +196,7 @@ public:
return JS_IdToValue(aContext, id, &v) && init(aContext, v); return JS_IdToValue(aContext, id, &v) && init(aContext, v);
} }
void infallibleInit(const char16_t* aChars, size_t aLength) ~nsAutoJSString() {}
{
MOZ_ASSERT(IsEmpty(), "init() on initialized string");
nsDependentString* base = this;
new (base) nsDependentString(aChars, aLength);
}
// For use when JSID_IS_STRING(id) is known to be true.
void infallibleInit(jsid id)
{
MOZ_ASSERT(JSID_IS_STRING(id));
infallibleInit(JS_GetInternedStringChars(JSID_TO_STRING(id)),
JS_GetStringLength(JSID_TO_STRING(id)));
}
void infallibleInit(JSFlatString* fstr)
{
infallibleInit(JS_GetFlatStringChars(fstr), JS_GetStringLength(JS_FORGET_STRING_FLATNESS(fstr)));
}
~nsDependentJSString() {}
}; };
#endif /* nsJSUtils_h__ */ #endif /* nsJSUtils_h__ */

View File

@ -27,6 +27,7 @@
#include "mozilla/MemoryReporting.h" #include "mozilla/MemoryReporting.h"
#include "nsCycleCollector.h" #include "nsCycleCollector.h"
#include "nsIXPConnect.h" #include "nsIXPConnect.h"
#include "nsJSUtils.h"
#include "MainThreadUtils.h" #include "MainThreadUtils.h"
#include "nsISupportsImpl.h" #include "nsISupportsImpl.h"
#include "qsObjectHelper.h" #include "qsObjectHelper.h"
@ -1857,25 +1858,6 @@ private:
}; };
}; };
template<typename T>
inline bool
AssignJSString(JSContext *cx, T &dest, JSString *s)
{
size_t len = js::GetStringLength(s);
static_assert(js::MaxStringLength < (1 << 28),
"Shouldn't overflow here or in FakeString::SetCapacity");
if (MOZ_UNLIKELY(!dest.SetCapacity(len + 1, mozilla::fallible_t()))) {
JS_ReportOutOfMemory(cx);
return false;
}
if (MOZ_UNLIKELY(!js::CopyStringChars(cx, dest.BeginWriting(), s, len))) {
return false;
}
dest.BeginWriting()[len] = '\0';
dest.SetLength(len);
return true;
}
} // namespace binding_detail } // namespace binding_detail
enum StringificationBehavior { enum StringificationBehavior {
@ -1919,7 +1901,7 @@ ConvertJSValueToString(JSContext* cx, JS::Handle<JS::Value> v,
} }
} }
return binding_detail::AssignJSString(cx, result, s); return AssignJSString(cx, result, s);
} }
bool bool

View File

@ -119,9 +119,9 @@ EventListenerInfo::ToSource(nsAString& aResult)
if (GetJSVal(cx, ac, &v)) { if (GetJSVal(cx, ac, &v)) {
JSString* str = JS_ValueToSource(cx, v); JSString* str = JS_ValueToSource(cx, v);
if (str) { if (str) {
nsDependentJSString depStr; nsAutoJSString autoStr;
if (depStr.init(cx, str)) { if (autoStr.init(cx, str)) {
aResult.Assign(depStr); aResult.Assign(autoStr);
} }
} }
} }

View File

@ -681,7 +681,7 @@ FMRadioService::Observe(nsISupports * aSubject,
} }
JS::Rooted<JSString*> jsKey(cx, key.toString()); JS::Rooted<JSString*> jsKey(cx, key.toString());
nsDependentJSString keyStr; nsAutoJSString keyStr;
if (!keyStr.init(cx, jsKey)) { if (!keyStr.init(cx, jsKey)) {
return NS_OK; return NS_OK;
} }

View File

@ -112,7 +112,7 @@ Key::EncodeJSValInternal(JSContext* aCx, JS::Handle<JS::Value> aVal,
"Unable to encode jsvals."); "Unable to encode jsvals.");
if (aVal.isString()) { if (aVal.isString()) {
nsDependentJSString str; nsAutoJSString str;
if (!str.init(aCx, aVal)) { if (!str.init(aCx, aVal)) {
IDB_REPORT_INTERNAL_ERR(); IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;

View File

@ -285,7 +285,7 @@ KeyPath::Parse(JSContext* aCx, const JS::Value& aValue_, KeyPath* aKeyPath)
for (uint32_t index = 0; index < length; index++) { for (uint32_t index = 0; index < length; index++) {
JS::Rooted<JS::Value> val(aCx); JS::Rooted<JS::Value> val(aCx);
JSString* jsstr; JSString* jsstr;
nsDependentJSString str; nsAutoJSString str;
if (!JS_GetElement(aCx, obj, index, &val) || if (!JS_GetElement(aCx, obj, index, &val) ||
!(jsstr = JS::ToString(aCx, val)) || !(jsstr = JS::ToString(aCx, val)) ||
!str.init(aCx, jsstr)) { !str.init(aCx, jsstr)) {
@ -300,7 +300,7 @@ KeyPath::Parse(JSContext* aCx, const JS::Value& aValue_, KeyPath* aKeyPath)
// Otherwise convert it to a string. // Otherwise convert it to a string.
else if (!aValue.isNull() && !aValue.isUndefined()) { else if (!aValue.isNull() && !aValue.isUndefined()) {
JSString* jsstr; JSString* jsstr;
nsDependentJSString str; nsAutoJSString str;
if (!(jsstr = JS::ToString(aCx, aValue)) || if (!(jsstr = JS::ToString(aCx, aValue)) ||
!str.init(aCx, jsstr)) { !str.init(aCx, jsstr)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

View File

@ -287,7 +287,7 @@ MediaPermissionRequest::Allow(JS::HandleValue aChoices)
if (!JS_GetProperty(cx, obj, AUDIO_PERMISSION_NAME, &v) || !v.isString()) { if (!JS_GetProperty(cx, obj, AUDIO_PERMISSION_NAME, &v) || !v.isString()) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsDependentJSString deviceName; nsAutoJSString deviceName;
if (!deviceName.init(cx, v)) { if (!deviceName.init(cx, v)) {
MOZ_ASSERT(false, "Couldn't initialize string from aChoices"); MOZ_ASSERT(false, "Couldn't initialize string from aChoices");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -301,7 +301,7 @@ MediaPermissionRequest::Allow(JS::HandleValue aChoices)
if (!JS_GetProperty(cx, obj, VIDEO_PERMISSION_NAME, &v) || !v.isString()) { if (!JS_GetProperty(cx, obj, VIDEO_PERMISSION_NAME, &v) || !v.isString()) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsDependentJSString deviceName; nsAutoJSString deviceName;
if (!deviceName.init(cx, v)) { if (!deviceName.init(cx, v)) {
MOZ_ASSERT(false, "Couldn't initialize string from aChoices"); MOZ_ASSERT(false, "Couldn't initialize string from aChoices");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

View File

@ -250,8 +250,11 @@ MmsMessage::Create(int32_t aId,
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
nsDependentJSString receiverStr; nsAutoJSString receiverStr;
receiverStr.init(aCx, receiverJsVal.toString()); if (!receiverStr.init(aCx, receiverJsVal.toString())) {
return NS_ERROR_FAILURE;
}
receivers.AppendElement(receiverStr); receivers.AppendElement(receiverStr);
} }

View File

@ -7,7 +7,7 @@
#include "nsIDOMClassInfo.h" #include "nsIDOMClassInfo.h"
#include "jsapi.h" // For OBJECT_TO_JSVAL and JS_NewDateObjectMsec #include "jsapi.h" // For OBJECT_TO_JSVAL and JS_NewDateObjectMsec
#include "jsfriendapi.h" // For js_DateGetMsecSinceEpoch #include "jsfriendapi.h" // For js_DateGetMsecSinceEpoch
#include "nsJSUtils.h" // For nsDependentJSString #include "nsJSUtils.h" // For nsAutoJSString
#include "nsTArrayHelpers.h" // For nsTArrayToJSArray #include "nsTArrayHelpers.h" // For nsTArrayToJSArray
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType #include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
@ -70,8 +70,11 @@ MobileMessageThread::Create(uint64_t aId,
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
nsDependentJSString str; nsAutoJSString str;
str.init(aCx, val.toString()); if (!str.init(aCx, val.toString())) {
return NS_ERROR_FAILURE;
}
data.participants().AppendElement(str); data.participants().AppendElement(str);
} }
} }

View File

@ -170,8 +170,10 @@ SmsFilter::SetNumbers(JSContext* aCx, JS::Handle<JS::Value> aNumbers)
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
nsDependentJSString number; nsAutoJSString number;
number.init(aCx, jsNumber.toString()); if (!number.init(aCx, jsNumber.toString())) {
return NS_ERROR_FAILURE;
}
numbers.AppendElement(number); numbers.AppendElement(number);
} }

View File

@ -213,7 +213,7 @@ TCPSocketChild::SendSend(JS::Handle<JS::Value> aData,
{ {
if (aData.isString()) { if (aData.isString()) {
JSString* jsstr = aData.toString(); JSString* jsstr = aData.toString();
nsDependentJSString str; nsAutoJSString str;
bool ok = str.init(aCx, jsstr); bool ok = str.init(aCx, jsstr);
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE); NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
SendData(str, aTrackingNumber); SendData(str, aTrackingNumber);

View File

@ -206,7 +206,7 @@ TCPSocketParent::SendEvent(const nsAString& aType, JS::Handle<JS::Value> aDataVa
CallbackData data; CallbackData data;
if (aDataVal.isString()) { if (aDataVal.isString()) {
JSString* jsstr = aDataVal.toString(); JSString* jsstr = aDataVal.toString();
nsDependentJSString str; nsAutoJSString str;
if (!str.init(aCx, jsstr)) { if (!str.init(aCx, jsstr)) {
FireInteralError(this, __LINE__); FireInteralError(this, __LINE__);
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -235,7 +235,7 @@ TCPSocketParent::SendEvent(const nsAString& aType, JS::Handle<JS::Value> aDataVa
data = SendableData(arr); data = SendableData(arr);
} else { } else {
nsDependentJSString name; nsAutoJSString name;
JS::Rooted<JS::Value> val(aCx); JS::Rooted<JS::Value> val(aCx);
if (!JS_GetProperty(aCx, obj, "name", &val)) { if (!JS_GetProperty(aCx, obj, "name", &val)) {

View File

@ -282,7 +282,7 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
} else if (v.isUndefined()) { } else if (v.isUndefined()) {
return NS_ERROR_DOM_RETVAL_UNDEFINED; return NS_ERROR_DOM_RETVAL_UNDEFINED;
} else { } else {
nsDependentJSString result; nsAutoJSString result;
if (!result.init(cx, v)) { if (!result.init(cx, v)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }

View File

@ -355,7 +355,7 @@ AudioManager::Observe(nsISupports* aSubject,
if (!jsKey) { if (!jsKey) {
return NS_OK; return NS_OK;
} }
nsDependentJSString keyStr; nsAutoJSString keyStr;
if (!keyStr.init(cx, jsKey) || !keyStr.EqualsLiteral("audio.volume.bt_sco")) { if (!keyStr.init(cx, jsKey) || !keyStr.EqualsLiteral("audio.volume.bt_sco")) {
return NS_OK; return NS_OK;
} }

View File

@ -250,7 +250,7 @@ AutoMounterSetting::Observe(nsISupports* aSubject,
} }
JSString *jsKey = JS::ToString(cx, key); JSString *jsKey = JS::ToString(cx, key);
nsDependentJSString keyStr; nsAutoJSString keyStr;
if (!keyStr.init(cx, jsKey)) { if (!keyStr.init(cx, jsKey)) {
return NS_OK; return NS_OK;
} }

View File

@ -850,8 +850,10 @@ GonkGPSGeolocationProvider::Handle(const nsAString& aName,
NS_ENSURE_TRUE(cx, NS_OK); NS_ENSURE_TRUE(cx, NS_OK);
// NB: No need to enter a compartment to read the contents of a string. // NB: No need to enter a compartment to read the contents of a string.
nsDependentJSString apn; nsAutoJSString apn;
apn.init(cx, aResult.toString()); if (!apn.init(cx, aResult.toString())) {
return NS_ERROR_FAILURE;
}
if (!apn.IsEmpty()) { if (!apn.IsEmpty()) {
SetAGpsDataConn(apn); SetAGpsDataConn(apn);
} }

View File

@ -144,7 +144,7 @@ nsresult TimeZoneSettingObserver::SetTimeZone(const JS::Value &aValue, JSContext
{ {
// Convert the JS value to a nsCString type. // Convert the JS value to a nsCString type.
// The value should be a JS string like "America/Chicago" or "UTC-05:00". // The value should be a JS string like "America/Chicago" or "UTC-05:00".
nsDependentJSString valueStr; nsAutoJSString valueStr;
if (!valueStr.init(aContext, aValue.toString())) { if (!valueStr.init(aContext, aValue.toString())) {
ERR("Failed to convert JS value to nsCString"); ERR("Failed to convert JS value to nsCString");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

View File

@ -190,7 +190,7 @@ private:
return false; return false;
} }
nsDependentJSString contentType; nsAutoJSString contentType;
if (!contentType.init(aCx, jsContentType)) { if (!contentType.init(aCx, jsContentType)) {
return false; return false;
} }

View File

@ -5192,9 +5192,9 @@ WorkerPrivate::ReportError(JSContext* aCx, const char* aMessage,
JS::Rooted<JSString*> messageStr(aCx, JS::Rooted<JSString*> messageStr(aCx,
js::ErrorReportToString(aCx, aReport)); js::ErrorReportToString(aCx, aReport));
if (messageStr) { if (messageStr) {
nsDependentJSString depStr; nsAutoJSString autoStr;
if (depStr.init(aCx, messageStr)) { if (autoStr.init(aCx, messageStr)) {
message = depStr; message = autoStr;
} }
} }
filename = NS_ConvertUTF8toUTF16(aReport->filename); filename = NS_ConvertUTF8toUTF16(aReport->filename);

View File

@ -1100,13 +1100,13 @@ nsXBLBinding::LookupMember(JSContext* aCx, JS::Handle<jsid> aId,
// Get the string as an nsString before doing anything, so we can make // Get the string as an nsString before doing anything, so we can make
// convenient comparisons during our search. // convenient comparisons during our search.
//
// Note: the infallibleInit call below depends on this check.
if (!JSID_IS_STRING(aId)) { if (!JSID_IS_STRING(aId)) {
return true; return true;
} }
nsDependentJSString name; nsAutoJSString name;
name.infallibleInit(aId); if (!name.init(aCx, JSID_TO_STRING(aId))) {
return false;
}
// We have a weak reference to our bound element, so make sure it's alive. // We have a weak reference to our bound element, so make sure it's alive.
if (!mBoundElement || !mBoundElement->GetWrapper()) { if (!mBoundElement || !mBoundElement->GetWrapper()) {

View File

@ -181,7 +181,7 @@ InstallXBLField(JSContext* cx,
// Field[GS]etter where we attempt a cross-compartment call), we must enter // Field[GS]etter where we attempt a cross-compartment call), we must enter
// the callee's compartment to access its reserved slots. // the callee's compartment to access its reserved slots.
nsXBLPrototypeBinding* protoBinding; nsXBLPrototypeBinding* protoBinding;
nsDependentJSString fieldName; nsAutoJSString fieldName;
{ {
JSAutoCompartment ac(cx, callee); JSAutoCompartment ac(cx, callee);
@ -189,8 +189,9 @@ InstallXBLField(JSContext* cx,
xblProto = &js::GetFunctionNativeReserved(callee, XBLPROTO_SLOT).toObject(); xblProto = &js::GetFunctionNativeReserved(callee, XBLPROTO_SLOT).toObject();
JS::Rooted<JS::Value> name(cx, js::GetFunctionNativeReserved(callee, FIELD_SLOT)); JS::Rooted<JS::Value> name(cx, js::GetFunctionNativeReserved(callee, FIELD_SLOT));
JSFlatString* fieldStr = JS_ASSERT_STRING_IS_FLAT(name.toString()); if (!fieldName.init(cx, name.toString())) {
fieldName.infallibleInit(fieldStr); return false;
}
MOZ_ALWAYS_TRUE(JS_ValueToId(cx, name, idp)); MOZ_ALWAYS_TRUE(JS_ValueToId(cx, name, idp));

View File

@ -44,7 +44,7 @@ EXTRA_COMPONENTS += [
FAIL_ON_WARNINGS = True FAIL_ON_WARNINGS = True
# For nsDependentJSString # For nsAutoJSString
LOCAL_INCLUDES += ["/dom/base"] LOCAL_INCLUDES += ["/dom/base"]
LOCAL_INCLUDES += [ LOCAL_INCLUDES += [

View File

@ -1437,7 +1437,7 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult)
JS::Rooted<JSString*> str(cx, JS::ToString(cx, v)); JS::Rooted<JSString*> str(cx, JS::ToString(cx, v));
NS_ENSURE_TRUE(str, NS_ERROR_FAILURE); NS_ENSURE_TRUE(str, NS_ERROR_FAILURE);
nsDependentJSString value; nsAutoJSString value;
NS_ENSURE_TRUE(value.init(cx, str), NS_ERROR_FAILURE); NS_ENSURE_TRUE(value.init(cx, str), NS_ERROR_FAILURE);
*aResult = new StringResult(value, nullptr); *aResult = new StringResult(value, nullptr);

View File

@ -596,13 +596,13 @@ XPCShellEnvironment::EvaluateString(const nsString& aString,
if (ok && result != JSVAL_VOID) { if (ok && result != JSVAL_VOID) {
JSErrorReporter old = JS_SetErrorReporter(cx, nullptr); JSErrorReporter old = JS_SetErrorReporter(cx, nullptr);
JSString* str = JS::ToString(cx, result); JSString* str = JS::ToString(cx, result);
nsDependentJSString depStr; nsAutoJSString autoStr;
if (str) if (str)
depStr.init(cx, str); autoStr.init(cx, str);
JS_SetErrorReporter(cx, old); JS_SetErrorReporter(cx, old);
if (!depStr.IsEmpty() && aResult) { if (!autoStr.IsEmpty() && aResult) {
aResult->Assign(depStr); aResult->Assign(autoStr);
} }
} }

View File

@ -31,7 +31,7 @@ include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul' FINAL_LIBRARY = 'xul'
# For xpcshell error messages and nsDependentJSString # For xpcshell error messages and nsAutoJSString
LOCAL_INCLUDES += [ LOCAL_INCLUDES += [
'/dom/base', '/dom/base',
'/js/xpconnect/src', '/js/xpconnect/src',

View File

@ -254,10 +254,10 @@ JavaScriptShared::toVariant(JSContext *cx, JS::HandleValue from, JSVariant *to)
case JSTYPE_STRING: case JSTYPE_STRING:
{ {
nsDependentJSString dep; nsAutoJSString autoStr;
if (!dep.init(cx, from)) if (!autoStr.init(cx, from))
return false; return false;
*to = dep; *to = autoStr;
return true; return true;
} }

View File

@ -344,7 +344,7 @@ WrapperOwner::toString(JSContext *cx, HandleObject cpow, JS::CallArgs &args)
return true; return true;
RootedString cpowResult(cx, args.rval().toString()); RootedString cpowResult(cx, args.rval().toString());
nsDependentJSString toStringResult; nsAutoJSString toStringResult;
if (!toStringResult.init(cx, cpowResult)) if (!toStringResult.init(cx, cpowResult))
return false; return false;

View File

@ -283,13 +283,13 @@ SandboxEvalInWindow(JSContext *cx, unsigned argc, jsval *vp)
RootedString srcString(cx, args[0].toString()); RootedString srcString(cx, args[0].toString());
RootedObject targetScope(cx, &args[1].toObject()); RootedObject targetScope(cx, &args[1].toObject());
nsDependentJSString srcDepString; nsAutoJSString srcAutoString;
if (!srcDepString.init(cx, srcString)) { if (!srcAutoString.init(cx, srcString)) {
JS_ReportError(cx, "Source string is invalid"); JS_ReportError(cx, "Source string is invalid");
return false; return false;
} }
return EvalInWindow(cx, srcDepString, targetScope, args.rval()); return EvalInWindow(cx, srcAutoString, targetScope, args.rval());
} }
static bool static bool
@ -1037,7 +1037,7 @@ ParsePrincipal(JSContext *cx, HandleString codebase, nsIPrincipal **principal)
MOZ_ASSERT(principal); MOZ_ASSERT(principal);
MOZ_ASSERT(codebase); MOZ_ASSERT(codebase);
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
nsDependentJSString codebaseStr; nsAutoJSString codebaseStr;
NS_ENSURE_TRUE(codebaseStr.init(cx, codebase), false); NS_ENSURE_TRUE(codebaseStr.init(cx, codebase), false);
nsresult rv = NS_NewURI(getter_AddRefs(uri), codebaseStr); nsresult rv = NS_NewURI(getter_AddRefs(uri), codebaseStr);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@ -1283,8 +1283,10 @@ OptionsBase::ParseString(const char *name, nsString &prop)
return false; return false;
} }
nsDependentJSString strVal; nsAutoJSString strVal;
strVal.init(mCx, value.toString()); if (!strVal.init(mCx, value.toString()))
return false;
prop = strVal; prop = strVal;
return true; return true;
} }

View File

@ -102,13 +102,13 @@ private:
ChangeCase(JSContext* cx, HandleString src, MutableHandleValue rval, ChangeCase(JSContext* cx, HandleString src, MutableHandleValue rval,
void(*changeCaseFnc)(const nsAString&, nsAString&)) void(*changeCaseFnc)(const nsAString&, nsAString&))
{ {
nsDependentJSString depStr; nsAutoJSString autoStr;
if (!depStr.init(cx, src)) { if (!autoStr.init(cx, src)) {
return false; return false;
} }
nsAutoString result; nsAutoString result;
changeCaseFnc(depStr, result); changeCaseFnc(autoStr, result);
JSString *ucstr = JSString *ucstr =
JS_NewUCStringCopyN(cx, result.get(), result.Length()); JS_NewUCStringCopyN(cx, result.get(), result.Length());
@ -149,14 +149,14 @@ private:
} }
} }
nsDependentJSString depStr1, depStr2; nsAutoJSString autoStr1, autoStr2;
if (!depStr1.init(cx, src1) || !depStr2.init(cx, src2)) { if (!autoStr1.init(cx, src1) || !autoStr2.init(cx, src2)) {
return false; return false;
} }
int32_t result; int32_t result;
rv = mCollation->CompareString(nsICollation::kCollationStrengthDefault, rv = mCollation->CompareString(nsICollation::kCollationStrengthDefault,
depStr1, depStr2, &result); autoStr1, autoStr2, &result);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
xpc::Throw(cx, rv); xpc::Throw(cx, rv);

View File

@ -148,8 +148,10 @@ IsFrameId(JSContext *cx, JSObject *objArg, jsid idArg)
if (JSID_IS_INT(id)) { if (JSID_IS_INT(id)) {
col->Item(JSID_TO_INT(id), getter_AddRefs(domwin)); col->Item(JSID_TO_INT(id), getter_AddRefs(domwin));
} else if (JSID_IS_STRING(id)) { } else if (JSID_IS_STRING(id)) {
nsDependentJSString idAsString; nsAutoJSString idAsString;
idAsString.infallibleInit(id); if (!idAsString.init(cx, JSID_TO_STRING(id))) {
return false;
}
col->NamedItem(idAsString, getter_AddRefs(domwin)); col->NamedItem(idAsString, getter_AddRefs(domwin));
} }

View File

@ -458,7 +458,7 @@ inline bool
SilentFailure(JSContext *cx, HandleId id, const char *reason) SilentFailure(JSContext *cx, HandleId id, const char *reason)
{ {
#ifdef DEBUG #ifdef DEBUG
nsDependentJSString name; nsAutoJSString name;
if (!name.init(cx, id)) if (!name.init(cx, id))
return false; return false;
AutoFilename filename; AutoFilename filename;
@ -2252,9 +2252,9 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
JSID_IS_STRING(id) && JSID_IS_STRING(id) &&
(win = AsWindow(cx, wrapper))) (win = AsWindow(cx, wrapper)))
{ {
// Note - The infallibleInit() depends on the JSID_IS_STRING check above. nsAutoJSString name;
nsDependentJSString name; if (!name.init(cx, JSID_TO_STRING(id)))
name.infallibleInit(id); return false;
nsCOMPtr<nsIDOMWindow> childDOMWin = win->GetChildWindow(name); nsCOMPtr<nsIDOMWindow> childDOMWin = win->GetChildWindow(name);
if (childDOMWin) { if (childDOMWin) {
nsGlobalWindow *cwin = static_cast<nsGlobalWindow*>(childDOMWin.get()); nsGlobalWindow *cwin = static_cast<nsGlobalWindow*>(childDOMWin.get());

View File

@ -409,7 +409,7 @@ bool PACDnsResolve(JSContext *cx, unsigned int argc, JS::Value *vp)
if (!JS_ConvertArguments(cx, args, "S", arg1.address())) if (!JS_ConvertArguments(cx, args, "S", arg1.address()))
return false; return false;
nsDependentJSString hostName; nsAutoJSString hostName;
nsAutoCString dottedDecimal; nsAutoCString dottedDecimal;
if (!hostName.init(cx, arg1)) if (!hostName.init(cx, arg1))
@ -458,11 +458,11 @@ bool PACProxyAlert(JSContext *cx, unsigned int argc, JS::Value *vp)
if (!JS_ConvertArguments(cx, args, "S", arg1.address())) if (!JS_ConvertArguments(cx, args, "S", arg1.address()))
return false; return false;
nsDependentJSString message; nsAutoJSString message;
if (!message.init(cx, arg1)) if (!message.init(cx, arg1))
return false; return false;
nsString alertMessage; nsAutoString alertMessage;
alertMessage.SetCapacity(32 + message.Length()); alertMessage.SetCapacity(32 + message.Length());
alertMessage += NS_LITERAL_STRING("PAC-alert: "); alertMessage += NS_LITERAL_STRING("PAC-alert: ");
alertMessage += message; alertMessage += message;
@ -706,7 +706,7 @@ ProxyAutoConfig::GetProxyForURI(const nsCString &aTestURI,
bool ok = JS_CallFunctionName(cx, global, "FindProxyForURL", args, &rval); bool ok = JS_CallFunctionName(cx, global, "FindProxyForURL", args, &rval);
if (ok && rval.isString()) { if (ok && rval.isString()) {
nsDependentJSString pacString; nsAutoJSString pacString;
if (pacString.init(cx, rval.toString())) { if (pacString.init(cx, rval.toString())) {
CopyUTF16toUTF8(pacString, result); CopyUTF16toUTF8(pacString, result);
rv = NS_OK; rv = NS_OK;

View File

@ -972,13 +972,13 @@ cryptojs_ReadArgsAndGenerateKey(JSContext *cx,
jsString = JS::ToString(cx, v); jsString = JS::ToString(cx, v);
NS_ENSURE_TRUE(jsString, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(jsString, NS_ERROR_OUT_OF_MEMORY);
argv[2] = STRING_TO_JSVAL(jsString); argv[2] = STRING_TO_JSVAL(jsString);
nsDependentJSString dependentKeyGenAlg; nsAutoJSString autoJSKeyGenAlg;
NS_ENSURE_TRUE(dependentKeyGenAlg.init(cx, jsString), NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(autoJSKeyGenAlg.init(cx, jsString), NS_ERROR_UNEXPECTED);
nsAutoString keyGenAlg(dependentKeyGenAlg); nsAutoString keyGenAlg(autoJSKeyGenAlg);
keyGenAlg.Trim("\r\n\t "); keyGenAlg.Trim("\r\n\t ");
keyGenType->keyGenType = cryptojs_interpret_key_gen_type(keyGenAlg); keyGenType->keyGenType = cryptojs_interpret_key_gen_type(keyGenAlg);
if (keyGenType->keyGenType == invalidKeyGen) { if (keyGenType->keyGenType == invalidKeyGen) {
NS_LossyConvertUTF16toASCII keyGenAlgNarrow(dependentKeyGenAlg); NS_LossyConvertUTF16toASCII keyGenAlgNarrow(autoJSKeyGenAlg);
JS_ReportError(cx, "%s%s%s", JS_ERROR, JS_ReportError(cx, "%s%s%s", JS_ERROR,
"invalid key generation argument:", "invalid key generation argument:",
keyGenAlgNarrow.get()); keyGenAlgNarrow.get());
@ -994,7 +994,7 @@ cryptojs_ReadArgsAndGenerateKey(JSContext *cx,
*slot,willEscrow); *slot,willEscrow);
if (rv != NS_OK) { if (rv != NS_OK) {
NS_LossyConvertUTF16toASCII keyGenAlgNarrow(dependentKeyGenAlg); NS_LossyConvertUTF16toASCII keyGenAlgNarrow(autoJSKeyGenAlg);
JS_ReportError(cx,"%s%s%s", JS_ERROR, JS_ReportError(cx,"%s%s%s", JS_ERROR,
"could not generate the key for algorithm ", "could not generate the key for algorithm ",
keyGenAlgNarrow.get()); keyGenAlgNarrow.get());

View File

@ -126,8 +126,8 @@ convertJSValToVariant(
return new FloatVariant(aValue.toDouble()); return new FloatVariant(aValue.toDouble());
if (aValue.isString()) { if (aValue.isString()) {
nsDependentJSString value; nsAutoJSString value;
if (!value.init(aCtx, aValue)) if (!value.init(aCtx, aValue.toString()))
return nullptr; return nullptr;
return new TextVariant(value); return new TextVariant(value);
} }

View File

@ -754,7 +754,7 @@ XRE_SendTestShellCommand(JSContext* aCx,
TestShellParent* tsp = GetOrCreateTestShellParent(); TestShellParent* tsp = GetOrCreateTestShellParent();
NS_ENSURE_TRUE(tsp, false); NS_ENSURE_TRUE(tsp, false);
nsDependentJSString command; nsAutoJSString command;
NS_ENSURE_TRUE(command.init(aCx, cmd), false); NS_ENSURE_TRUE(command.init(aCx, cmd), false);
if (!aCallback) { if (!aCallback) {