author | David Zbarsky <dzbarsky@gmail.com> |
Thu, 02 May 2013 05:12:46 -0400 | |
changeset 141600 | 173a6deb4792d76e315e649bd7db1f9ce24a55f5 |
parent 141599 | 27f8c1c2e09e9e0bb77c59fcf211efbb9df037cf |
child 141601 | 82dfcc2b53661b8a8f3d354f2202bb709636a8cc |
push id | 2579 |
push user | akeybl@mozilla.com |
push date | Mon, 24 Jun 2013 18:52:47 +0000 |
treeherder | mozilla-beta@b69b7de8a05a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bz |
bugs | 866450 |
milestone | 23.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -1678,40 +1678,40 @@ public: /** * The method checks whether the caller can access native anonymous content. * If there is no JS in the stack or privileged JS is running, this * method returns true, otherwise false. */ static bool CanAccessNativeAnon(); - static nsresult WrapNative(JSContext *cx, JSObject *scope, + static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope, nsISupports *native, const nsIID* aIID, JS::Value *vp, // If non-null aHolder will keep the Value alive // while there's a ref to it nsIXPConnectJSObjectHolder** aHolder = nullptr, bool aAllowWrapping = false) { return WrapNative(cx, scope, native, nullptr, aIID, vp, aHolder, aAllowWrapping); } // 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::Handle<JSObject*> scope, nsISupports *native, JS::Value *vp, // If non-null aHolder will keep the Value alive // while there's a ref to it nsIXPConnectJSObjectHolder** aHolder = nullptr, bool aAllowWrapping = false) { return WrapNative(cx, scope, native, nullptr, nullptr, vp, aHolder, aAllowWrapping); } - static nsresult WrapNative(JSContext *cx, JSObject *scope, + static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope, nsISupports *native, nsWrapperCache *cache, JS::Value *vp, // If non-null aHolder will keep the Value alive // while there's a ref to it nsIXPConnectJSObjectHolder** aHolder = nullptr, bool aAllowWrapping = false) { return WrapNative(cx, scope, native, cache, nullptr, vp, aHolder, @@ -2141,22 +2141,22 @@ public: private: static bool InitializeEventTable(); static nsresult EnsureStringBundle(PropertiesFile aFile); static bool CanCallerAccess(nsIPrincipal* aSubjectPrincipal, nsIPrincipal* aPrincipal); - static nsresult WrapNative(JSContext *cx, JSObject *scope, + static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope, nsISupports *native, nsWrapperCache *cache, const nsIID* aIID, JS::Value *vp, nsIXPConnectJSObjectHolder** aHolder, bool aAllowWrapping); - + static nsresult DispatchEvent(nsIDocument* aDoc, nsISupports* aTarget, const nsAString& aEventName, bool aCanBubble, bool aCancelable, bool aTrusted, bool *aDefaultAction = nullptr);
--- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -2137,17 +2137,17 @@ protected: nsCString GetContentTypeInternal() const { return mContentType; } // 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, JS::Handle<JSObject*> aNewObject); nsCString mReferrer; nsString mLastModified; nsCOMPtr<nsIURI> mDocumentURI; nsCOMPtr<nsIURI> mOriginalURI; nsCOMPtr<nsIURI> mDocumentBaseURI;
--- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -5834,18 +5834,19 @@ nsContentUtils::DispatchXULCommand(nsICo nsCOMPtr<EventTarget> target = do_QueryInterface(aTarget); NS_ENSURE_STATE(target); bool dummy; return target->DispatchEvent(event, &dummy); } // static nsresult -nsContentUtils::WrapNative(JSContext *cx, JSObject *scope, nsISupports *native, - nsWrapperCache *cache, const nsIID* aIID, JS::Value *vp, +nsContentUtils::WrapNative(JSContext *cx, JS::Handle<JSObject*> scope, + nsISupports *native, nsWrapperCache *cache, + const nsIID* aIID, JS::Value *vp, nsIXPConnectJSObjectHolder **aHolder, bool aAllowWrapping) { if (!native) { NS_ASSERTION(!aHolder || !*aHolder, "*aHolder should be null!"); *vp = JSVAL_NULL; @@ -5924,17 +5925,17 @@ nsContentUtils::CreateBlobBuffer(JSConte void* blobData = moz_malloc(blobLen); nsCOMPtr<nsIDOMBlob> blob; if (blobData) { memcpy(blobData, aData.BeginReading(), blobLen); blob = new nsDOMMemoryFile(blobData, blobLen, EmptyString()); } 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); } void nsContentUtils::StripNullChars(const nsAString& aInStr, nsAString& aOutStr) { // In common cases where we don't have nulls in the // string we can simple simply bypass the checking code.
--- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -4963,17 +4963,18 @@ nsIDocument::CreateAttributeNS(const nsA return attribute.forget(); } static JSBool 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"); nsIDocument* document = window->GetDoc(); // Function name is the type of the custom element. JSString* jsFunName = JS_GetFunctionId(JS_ValueToFunction(aCx, calleeVal)); nsDependentJSString elemName; @@ -6569,25 +6570,25 @@ nsIDocument::AdoptNode(nsINode& aAdopted return nullptr; } } nsCOMPtr<nsIDocument> oldDocument = adoptedNode->OwnerDoc(); bool sameDocument = oldDocument == this; AutoJSContext cx; - JSObject *newScope = nullptr; + JS::Rooted<JSObject*> newScope(cx, nullptr); if (!sameDocument) { newScope = GetWrapper(); if (!newScope && GetScopeObject() && GetScopeObject()->GetGlobalJSObject()) { // We need to pass some sort of scope object to WrapNative. It's kind of // 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, /* aAllowWrapping = */ false); if (rv.Failed()) return nullptr; newScope = &v.toObject(); } @@ -11195,17 +11196,17 @@ nsIDocument::Evaluate(const nsAString& a rv = evaluator->Evaluate(aExpression, contextNode, aResolver, aType, aResult, getter_AddRefs(res)); return res.forget(); } // 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, JS::Handle<JSObject*> aNewObject) { MOZ_ASSERT(IsDOMBinding()); nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(GetScriptGlobalObject()); if (!win) { // No window, nothing else to do here return true; }
--- a/content/base/src/nsFrameMessageManager.cpp +++ b/content/base/src/nsFrameMessageManager.cpp @@ -656,19 +656,19 @@ nsFrameMessageManager::ReceiveMessage(ns JSAutoCompartment ac(ctx, object); // The parameter for the listener function. JS::Rooted<JSObject*> param(ctx, JS_NewObject(ctx, nullptr, nullptr, nullptr)); 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. if (!aObjectsArray) { // Because we want JS messages to have always the same properties, // create array even if len == 0. aObjectsArray = JS_NewArrayObject(ctx, 0, nullptr); if (!aObjectsArray) { @@ -710,19 +710,19 @@ nsFrameMessageManager::ReceiveMessage(ns // A small hack to get 'this' value right on content side where // messageManager is wrapped in TabChildGlobal. nsCOMPtr<nsISupports> defaultThisValue; if (mChrome) { defaultThisValue = do_QueryObject(this); } 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) || !funval.isObject()) return NS_ERROR_UNEXPECTED; // Check if the object is even callable. NS_ENSURE_STATE(JS_ObjectIsCallable(ctx, &funval.toObject()));
--- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -997,28 +997,28 @@ nsXMLHttpRequest::GetResponse(JSContext* } } if (!mResponseBlob) { return JSVAL_NULL; } 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; } case XML_HTTP_RESPONSE_TYPE_DOCUMENT: { if (!(mState & XML_HTTP_REQUEST_DONE) || !mResponseXML) { 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); return result; } case XML_HTTP_RESPONSE_TYPE_JSON: { if (!(mState & XML_HTTP_REQUEST_DONE)) { @@ -3631,17 +3631,17 @@ nsXMLHttpRequest::GetInterface(JSContext const nsID* iid = aIID->GetID(); nsCOMPtr<nsISupports> result; JS::Value v = JSVAL_NULL; aRv = GetInterface(*iid, getter_AddRefs(result)); NS_ENSURE_FALSE(aRv.Failed(), JSVAL_NULL); 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; } nsXMLHttpRequestUpload* nsXMLHttpRequest::Upload() { if (!mUpload) {
--- a/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -1369,27 +1369,27 @@ nsXULTemplateBuilder::InitHTMLTemplateRo NS_ASSERTION(doc, "no document"); if (! doc) return NS_ERROR_UNEXPECTED; nsIScriptGlobalObject *global = doc->GetScriptGlobalObject(); if (! global) return NS_ERROR_UNEXPECTED; - JSObject *scope = global->GetGlobalJSObject(); - nsIScriptContext *context = global->GetContext(); if (! context) return NS_ERROR_UNEXPECTED; AutoPushJSContext jscontext(context->GetNativeContext()); NS_ASSERTION(context != nullptr, "no jscontext"); if (! jscontext) return NS_ERROR_UNEXPECTED; + JS::Rooted<JSObject*> scope(jscontext, global->GetGlobalJSObject()); + JSAutoRequest ar(jscontext); JS::Value v; nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper; rv = nsContentUtils::WrapNative(jscontext, scope, mRoot, mRoot, &v, getter_AddRefs(wrapper)); NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -6583,17 +6583,17 @@ PostMessageReadStructuredClone(JSContext { NS_ASSERTION(closure, "Must have closure!"); if (tag == SCTAG_DOM_BLOB || tag == SCTAG_DOM_FILELIST) { NS_ASSERTION(!data, "Data should be empty"); 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; if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, global, supports, &val, getter_AddRefs(wrapper)))) { return JSVAL_TO_OBJECT(val); }
--- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -1466,17 +1466,19 @@ AtomIsEventHandlerName(nsIAtom *aName) return true; } #endif // 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::Handle<JSObject*> aScope, + JSObject** aRet) { // It is legal to specify a null target. if (!aTarget) { *aRet = nullptr; return NS_OK; } // Get the jsobject associated with this target @@ -1511,17 +1513,18 @@ nsJSContext::BindCompiledEventHandler(ns xpc_UnmarkGrayObject(aScope); xpc_UnmarkGrayObject(aHandler); XPCAutoRequest ar(mContext); // 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 { JSAutoCompartment ac(mContext, aHandler); NS_ASSERTION(JS_TypeOfValue(mContext, OBJECT_TO_JSVAL(aHandler)) == JSTYPE_FUNCTION, "Event handler object not a function"); @@ -1667,18 +1670,19 @@ nsJSContext::SetProperty(JSObject* aTarg JS::Value *argv = nullptr; nsCxPusher pusher; pusher.Push(mContext); XPCAutoRequest ar(mContext); 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; // got the arguments, now attach them. // window.dialogArguments is supposed to be an array if a JS array // was passed to showModalDialog(), deal with that here. @@ -1699,17 +1703,17 @@ nsJSContext::SetProperty(JSObject* aTarg // readonly XPConnect properties here as well (read dialogArguments). return JS_DefineProperty(mContext, aTarget, aPropName, vargs, NULL, NULL, 0) ? NS_OK : NS_ERROR_FAILURE; } nsresult nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs, - JSObject *aScope, + JS::Handle<JSObject*> aScope, uint32_t *aArgc, JS::Value **aArgv, Maybe<nsRootedJSValueArray> &aTempStorage) { nsresult rv = NS_OK; // If the array implements nsIJSArgArray, just grab the values directly. nsCOMPtr<nsIJSArgArray> fastArray = do_QueryInterface(aArgs); @@ -1971,17 +1975,18 @@ nsJSContext::AddSupportsPrimitiveTojsval p->GetData(getter_AddRefs(data)); p->GetDataIID(&iid); NS_ENSURE_TRUE(iid, NS_ERROR_UNEXPECTED); 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, getter_AddRefs(wrapper)); NS_ENSURE_SUCCESS(rv, rv); *aArgv = v;
--- a/dom/base/nsJSEnvironment.h +++ b/dom/base/nsJSEnvironment.h @@ -158,26 +158,27 @@ public: JSObject* global = JS_GetGlobalObject(mContext); return global ? mGlobalObjectRef.get() : nullptr; } protected: nsresult InitializeExternalClasses(); // Helper to convert xpcom datatypes to jsvals. nsresult ConvertSupportsTojsvals(nsISupports *aArgs, - JSObject *aScope, + JS::Handle<JSObject*> aScope, uint32_t *aArgc, JS::Value **aArgv, mozilla::Maybe<nsRootedJSValueArray> &aPoolRelease); nsresult AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv); // 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::Handle<JSObject*> aScript, JSObject **aRet); // Report the pending exception on our mContext, if any. This // function will set aside the frame chain on mContext before // reporting. void ReportPendingException(); private: void DestroyJSContext();
--- a/dom/bluetooth/BluetoothManager.cpp +++ b/dom/bluetooth/BluetoothManager.cpp @@ -63,20 +63,19 @@ public: nsresult rv; nsIScriptContext* sc = mManagerPtr->GetContextForEventHandlers(&rv); if (!sc) { NS_WARNING("Cannot create script context!"); SetError(NS_LITERAL_STRING("BluetoothScriptContextError")); return false; } - rv = nsContentUtils::WrapNative(sc->GetNativeContext(), - sc->GetNativeGlobal(), - adapter, - aValue); + JSContext* cx = sc->GetNativeContext(); + JS::Rooted<JSObject*> global(cx, sc->GetNativeGlobal()); + rv = nsContentUtils::WrapNative(cx, global, adapter, aValue); if (NS_FAILED(rv)) { NS_WARNING("Cannot create native object!"); SetError(NS_LITERAL_STRING("BluetoothNativeObjectError")); return false; } return true; }
--- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -918,18 +918,19 @@ InterfaceToJsval(nsPIDOMWindow* aWindow, } AutoPushJSContext cx(scriptContext->GetNativeContext()); if (!cx) { return JSVAL_NULL; } JS::Value someJsVal; + JS::Rooted<JSObject*> global(cx, JS_GetGlobalObject(cx)); nsresult rv = nsContentUtils::WrapNative(cx, - JS_GetGlobalObject(cx), + global, aObject, aIID, &someJsVal); if (NS_FAILED(rv)) { return JSVAL_NULL; } return someJsVal;
--- a/dom/file/ArchiveRequest.cpp +++ b/dom/file/ArchiveRequest.cpp @@ -218,20 +218,19 @@ ArchiveRequest::GetFileResult(JSContext* for (uint32_t i = 0; i < aFileList.Length(); ++i) { nsCOMPtr<nsIDOMFile> file = aFileList[i]; nsString filename; nsresult rv = file->GetName(filename); 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); } } return NS_ERROR_FAILURE; } nsresult ArchiveRequest::GetFilesResult(JSContext* aCx, @@ -242,18 +241,19 @@ ArchiveRequest::GetFilesResult(JSContext if (!array) { return NS_ERROR_OUT_OF_MEMORY; } for (uint32_t i = 0; i < aFileList.Length(); ++i) { 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; } } aValue->setObject(*array); return NS_OK; }
--- a/dom/file/FileHandle.cpp +++ b/dom/file/FileHandle.cpp @@ -186,18 +186,19 @@ FileHandle::GetFileInfo() } nsresult 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); return NS_OK; } /* virtual */ JSObject*
--- a/dom/indexedDB/AsyncConnectionHelper.cpp +++ b/dom/indexedDB/AsyncConnectionHelper.cpp @@ -114,17 +114,17 @@ HelperBase::WrapNative(JSContext* aCx, nsISupports* aNative, jsval* aResult) { NS_ASSERTION(aCx, "Null context!"); NS_ASSERTION(aNative, "Null pointer!"); 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 = nsContentUtils::WrapNative(aCx, global, aNative, aResult); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; }
--- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -661,18 +661,19 @@ public: MOZ_ASSERT(NS_IsMainThread()); nsRefPtr<FileInfo>& fileInfo = aFile.mFileInfo; nsRefPtr<IDBFileHandle> fileHandle = IDBFileHandle::Create(aDatabase, 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); if (NS_FAILED(rv)) { NS_WARNING("Failed to wrap native!"); return nullptr; } @@ -721,18 +722,19 @@ public: domBlob = aFile.mFile; } else { domBlob = new nsDOMFileFile(aData.type, aData.size, nativeFile, fileInfo); } 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!"); return nullptr; } return JSVAL_TO_OBJECT(wrappedBlob); } @@ -747,18 +749,19 @@ public: NS_ASSERTION(domFile, "This should never fail!"); } else { domFile = new nsDOMFileFile(aData.name, aData.type, aData.size, nativeFile, fileInfo); } 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!"); return nullptr; } return JSVAL_TO_OBJECT(wrappedFile); }
--- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -397,17 +397,17 @@ NS_IMPL_RELEASE_WITH_DESTROY(IndexedData NS_IMPL_QUERY_INTERFACE1(IndexedDatabaseManager, nsIIndexedDatabaseManager) NS_IMETHODIMP 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)) { return NS_ERROR_FAILURE; } if (hasIndexedDB) { NS_WARNING("Passed object already has an 'indexedDB' property!");
--- a/dom/ipc/StructuredCloneUtils.cpp +++ b/dom/ipc/StructuredCloneUtils.cpp @@ -53,18 +53,19 @@ Read(JSContext* aCx, JSStructuredCloneRe } else { MOZ_ASSERT(!isMutable); } } #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); return nullptr; } return &wrappedFile.toObject(); } @@ -85,18 +86,19 @@ Read(JSContext* aCx, JSStructuredCloneRe } else { MOZ_ASSERT(!isMutable); } } #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); return nullptr; } return &wrappedBlob.toObject(); }
--- a/dom/mobilemessage/src/MmsMessage.cpp +++ b/dom/mobilemessage/src/MmsMessage.cpp @@ -459,18 +459,19 @@ MmsMessage::GetAttachments(JSContext* aC tmpJsVal.setString(tmpJsStr); if (!JS_DefineProperty(aCx, attachmentObj, "location", tmpJsVal, NULL, NULL, JSPROP_ENUMERATE)) { return NS_ERROR_FAILURE; } // 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); NS_ENSURE_SUCCESS(rv, rv); if (!JS_DefineProperty(aCx, attachmentObj, "content", tmpJsVal, NULL, NULL, JSPROP_ENUMERATE)) { return NS_ERROR_FAILURE;
--- a/dom/mobilemessage/src/MobileMessageCallback.cpp +++ b/dom/mobilemessage/src/MobileMessageCallback.cpp @@ -49,17 +49,17 @@ MobileMessageCallback::NotifySuccess(nsI nsresult rv; nsIScriptContext* scriptContext = mDOMRequest->GetContextForEventHandlers(&rv); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(scriptContext, NS_ERROR_FAILURE); 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); JSAutoCompartment ac(cx, global); JS::Value wrappedMessage; rv = nsContentUtils::WrapNative(cx, global, aMessage, &wrappedMessage); NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/mobilemessage/src/MobileMessageCursorCallback.cpp +++ b/dom/mobilemessage/src/MobileMessageCursorCallback.cpp @@ -62,17 +62,17 @@ MobileMessageCursorCallback::NotifyCurso nsresult rv; nsIScriptContext* scriptContext = mDOMCursor->GetContextForEventHandlers(&rv); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(scriptContext, NS_ERROR_FAILURE); 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); JSAutoCompartment ac(cx, global); JS::Value wrappedResult; rv = nsContentUtils::WrapNative(cx, global, aResult, &wrappedResult); NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/mobilemessage/src/MobileMessageManager.cpp +++ b/dom/mobilemessage/src/MobileMessageManager.cpp @@ -116,17 +116,18 @@ MobileMessageManager::Send(JSContext* aC nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner()); nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request); 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)) { NS_ERROR("Failed to create the js value!"); return rv; } return NS_OK;
--- a/dom/mobilemessage/src/SmsManager.cpp +++ b/dom/mobilemessage/src/SmsManager.cpp @@ -152,17 +152,18 @@ SmsManager::Send(JSContext* aCx, JSObjec nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner()); nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request); 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)) { NS_ERROR("Failed to create the js value!"); return rv; } return NS_OK;
--- a/dom/mobilemessage/src/ipc/SmsParent.cpp +++ b/dom/mobilemessage/src/ipc/SmsParent.cpp @@ -51,18 +51,19 @@ MmsAttachmentDataToJSObject(JSContext* a NS_ENSURE_TRUE(locStr, nullptr); if (!JS_DefineProperty(aContext, obj, "location", JS::StringValue(locStr), nullptr, nullptr, 0)) { return nullptr; } 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); NS_ENSURE_SUCCESS(rv, nullptr); if (!JS_DefineProperty(aContext, obj, "content", content, nullptr, nullptr, 0)) { return nullptr; }
--- a/dom/telephony/Telephony.cpp +++ b/dom/telephony/Telephony.cpp @@ -291,24 +291,24 @@ Telephony::GetActive(JS::Value* aActive) if (!mActiveCall) { aActive->setNull(); return NS_OK; } nsresult rv; nsIScriptContext* sc = GetContextForEventHandlers(&rv); NS_ENSURE_SUCCESS(rv, rv); - AutoPushJSContext cx(sc ? sc->GetNativeContext() : nullptr); - if (sc) { - rv = - nsContentUtils::WrapNative(cx, sc->GetNativeGlobal(), - mActiveCall->ToISupports(), aActive); - NS_ENSURE_SUCCESS(rv, rv); + if (!sc) { + return NS_OK; } - return NS_OK; + + AutoPushJSContext cx(sc->GetNativeContext()); + JS::Rooted<JSObject*> global(cx, sc->GetNativeGlobal()); + return nsContentUtils::WrapNative(cx, global, mActiveCall->ToISupports(), + aActive); } NS_IMETHODIMP Telephony::GetCalls(JS::Value* aCalls) { JSObject* calls = mCallsArray; if (!calls) { nsresult rv;
--- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -304,18 +304,19 @@ struct MainThreadWorkerStructuredCloneCa !isMutable, "Only immutable file should be passed to worker"); } #endif // 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); return nullptr; } return &wrappedFile.toObject(); } @@ -337,18 +338,19 @@ struct MainThreadWorkerStructuredCloneCa !isMutable, "Only immutable blob should be passed to worker"); } #endif // 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); return nullptr; } return &wrappedBlob.toObject(); }
--- a/js/xpconnect/public/nsTArrayHelpers.h +++ b/js/xpconnect/public/nsTArrayHelpers.h @@ -14,17 +14,17 @@ nsTArrayToJSArray(JSContext* aCx, const JSAutoRequest ar(aCx); JSObject* arrayObj = JS_NewArrayObject(aCx, aSourceArray.Length(), nullptr); if (!arrayObj) { NS_WARNING("JS_NewArrayObject failed!"); 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++) { nsCOMPtr<nsISupports> obj; nsresult rv = aSourceArray[index]->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(obj)); NS_ENSURE_SUCCESS(rv, rv); jsval wrappedVal;
--- a/js/xpconnect/src/XPCJSWeakReference.cpp +++ b/js/xpconnect/src/XPCJSWeakReference.cpp @@ -67,17 +67,18 @@ xpcJSWeakReference::Get(JSContext* aCx, if (!supports) { return NS_OK; } nsCOMPtr<nsIXPConnectWrappedJS> wrappedObj = do_QueryInterface(supports); 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); } JS::RootedObject obj(aCx); wrappedObj->GetJSObject(obj.address()); if (!obj) { return NS_OK;