зеркало из https://github.com/mozilla/gecko-dev.git
Bug 866450 Part 2: Fix rooting hazards under content/ and dom/ r=bz
This commit is contained in:
Родитель
1527681014
Коммит
4b33572311
|
@ -1683,7 +1683,7 @@ public:
|
|||
*/
|
||||
static bool CanAccessNativeAnon();
|
||||
|
||||
static nsresult WrapNative(JSContext *cx, JSObject *scope,
|
||||
static nsresult WrapNative(JSContext *cx, JS::HandleObject scope,
|
||||
nsISupports *native, const nsIID* aIID,
|
||||
JS::Value *vp,
|
||||
// If non-null aHolder will keep the Value alive
|
||||
|
@ -1696,7 +1696,7 @@ public:
|
|||
}
|
||||
|
||||
// Same as the WrapNative above, but use this one if aIID is nsISupports' IID.
|
||||
static nsresult WrapNative(JSContext *cx, JSObject *scope,
|
||||
static nsresult WrapNative(JSContext *cx, JS::HandleObject scope,
|
||||
nsISupports *native, JS::Value *vp,
|
||||
// If non-null aHolder will keep the Value alive
|
||||
// while there's a ref to it
|
||||
|
@ -1706,7 +1706,7 @@ public:
|
|||
return WrapNative(cx, scope, native, nullptr, nullptr, vp, aHolder,
|
||||
aAllowWrapping);
|
||||
}
|
||||
static nsresult WrapNative(JSContext *cx, JSObject *scope,
|
||||
static nsresult WrapNative(JSContext *cx, JS::HandleObject scope,
|
||||
nsISupports *native, nsWrapperCache *cache,
|
||||
JS::Value *vp,
|
||||
// If non-null aHolder will keep the Value alive
|
||||
|
@ -2146,7 +2146,7 @@ private:
|
|||
static bool CanCallerAccess(nsIPrincipal* aSubjectPrincipal,
|
||||
nsIPrincipal* aPrincipal);
|
||||
|
||||
static nsresult WrapNative(JSContext *cx, JSObject *scope,
|
||||
static nsresult WrapNative(JSContext *cx, JS::HandleObject scope,
|
||||
nsISupports *native, nsWrapperCache *cache,
|
||||
const nsIID* aIID, JS::Value *vp,
|
||||
nsIXPConnectJSObjectHolder** aHolder,
|
||||
|
|
|
@ -2142,7 +2142,7 @@ protected:
|
|||
|
||||
// All document WrapNode implementations MUST call this method. A
|
||||
// false return value means an exception was thrown.
|
||||
bool PostCreateWrapper(JSContext* aCx, JSObject *aNewObject);
|
||||
bool PostCreateWrapper(JSContext* aCx, JSHandleObject aNewObject);
|
||||
|
||||
nsCString mReferrer;
|
||||
nsString mLastModified;
|
||||
|
|
|
@ -5839,7 +5839,7 @@ nsContentUtils::DispatchXULCommand(nsIContent* aTarget,
|
|||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
|
||||
nsContentUtils::WrapNative(JSContext *cx, JS::HandleObject scope, nsISupports *native,
|
||||
nsWrapperCache *cache, const nsIID* aIID, JS::Value *vp,
|
||||
nsIXPConnectJSObjectHolder **aHolder,
|
||||
bool aAllowWrapping)
|
||||
|
@ -5929,7 +5929,7 @@ nsContentUtils::CreateBlobBuffer(JSContext* aCx,
|
|||
} else {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
JSObject* scope = JS_GetGlobalForScopeChain(aCx);
|
||||
JS::Rooted<JSObject*> scope(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
return nsContentUtils::WrapNative(aCx, scope, blob, &aBlob, nullptr, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -4968,7 +4968,7 @@ CustomElementConstructor(JSContext *aCx, unsigned aArgc, JS::Value* aVp)
|
|||
{
|
||||
JS::Value calleeVal = JS_CALLEE(aCx, aVp);
|
||||
|
||||
JSObject* global = JS_GetGlobalForObject(aCx, &calleeVal.toObject());
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, &calleeVal.toObject()));
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryWrapper(aCx, global);
|
||||
MOZ_ASSERT(window, "Should have a non-null window");
|
||||
|
||||
|
@ -6574,7 +6574,7 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
|
|||
bool sameDocument = oldDocument == this;
|
||||
|
||||
AutoJSContext cx;
|
||||
JSObject *newScope = nullptr;
|
||||
JS::Rooted<JSObject*> newScope(cx, nullptr);
|
||||
if (!sameDocument) {
|
||||
newScope = GetWrapper();
|
||||
if (!newScope && GetScopeObject() && GetScopeObject()->GetGlobalJSObject()) {
|
||||
|
@ -6582,7 +6582,7 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
|
|||
// irrelevant, given that we're passing aAllowWrapping = false, and
|
||||
// documents should always insist on being wrapped in an canonical
|
||||
// scope. But we try to pass something sane anyway.
|
||||
JSObject *global = GetScopeObject()->GetGlobalJSObject();
|
||||
JS::Rooted<JSObject*> global(cx, GetScopeObject()->GetGlobalJSObject());
|
||||
|
||||
JS::Value v;
|
||||
rv = nsContentUtils::WrapNative(cx, global, this, this, &v, nullptr,
|
||||
|
@ -11200,7 +11200,7 @@ nsIDocument::Evaluate(const nsAString& aExpression, nsINode* aContextNode,
|
|||
// This is just a hack around the fact that window.document is not
|
||||
// [Unforgeable] yet.
|
||||
bool
|
||||
nsIDocument::PostCreateWrapper(JSContext* aCx, JSObject *aNewObject)
|
||||
nsIDocument::PostCreateWrapper(JSContext* aCx, JSHandleObject aNewObject)
|
||||
{
|
||||
MOZ_ASSERT(IsDOMBinding());
|
||||
|
||||
|
|
|
@ -660,9 +660,9 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
|||
NS_ENSURE_TRUE(param, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS::Value targetv;
|
||||
nsContentUtils::WrapNative(ctx,
|
||||
JS_GetGlobalForObject(ctx, object),
|
||||
aTarget, &targetv, nullptr, true);
|
||||
|
||||
JS::Rooted<JSObject*> global(ctx, JS_GetGlobalForObject(ctx, object));
|
||||
nsContentUtils::WrapNative(ctx, global, aTarget, &targetv, nullptr, true);
|
||||
|
||||
// To keep compatibility with e10s message manager,
|
||||
// define empty objects array.
|
||||
|
@ -714,9 +714,9 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
|||
} else {
|
||||
defaultThisValue = aTarget;
|
||||
}
|
||||
nsContentUtils::WrapNative(ctx,
|
||||
JS_GetGlobalForObject(ctx, object),
|
||||
defaultThisValue, thisValue.address(), nullptr, true);
|
||||
JS::Rooted<JSObject*> global(ctx, JS_GetGlobalForObject(ctx, object));
|
||||
nsContentUtils::WrapNative(ctx, global, defaultThisValue,
|
||||
thisValue.address(), nullptr, true);
|
||||
} else {
|
||||
// If the listener is a JS object which has receiveMessage function:
|
||||
if (!JS_GetProperty(ctx, object, "receiveMessage", &funval) ||
|
||||
|
|
|
@ -1002,7 +1002,7 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
|
|||
}
|
||||
|
||||
JS::Value result = JSVAL_NULL;
|
||||
JSObject* scope = JS_GetGlobalForScopeChain(aCx);
|
||||
JS::Rooted<JSObject*> scope(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
aRv = nsContentUtils::WrapNative(aCx, scope, mResponseBlob, &result,
|
||||
nullptr, true);
|
||||
return result;
|
||||
|
@ -1013,7 +1013,7 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
|
|||
return JSVAL_NULL;
|
||||
}
|
||||
|
||||
JSObject* scope = JS_GetGlobalForScopeChain(aCx);
|
||||
JS::Rooted<JSObject*> scope(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
JS::Value result = JSVAL_NULL;
|
||||
aRv = nsContentUtils::WrapNative(aCx, scope, mResponseXML, &result,
|
||||
nullptr, true);
|
||||
|
@ -3636,7 +3636,7 @@ nsXMLHttpRequest::GetInterface(JSContext* aCx, nsIJSID* aIID, ErrorResult& aRv)
|
|||
|
||||
JS::Rooted<JSObject*> wrapper(aCx, GetWrapper());
|
||||
JSAutoCompartment ac(aCx, wrapper);
|
||||
JSObject* global = JS_GetGlobalForObject(aCx, wrapper);
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, wrapper));
|
||||
aRv = nsContentUtils::WrapNative(aCx, global, result, iid, &v);
|
||||
return aRv.Failed() ? JSVAL_NULL : v;
|
||||
}
|
||||
|
|
|
@ -1374,8 +1374,6 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
|
|||
if (! global)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
JSObject *scope = global->GetGlobalJSObject();
|
||||
|
||||
nsIScriptContext *context = global->GetContext();
|
||||
if (! context)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
@ -1385,6 +1383,8 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
|
|||
if (! jscontext)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
JS::Rooted<JSObject*> scope(jscontext, global->GetGlobalJSObject());
|
||||
|
||||
JSAutoRequest ar(jscontext);
|
||||
|
||||
JS::Value v;
|
||||
|
|
|
@ -6588,7 +6588,7 @@ PostMessageReadStructuredClone(JSContext* cx,
|
|||
|
||||
nsISupports* supports;
|
||||
if (JS_ReadBytes(reader, &supports, sizeof(supports))) {
|
||||
JSObject* global = JS_GetGlobalForScopeChain(cx);
|
||||
JS::Rooted<JSObject*> global(cx, JS_GetGlobalForScopeChain(cx));
|
||||
if (global) {
|
||||
JS::Value val;
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
|
||||
|
|
|
@ -1471,7 +1471,7 @@ AtomIsEventHandlerName(nsIAtom *aName)
|
|||
// Helper function to find the JSObject associated with a (presumably DOM)
|
||||
// interface.
|
||||
nsresult
|
||||
nsJSContext::JSObjectFromInterface(nsISupports* aTarget, JSObject* aScope, JSObject** aRet)
|
||||
nsJSContext::JSObjectFromInterface(nsISupports* aTarget, JS::HandleObject aScope, JSObject** aRet)
|
||||
{
|
||||
// It is legal to specify a null target.
|
||||
if (!aTarget) {
|
||||
|
@ -1516,7 +1516,8 @@ nsJSContext::BindCompiledEventHandler(nsISupports* aTarget, JSObject* aScope,
|
|||
|
||||
// Get the jsobject associated with this target
|
||||
JSObject *target = nullptr;
|
||||
nsresult rv = JSObjectFromInterface(aTarget, aScope, &target);
|
||||
JS::Rooted<JSObject*> scope(mContext, aScope);
|
||||
nsresult rv = JSObjectFromInterface(aTarget, scope, &target);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -1672,8 +1673,9 @@ nsJSContext::SetProperty(JSObject* aTarget, const char* aPropName, nsISupports*
|
|||
|
||||
Maybe<nsRootedJSValueArray> tempStorage;
|
||||
|
||||
JS::Rooted<JSObject*> global(mContext, GetNativeGlobal());
|
||||
nsresult rv =
|
||||
ConvertSupportsTojsvals(aArgs, GetNativeGlobal(), &argc, &argv, tempStorage);
|
||||
ConvertSupportsTojsvals(aArgs, global, &argc, &argv, tempStorage);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::Value vargs;
|
||||
|
@ -1704,7 +1706,7 @@ nsJSContext::SetProperty(JSObject* aTarget, const char* aPropName, nsISupports*
|
|||
|
||||
nsresult
|
||||
nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs,
|
||||
JSObject *aScope,
|
||||
JS::HandleObject aScope,
|
||||
uint32_t *aArgc,
|
||||
JS::Value **aArgv,
|
||||
Maybe<nsRootedJSValueArray> &aTempStorage)
|
||||
|
@ -1976,7 +1978,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
|
|||
AutoFree iidGuard(iid); // Free iid upon destruction.
|
||||
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
|
||||
JSObject *global = xpc_UnmarkGrayObject(::JS_GetGlobalObject(cx));
|
||||
JS::Rooted<JSObject*> global(cx, xpc_UnmarkGrayObject(::JS_GetGlobalObject(cx)));
|
||||
JS::Value v;
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, global,
|
||||
data, iid, &v,
|
||||
|
|
|
@ -163,7 +163,7 @@ protected:
|
|||
|
||||
// Helper to convert xpcom datatypes to jsvals.
|
||||
nsresult ConvertSupportsTojsvals(nsISupports *aArgs,
|
||||
JSObject *aScope,
|
||||
JS::HandleObject aScope,
|
||||
uint32_t *aArgc,
|
||||
JS::Value **aArgv,
|
||||
mozilla::Maybe<nsRootedJSValueArray> &aPoolRelease);
|
||||
|
@ -172,7 +172,7 @@ protected:
|
|||
|
||||
// given an nsISupports object (presumably an event target or some other
|
||||
// DOM object), get (or create) the JSObject wrapping it.
|
||||
nsresult JSObjectFromInterface(nsISupports *aSup, JSObject *aScript,
|
||||
nsresult JSObjectFromInterface(nsISupports *aSup, JS::HandleObject aScript,
|
||||
JSObject **aRet);
|
||||
|
||||
// Report the pending exception on our mContext, if any. This
|
||||
|
|
|
@ -923,8 +923,9 @@ InterfaceToJsval(nsPIDOMWindow* aWindow, nsISupports* aObject, const nsIID* aIID
|
|||
}
|
||||
|
||||
JS::Value someJsVal;
|
||||
JS::Rooted<JSObject*> global(cx, JS_GetGlobalObject(cx));
|
||||
nsresult rv = nsContentUtils::WrapNative(cx,
|
||||
JS_GetGlobalObject(cx),
|
||||
global,
|
||||
aObject,
|
||||
aIID,
|
||||
&someJsVal);
|
||||
|
|
|
@ -223,10 +223,9 @@ ArchiveRequest::GetFileResult(JSContext* aCx,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (filename == mFilename) {
|
||||
nsresult rv = nsContentUtils::WrapNative(
|
||||
aCx, JS_GetGlobalForScopeChain(aCx),
|
||||
file, &NS_GET_IID(nsIDOMFile), aValue);
|
||||
return rv;
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
return nsContentUtils::WrapNative(aCx, global, file,
|
||||
&NS_GET_IID(nsIDOMFile), aValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,8 +246,9 @@ ArchiveRequest::GetFilesResult(JSContext* aCx,
|
|||
nsCOMPtr<nsIDOMFile> file = aFileList[i];
|
||||
|
||||
JS::Value value;
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, JS_GetGlobalForScopeChain(aCx),
|
||||
file, &NS_GET_IID(nsIDOMFile), &value);
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, global, file,
|
||||
&NS_GET_IID(nsIDOMFile), &value);
|
||||
if (NS_FAILED(rv) || !JS_SetElement(aCx, array, i, &value)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -191,8 +191,9 @@ GetFileHelper::GetSuccessResult(JSContext* aCx, JS::Value* aVal)
|
|||
nsCOMPtr<nsIDOMFile> domFile =
|
||||
mFileHandle->CreateFileObject(mLockedFile, mParams->Size());
|
||||
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(aCx, JS_GetGlobalForScopeChain(aCx), domFile,
|
||||
nsContentUtils::WrapNative(aCx, global, domFile,
|
||||
&NS_GET_IID(nsIDOMFile), aVal);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ HelperBase::WrapNative(JSContext* aCx,
|
|||
NS_ASSERTION(aResult, "Null pointer!");
|
||||
NS_ASSERTION(mRequest, "Null request!");
|
||||
|
||||
JSObject* global = mRequest->GetParentObject();
|
||||
JS::Rooted<JSObject*> global(aCx, mRequest->GetParentObject());
|
||||
NS_ASSERTION(global, "This should never be null!");
|
||||
|
||||
nsresult rv =
|
||||
|
|
|
@ -666,8 +666,9 @@ public:
|
|||
aData.name, aData.type, fileInfo.forget());
|
||||
|
||||
jsval wrappedFileHandle;
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(aCx, JS_GetGlobalForScopeChain(aCx),
|
||||
nsContentUtils::WrapNative(aCx, global,
|
||||
static_cast<nsIDOMFileHandle*>(fileHandle),
|
||||
&NS_GET_IID(nsIDOMFileHandle),
|
||||
&wrappedFileHandle);
|
||||
|
@ -726,8 +727,9 @@ public:
|
|||
}
|
||||
|
||||
jsval wrappedBlob;
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
rv =
|
||||
nsContentUtils::WrapNative(aCx, JS_GetGlobalForScopeChain(aCx), domBlob,
|
||||
nsContentUtils::WrapNative(aCx, global, domBlob,
|
||||
&NS_GET_IID(nsIDOMBlob), &wrappedBlob);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to wrap native!");
|
||||
|
@ -752,8 +754,9 @@ public:
|
|||
}
|
||||
|
||||
jsval wrappedFile;
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
rv =
|
||||
nsContentUtils::WrapNative(aCx, JS_GetGlobalForScopeChain(aCx), domFile,
|
||||
nsContentUtils::WrapNative(aCx, global, domFile,
|
||||
&NS_GET_IID(nsIDOMFile), &wrappedFile);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to wrap native!");
|
||||
|
|
|
@ -402,7 +402,7 @@ IndexedDatabaseManager::InitWindowless(const jsval& aObj, JSContext* aCx)
|
|||
NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);
|
||||
NS_ENSURE_ARG(!JSVAL_IS_PRIMITIVE(aObj));
|
||||
|
||||
JSObject* obj = JSVAL_TO_OBJECT(aObj);
|
||||
JS::Rooted<JSObject*> obj(aCx, JSVAL_TO_OBJECT(aObj));
|
||||
|
||||
JSBool hasIndexedDB;
|
||||
if (!JS_HasProperty(aCx, obj, "indexedDB", &hasIndexedDB)) {
|
||||
|
|
|
@ -58,8 +58,9 @@ Read(JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
|
|||
#endif
|
||||
|
||||
JS::Value wrappedFile;
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(aCx, JS_GetGlobalForScopeChain(aCx), file,
|
||||
nsContentUtils::WrapNative(aCx, global, file,
|
||||
&NS_GET_IID(nsIDOMFile), &wrappedFile);
|
||||
if (NS_FAILED(rv)) {
|
||||
Error(aCx, nsIDOMDOMException::DATA_CLONE_ERR);
|
||||
|
@ -90,8 +91,9 @@ Read(JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
|
|||
#endif
|
||||
|
||||
JS::Value wrappedBlob;
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(aCx, JS_GetGlobalForScopeChain(aCx), blob,
|
||||
nsContentUtils::WrapNative(aCx, global, blob,
|
||||
&NS_GET_IID(nsIDOMBlob), &wrappedBlob);
|
||||
if (NS_FAILED(rv)) {
|
||||
Error(aCx, nsIDOMDOMException::DATA_CLONE_ERR);
|
||||
|
|
|
@ -469,8 +469,9 @@ MmsMessage::GetAttachments(JSContext* aCx, JS::Value* aAttachments)
|
|||
}
|
||||
|
||||
// Get |attachment.mContent|.
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx,
|
||||
JS_GetGlobalForScopeChain(aCx),
|
||||
global,
|
||||
attachment.content,
|
||||
&NS_GET_IID(nsIDOMBlob),
|
||||
&tmpJsVal);
|
||||
|
|
|
@ -54,7 +54,7 @@ MobileMessageCallback::NotifySuccess(nsISupports *aMessage)
|
|||
AutoPushJSContext cx(scriptContext->GetNativeContext());
|
||||
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
|
||||
|
||||
JSObject* global = scriptContext->GetNativeGlobal();
|
||||
JS::Rooted<JSObject*> global(cx, scriptContext->GetNativeGlobal());
|
||||
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
|
|
@ -67,7 +67,7 @@ MobileMessageCursorCallback::NotifyCursorResult(nsISupports* aResult)
|
|||
AutoPushJSContext cx(scriptContext->GetNativeContext());
|
||||
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
|
||||
|
||||
JSObject* global = scriptContext->GetNativeGlobal();
|
||||
JS::Rooted<JSObject*> global(cx, scriptContext->GetNativeGlobal());
|
||||
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
|
|
@ -121,7 +121,8 @@ MobileMessageManager::Send(JSContext* aCx, JSObject* aGlobal, JSString* aNumber,
|
|||
nsresult rv = smsService->Send(number, aMessage, msgCallback);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = nsContentUtils::WrapNative(aCx, aGlobal,
|
||||
JS::Rooted<JSObject*> global(aCx, aGlobal);
|
||||
rv = nsContentUtils::WrapNative(aCx, global,
|
||||
static_cast<nsIDOMDOMRequest*>(request.get()),
|
||||
aRequest);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
|
|
@ -157,7 +157,8 @@ SmsManager::Send(JSContext* aCx, JSObject* aGlobal, JSString* aNumber,
|
|||
nsresult rv = smsService->Send(number, aMessage, msgCallback);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = nsContentUtils::WrapNative(aCx, aGlobal,
|
||||
JS::Rooted<JSObject*> global(aCx, aGlobal);
|
||||
rv = nsContentUtils::WrapNative(aCx, global,
|
||||
static_cast<nsIDOMDOMRequest*>(request.get()),
|
||||
aRequest);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
|
|
@ -56,8 +56,9 @@ MmsAttachmentDataToJSObject(JSContext* aContext,
|
|||
|
||||
nsCOMPtr<nsIDOMBlob> blob = static_cast<BlobParent*>(aAttachment.contentParent())->GetBlob();
|
||||
JS::Value content;
|
||||
JS::Rooted<JSObject*> global (aContext, JS_GetGlobalForScopeChain(aContext));
|
||||
nsresult rv = nsContentUtils::WrapNative(aContext,
|
||||
JS_GetGlobalForScopeChain(aContext),
|
||||
global,
|
||||
blob,
|
||||
&NS_GET_IID(nsIDOMBlob),
|
||||
&content);
|
||||
|
|
|
@ -309,8 +309,9 @@ struct MainThreadWorkerStructuredCloneCallbacks
|
|||
// nsIDOMFiles should be threadsafe, thus we will use the same instance
|
||||
// on the main thread.
|
||||
JS::Value wrappedFile;
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(aCx, JS_GetGlobalForScopeChain(aCx), file,
|
||||
nsContentUtils::WrapNative(aCx, global, file,
|
||||
&NS_GET_IID(nsIDOMFile), &wrappedFile);
|
||||
if (NS_FAILED(rv)) {
|
||||
Error(aCx, DATA_CLONE_ERR);
|
||||
|
@ -342,8 +343,9 @@ struct MainThreadWorkerStructuredCloneCallbacks
|
|||
// nsIDOMBlobs should be threadsafe, thus we will use the same instance
|
||||
// on the main thread.
|
||||
JS::Value wrappedBlob;
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(aCx, JS_GetGlobalForScopeChain(aCx), blob,
|
||||
nsContentUtils::WrapNative(aCx, global, blob,
|
||||
&NS_GET_IID(nsIDOMBlob), &wrappedBlob);
|
||||
if (NS_FAILED(rv)) {
|
||||
Error(aCx, DATA_CLONE_ERR);
|
||||
|
|
|
@ -19,7 +19,7 @@ nsTArrayToJSArray(JSContext* aCx, const nsTArray<T>& aSourceArray,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
JSObject* global = JS_GetGlobalForScopeChain(aCx);
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
MOZ_ASSERT(global);
|
||||
|
||||
for (uint32_t index = 0; index < aSourceArray.Length(); index++) {
|
||||
|
|
|
@ -72,7 +72,8 @@ xpcJSWeakReference::Get(JSContext* aCx, JS::Value* aRetval)
|
|||
if (!wrappedObj) {
|
||||
// We have a generic XPCOM object that supports weak references here.
|
||||
// Wrap it and pass it out.
|
||||
return nsContentUtils::WrapNative(aCx, JS_GetGlobalForScopeChain(aCx),
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||
return nsContentUtils::WrapNative(aCx, global,
|
||||
supports, &NS_GET_IID(nsISupports),
|
||||
aRetval);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче