Bug 899245 - Rename JS_GetGlobalForScopeChain to JS::CurrentGlobalOrNull. r=luke

This was done with perl/grep.
This commit is contained in:
Bobby Holley 2013-07-29 16:45:27 -07:00
parent 43974de990
commit 98a0425f0f
50 changed files with 97 additions and 93 deletions

View File

@ -1675,7 +1675,7 @@ nsContentUtils::GetDocumentFromCaller()
AutoJSContext cx;
nsCOMPtr<nsPIDOMWindow> win =
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(JS_GetGlobalForScopeChain(cx)));
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(JS::CurrentGlobalOrNull(cx)));
if (!win) {
return nullptr;
}
@ -5666,7 +5666,7 @@ nsContentUtils::CreateBlobBuffer(JSContext* aCx,
} else {
return NS_ERROR_OUT_OF_MEMORY;
}
JS::Rooted<JSObject*> scope(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> scope(aCx, JS::CurrentGlobalOrNull(aCx));
return nsContentUtils::WrapNative(aCx, scope, blob, aBlob.address(), nullptr,
true);
}

View File

@ -1022,7 +1022,7 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
}
JS::Rooted<JS::Value> result(aCx, JSVAL_NULL);
JS::Rooted<JSObject*> scope(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> scope(aCx, JS::CurrentGlobalOrNull(aCx));
aRv = nsContentUtils::WrapNative(aCx, scope, mResponseBlob, result.address(),
nullptr, true);
return result;
@ -1033,7 +1033,7 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
return JSVAL_NULL;
}
JS::Rooted<JSObject*> scope(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> scope(aCx, JS::CurrentGlobalOrNull(aCx));
JS::Rooted<JS::Value> result(aCx, JSVAL_NULL);
aRv = nsContentUtils::WrapNative(aCx, scope, mResponseXML, result.address(),
nullptr, true);

View File

@ -2395,7 +2395,7 @@ ChildWindowGetter(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
// Wrap the child for JS.
JS::Rooted<JS::Value> v(cx);
nsresult rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), child,
nsresult rv = WrapNative(cx, JS::CurrentGlobalOrNull(cx), child,
/* aAllowWrapping = */ true, v.address());
NS_ENSURE_SUCCESS(rv, false);
vp.set(v);
@ -3977,7 +3977,7 @@ LocationSetterGuts(JSContext *cx, JSObject *obj, jsval *vp)
// We have to wrap location into vp before null-checking location, to
// avoid assigning the wrong thing into the slot.
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), location,
rv = WrapNative(cx, JS::CurrentGlobalOrNull(cx), location,
&NS_GET_IID(nsIDOMLocation), true, vp,
getter_AddRefs(holder));
NS_ENSURE_SUCCESS(rv, rv);
@ -4322,7 +4322,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
nsCOMPtr<nsIDocument> document = win->GetDoc();
JS::Rooted<JS::Value> v(cx);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), document, document,
rv = WrapNative(cx, JS::CurrentGlobalOrNull(cx), document, document,
&NS_GET_IID(nsIDOMDocument), v.address(), getter_AddRefs(holder),
false);
NS_ENSURE_SUCCESS(rv, rv);
@ -4704,7 +4704,7 @@ nsArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
NS_ENSURE_SUCCESS(rv, rv);
if (array_item) {
rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), array_item, cache,
rv = WrapNative(cx, JS::CurrentGlobalOrNull(cx), array_item, cache,
true, vp);
NS_ENSURE_SUCCESS(rv, rv);
@ -4801,7 +4801,7 @@ nsHTMLDocumentSH::GetDocumentAllNodeList(JSContext *cx,
}
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
nsresult tmp = WrapNative(cx, JS_GetGlobalForScopeChain(cx),
nsresult tmp = WrapNative(cx, JS::CurrentGlobalOrNull(cx),
static_cast<nsINodeList*>(list), list, false,
collection.address(), getter_AddRefs(holder));
if (NS_FAILED(tmp)) {
@ -4907,7 +4907,7 @@ nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JS::Handle<JSObject*> ob
}
if (result) {
rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), result, cache, true, vp.address());
rv = WrapNative(cx, JS::CurrentGlobalOrNull(cx), result, cache, true, vp.address());
if (NS_FAILED(rv)) {
xpc::Throw(cx, rv);

View File

@ -3648,7 +3648,7 @@ nsGlobalWindow::GetScriptableContent(JSContext* aCx, JS::Value* aVal)
NS_ENSURE_SUCCESS(rv, rv);
if (content || !nsContentUtils::IsCallerChrome() || !IsChromeWindow()) {
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
if (content && global) {
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
return nsContentUtils::WrapNative(aCx, global, content, aVal,
@ -6567,7 +6567,7 @@ JSObject* nsGlobalWindow::CallerGlobal()
// we verify that its principal is subsumed by the subject principal. If it
// isn't, something is screwy, and we want to clamp to the cx global.
JS::Rooted<JSObject*> scriptedGlobal(cx, JS_GetScriptedGlobal(cx));
JS::Rooted<JSObject*> cxGlobal(cx, JS_GetGlobalForScopeChain(cx));
JS::Rooted<JSObject*> cxGlobal(cx, JS::CurrentGlobalOrNull(cx));
if (!xpc::AccessCheck::subsumes(cxGlobal, scriptedGlobal)) {
NS_WARNING("Something nasty is happening! Applying countermeasures...");
return cxGlobal;
@ -6692,7 +6692,7 @@ PostMessageReadStructuredClone(JSContext* cx,
nsISupports* supports;
if (JS_ReadBytes(reader, &supports, sizeof(supports))) {
JS::Rooted<JSObject*> global(cx, JS_GetGlobalForScopeChain(cx));
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
if (global) {
JS::Rooted<JS::Value> val(cx);
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;

View File

@ -736,7 +736,7 @@ nsJSContext::DOMOperationCallback(JSContext *cx)
// Check the amount of time this script has been running, or if the
// dialog is disabled.
JSObject* global = ::JS_GetGlobalForScopeChain(cx);
JSObject* global = ::JS::CurrentGlobalOrNull(cx);
bool isTrackingChromeCodeTime =
global && xpc::AccessCheck::isChrome(js::GetObjectCompartment(global));
if (duration < (isTrackingChromeCodeTime ?
@ -3300,7 +3300,7 @@ NS_DOMReadStructuredClone(JSContext* cx,
nsRefPtr<ImageData> imageData = new ImageData(width, height,
dataArray.toObject());
// Wrap it in a JS::Value.
JS::Rooted<JSObject*> global(cx, JS_GetGlobalForScopeChain(cx));
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
if (!global) {
return nullptr;
}

View File

@ -125,7 +125,7 @@ nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(JSContext *aContext)
uint64_t innerWindowID = 0;
JSObject *jsGlobal = JS_GetGlobalForScopeChain(aContext);
JSObject *jsGlobal = JS::CurrentGlobalOrNull(aContext);
if (jsGlobal) {
nsIScriptGlobalObject *scriptGlobal = GetStaticScriptGlobal(jsGlobal);
if (scriptGlobal) {

View File

@ -222,7 +222,7 @@ ArchiveRequest::GetFileResult(JSContext* aCx,
NS_ENSURE_SUCCESS(rv, rv);
if (filename == mFilename) {
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
return nsContentUtils::WrapNative(aCx, global, file,
&NS_GET_IID(nsIDOMFile), aValue);
}
@ -245,7 +245,7 @@ ArchiveRequest::GetFilesResult(JSContext* aCx,
nsCOMPtr<nsIDOMFile> file = aFileList[i];
JS::Rooted<JS::Value> value(aCx);
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
nsresult rv = nsContentUtils::WrapNative(aCx, global, file,
&NS_GET_IID(nsIDOMFile),
value.address());

View File

@ -184,7 +184,7 @@ GetFileHelper::GetSuccessResult(JSContext* aCx, JS::Value* aVal)
nsCOMPtr<nsIDOMFile> domFile =
mFileHandle->CreateFileObject(mLockedFile, mParams->Size());
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
nsresult rv =
nsContentUtils::WrapNative(aCx, global, domFile,
&NS_GET_IID(nsIDOMFile), aVal);

View File

@ -38,7 +38,7 @@ ReturnKeyRange(JSContext* aCx,
nsIXPConnect* xpc = nsContentUtils::XPConnect();
NS_ASSERTION(xpc, "This should never be null!");
JSObject* global = JS_GetGlobalForScopeChain(aCx);
JSObject* global = JS::CurrentGlobalOrNull(aCx);
if (!global) {
NS_WARNING("Couldn't get global object!");
return false;

View File

@ -677,7 +677,7 @@ public:
aData.name, aData.type, fileInfo.forget());
JS::Rooted<JS::Value> wrappedFileHandle(aCx);
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
nsresult rv =
nsContentUtils::WrapNative(aCx, global,
static_cast<nsIDOMFileHandle*>(fileHandle),
@ -738,7 +738,7 @@ public:
}
JS::Rooted<JS::Value> wrappedBlob(aCx);
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
rv = nsContentUtils::WrapNative(aCx, global, domBlob,
&NS_GET_IID(nsIDOMBlob),
wrappedBlob.address());
@ -765,7 +765,7 @@ public:
}
JS::Rooted<JS::Value> wrappedFile(aCx);
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
rv = nsContentUtils::WrapNative(aCx, global, domFile,
&NS_GET_IID(nsIDOMFile),
wrappedFile.address());

View File

@ -54,7 +54,7 @@ Read(JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
#endif
JS::Rooted<JS::Value> wrappedFile(aCx);
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
nsresult rv = nsContentUtils::WrapNative(aCx, global, file,
&NS_GET_IID(nsIDOMFile),
wrappedFile.address());
@ -83,7 +83,7 @@ Read(JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
#endif
JS::Rooted<JS::Value> wrappedBlob(aCx);
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
nsresult rv = nsContentUtils::WrapNative(aCx, global, blob,
&NS_GET_IID(nsIDOMBlob),
wrappedBlob.address());

View File

@ -512,7 +512,7 @@ MmsMessage::GetAttachments(JSContext* aCx, JS::Value* aAttachments)
}
// Get |attachment.mContent|.
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
nsresult rv = nsContentUtils::WrapNative(aCx,
global,
attachment.content,

View File

@ -56,7 +56,7 @@ MmsAttachmentDataToJSObject(JSContext* aContext,
nsCOMPtr<nsIDOMBlob> blob = static_cast<BlobParent*>(aAttachment.contentParent())->GetBlob();
JS::Rooted<JS::Value> content(aContext);
JS::Rooted<JSObject*> global(aContext, JS_GetGlobalForScopeChain(aContext));
JS::Rooted<JSObject*> global(aContext, JS::CurrentGlobalOrNull(aContext));
nsresult rv = nsContentUtils::WrapNative(aContext,
global,
blob,

View File

@ -1247,7 +1247,7 @@ _getpluginelement(NPP npp)
NS_ENSURE_TRUE(xpc, nullptr);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
xpc->WrapNative(cx, ::JS_GetGlobalForScopeChain(cx), element,
xpc->WrapNative(cx, ::JS::CurrentGlobalOrNull(cx), element,
NS_GET_IID(nsIDOMElement),
getter_AddRefs(holder));
NS_ENSURE_TRUE(holder, nullptr);

View File

@ -152,7 +152,7 @@ ConnectWorkerToRIL::RunTask(JSContext *aCx)
// communication.
NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?");
JSObject *workerGlobal = JS_GetGlobalForScopeChain(aCx);
JSObject *workerGlobal = JS::CurrentGlobalOrNull(aCx);
return !!JS_DefineFunction(aCx, workerGlobal, "postRILMessage", PostToRIL, 1,
0);
@ -253,7 +253,7 @@ ConnectWorkerToNetd::RunTask(JSContext *aCx)
// communication.
NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?");
JSObject *workerGlobal = JS_GetGlobalForScopeChain(aCx);
JSObject *workerGlobal = JS::CurrentGlobalOrNull(aCx);
return !!JS_DefineFunction(aCx, workerGlobal, "postNetdCommand",
DoNetdCommand, 1, 0);
}
@ -292,7 +292,7 @@ private:
bool
NetdReceiver::DispatchNetdEvent::RunTask(JSContext *aCx)
{
JSObject *obj = JS_GetGlobalForScopeChain(aCx);
JSObject *obj = JS::CurrentGlobalOrNull(aCx);
JSObject *array = JS_NewUint8Array(aCx, mMessage->mSize);
if (!array) {

View File

@ -70,7 +70,7 @@ Wrap(JSContext* aCx, JSObject* aGlobal, nsRefPtr<T>& aConcreteObject)
MOZ_ASSERT(aCx);
if (!aGlobal) {
aGlobal = JS_GetGlobalForScopeChain(aCx);
aGlobal = JS::CurrentGlobalOrNull(aCx);
if (!aGlobal) {
return NULL;
}

View File

@ -970,7 +970,7 @@ JSObject*
CreateGenericEvent(JSContext* aCx, JS::Handle<JSString*> aType, bool aBubbles,
bool aCancelable, bool aMainRuntime)
{
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
return Event::Create(aCx, global, aType, aBubbles, aCancelable, aMainRuntime);
}
@ -979,7 +979,7 @@ CreateMessageEvent(JSContext* aCx, JSAutoStructuredCloneBuffer& aData,
nsTArray<nsCOMPtr<nsISupports> >& aClonedObjects,
bool aMainRuntime)
{
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
return MessageEvent::Create(aCx, global, aData, aClonedObjects, aMainRuntime);
}
@ -988,7 +988,7 @@ CreateErrorEvent(JSContext* aCx, JS::Handle<JSString*> aMessage,
JS::Handle<JSString*> aFilename, uint32_t aLineNumber,
bool aMainRuntime)
{
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
return ErrorEvent::Create(aCx, global, aMessage, aFilename, aLineNumber,
aMainRuntime);
}
@ -997,7 +997,7 @@ JSObject*
CreateProgressEvent(JSContext* aCx, JSString* aType, bool aLengthComputable,
double aLoaded, double aTotal)
{
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
return ProgressEvent::Create(aCx, global, aType, aLengthComputable, aLoaded,
aTotal);
}

View File

@ -632,7 +632,7 @@ ScriptExecutorRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
}
}
JS::RootedObject global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::RootedObject global(aCx, JS::CurrentGlobalOrNull(aCx));
NS_ASSERTION(global, "Must have a global by now!");
JSPrincipals* principal = GetWorkerPrincipal();

View File

@ -309,7 +309,7 @@ struct MainThreadWorkerStructuredCloneCallbacks
// nsIDOMFiles should be threadsafe, thus we will use the same instance
// on the main thread.
JS::Rooted<JS::Value> wrappedFile(aCx);
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
nsresult rv = nsContentUtils::WrapNative(aCx, global, file,
&NS_GET_IID(nsIDOMFile),
wrappedFile.address());
@ -343,7 +343,7 @@ struct MainThreadWorkerStructuredCloneCallbacks
// nsIDOMBlobs should be threadsafe, thus we will use the same instance
// on the main thread.
JS::Rooted<JS::Value> wrappedBlob(aCx);
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
nsresult rv = nsContentUtils::WrapNative(aCx, global, blob,
&NS_GET_IID(nsIDOMBlob),
wrappedBlob.address());
@ -734,7 +734,7 @@ public:
bool
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
{
JS::Rooted<JSObject*> target(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> target(aCx, JS::CurrentGlobalOrNull(aCx));
NS_ASSERTION(target, "This must never be null!");
aWorkerPrivate->CloseHandlerStarted();
@ -814,7 +814,7 @@ public:
NS_ASSERTION(aWorkerPrivate == GetWorkerPrivateFromContext(aCx),
"Badness!");
mainRuntime = false;
target = JS_GetGlobalForScopeChain(aCx);
target = JS::CurrentGlobalOrNull(aCx);
}
NS_ASSERTION(target, "This should never be null!");
@ -1035,7 +1035,7 @@ public:
// Now fire an event at the global object, but don't do that if the error
// code is too much recursion and this is the same script threw the error.
if (aFireAtScope && (aTarget || aErrorNumber != JSMSG_OVER_RECURSED)) {
aTarget = JS_GetGlobalForScopeChain(aCx);
aTarget = JS::CurrentGlobalOrNull(aCx);
NS_ASSERTION(aTarget, "This should never be null!");
bool preventDefaultCalled;
@ -1580,7 +1580,7 @@ WorkerRunnable::Dispatch(JSContext* aCx)
JSAutoRequest ar(aCx);
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
Maybe<JSAutoCompartment> ac;
if (global) {
@ -1677,7 +1677,7 @@ WorkerRunnable::Run()
JS::Rooted<JSObject*> targetCompartmentObject(cx);
if (mTarget == WorkerThread) {
targetCompartmentObject = JS_GetGlobalForScopeChain(cx);
targetCompartmentObject = JS::CurrentGlobalOrNull(cx);
} else {
targetCompartmentObject = mWorkerPrivate->GetJSObject();
}
@ -2610,7 +2610,7 @@ WorkerPrivate::Create(JSContext* aCx, JS::Handle<JSObject*> aObj, WorkerPrivate*
// See if we're being called from a window or from somewhere else.
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal =
nsJSUtils::GetStaticScriptGlobal(JS_GetGlobalForScopeChain(aCx));
nsJSUtils::GetStaticScriptGlobal(JS::CurrentGlobalOrNull(aCx));
if (scriptGlobal) {
// Window!
nsCOMPtr<nsPIDOMWindow> globalWindow = do_QueryInterface(scriptGlobal);
@ -2902,7 +2902,7 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
scheduleIdleGC = mControlQueue.IsEmpty() &&
mQueue.IsEmpty() &&
eventIsNotIdleGCEvent &&
JS_GetGlobalForScopeChain(aCx);
JS::CurrentGlobalOrNull(aCx);
}
// Take care of the GC timer. If we're starting the close sequence then we
@ -2918,10 +2918,10 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
}
if (scheduleIdleGC) {
NS_ASSERTION(JS_GetGlobalForScopeChain(aCx), "Should have global here!");
NS_ASSERTION(JS::CurrentGlobalOrNull(aCx), "Should have global here!");
// Now *might* be a good time to GC. Let the JS engine make the decision.
JSAutoCompartment ac(aCx, JS_GetGlobalForScopeChain(aCx));
JSAutoCompartment ac(aCx, JS::CurrentGlobalOrNull(aCx));
JS_MaybeGC(aCx);
if (NS_SUCCEEDED(gcTimer->SetTarget(idleGCEventTarget)) &&
@ -3726,7 +3726,7 @@ WorkerPrivate::NotifyInternal(JSContext* aCx, Status aStatus)
// If the worker script never ran, or failed to compile, we don't need to do
// anything else, except pretend that we ran the close handler.
if (!JS_GetGlobalForScopeChain(aCx)) {
if (!JS::CurrentGlobalOrNull(aCx)) {
mCloseHandlerStarted = true;
mCloseHandlerFinished = true;
return true;
@ -4054,7 +4054,7 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
bool retval = true;
AutoPtrComparator<TimeoutInfo> comparator = GetAutoPtrComparator(mTimeouts);
JS::RootedObject global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::RootedObject global(aCx, JS::CurrentGlobalOrNull(aCx));
JSPrincipals* principal = GetWorkerPrincipal();
// We want to make sure to run *something*, even if the timer fired a little

View File

@ -337,7 +337,7 @@ private:
JSFunction* adaptor =
js::NewFunctionWithReserved(aCx, UnwrapErrorEvent, 1, 0,
JS_GetGlobalForScopeChain(aCx), "unwrap");
JS::CurrentGlobalOrNull(aCx), "unwrap");
if (!adaptor) {
return false;
}

View File

@ -53,7 +53,7 @@ DispatchNfcEvent::RunTask(JSContext *aCx)
MOZ_ASSERT(NS_IsMainThread(), "DispatchNfcEvent on main thread");
MOZ_ASSERT(aCx);
JSObject *obj = JS_GetGlobalForScopeChain(aCx);
JSObject *obj = JS::CurrentGlobalOrNull(aCx);
JSObject *array = JS_NewUint8Array(aCx, mMessage->mSize);
if (!array) {
return false;

View File

@ -48,7 +48,7 @@ private:
bool
DispatchRILEvent::RunTask(JSContext *aCx)
{
JSObject *obj = JS_GetGlobalForScopeChain(aCx);
JSObject *obj = JS::CurrentGlobalOrNull(aCx);
JSObject *array = JS_NewUint8Array(aCx, mMessage->mSize);
if (!array) {

View File

@ -63,7 +63,7 @@ TestShellCommandParent::RunCallback(const nsString& aResponse)
JSAutoRequest ar(mCx);
NS_ENSURE_TRUE(mCallback.ToJSObject(), JS_FALSE);
JSAutoCompartment ac(mCx, mCallback.ToJSObject());
JS::Rooted<JSObject*> global(mCx, JS_GetGlobalForScopeChain(mCx));
JS::Rooted<JSObject*> global(mCx, JS::CurrentGlobalOrNull(mCx));
JSString* str = JS_NewUCStringCopyN(mCx, aResponse.get(), aResponse.Length());
NS_ENSURE_TRUE(str, JS_FALSE);

View File

@ -177,7 +177,7 @@ Load(JSContext *cx,
JS::CompileOptions options(cx);
options.setUTF8(true)
.setFileAndLine(filename.ptr(), 1)
.setPrincipals(Environment(JS_GetGlobalForScopeChain(cx))->GetPrincipal());
.setPrincipals(Environment(JS::CurrentGlobalOrNull(cx))->GetPrincipal());
JS::RootedObject rootedObj(cx, obj);
JSScript *script = JS::Compile(cx, rootedObj, options, file);
fclose(file);
@ -217,7 +217,7 @@ Quit(JSContext *cx,
unsigned argc,
JS::Value *vp)
{
XPCShellEnvironment* env = Environment(JS_GetGlobalForScopeChain(cx));
XPCShellEnvironment* env = Environment(JS::CurrentGlobalOrNull(cx));
env->SetIsQuitting();
return JS_FALSE;

View File

@ -562,7 +562,7 @@ JavaScriptParent::unwrap(JSContext *cx, ObjectId objId)
bool callable = !!(objId & OBJECT_IS_CALLABLE);
RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
RootedObject global(cx, JS::DefaultObjectForContextOrNull(cx));
RootedValue v(cx, UndefinedValue());
JSObject *obj = NewProxyObject(cx,

View File

@ -800,7 +800,7 @@ static JSClass FinalizeCounterClass = {
static JSBool
MakeFinalizeObserver(JSContext *cx, unsigned argc, jsval *vp)
{
RootedObject scope(cx, JS_GetGlobalForScopeChain(cx));
RootedObject scope(cx, JS::CurrentGlobalOrNull(cx));
if (!scope)
return false;

View File

@ -1,14 +1,14 @@
#include "gdb-tests.h"
FRAGMENT(JSObject, simple) {
JS::Rooted<JSObject *> glob(cx, JS_GetGlobalForScopeChain(cx));
JS::Rooted<JSObject *> glob(cx, JS::CurrentGlobalOrNull(cx));
JS::Rooted<JSObject *> plain(cx, JS_NewObject(cx, 0, 0, 0));
JS::Rooted<JSObject *> func(cx, (JSObject *) JS_NewFunction(cx, (JSNative) 1, 0, 0,
JS_GetGlobalForScopeChain(cx), "dys"));
JS::CurrentGlobalOrNull(cx), "dys"));
JS::Rooted<JSObject *> anon(cx, (JSObject *) JS_NewFunction(cx, (JSNative) 1, 0, 0,
JS_GetGlobalForScopeChain(cx), 0));
JS::CurrentGlobalOrNull(cx), 0));
JS::Rooted<JSFunction *> funcPtr(cx, JS_NewFunction(cx, (JSNative) 1, 0, 0,
JS_GetGlobalForScopeChain(cx), "formFollows"));
JS::CurrentGlobalOrNull(cx), "formFollows"));
JSObject &plainRef = *plain;
JSFunction &funcRef = *funcPtr;

View File

@ -17,7 +17,7 @@ void callee(JS::Handle<JSObject *> obj, JS::MutableHandle<JSObject *> mutableObj
}
FRAGMENT(Root, handle) {
JS::Rooted<JSObject *> global(cx, JS_GetGlobalForScopeChain(cx));
JS::Rooted<JSObject *> global(cx, JS::CurrentGlobalOrNull(cx));
callee(global, &global);
(void) global;
}

View File

@ -6,7 +6,7 @@ FRAGMENT(jsid, simple) {
JS::Rooted<jsid> string_id(cx, INTERNED_STRING_TO_JSID(cx, interned));
jsid int_id = INT_TO_JSID(1729);
jsid void_id = JSID_VOID;
JS::Rooted<jsid> object_id(cx, OBJECT_TO_JSID(JS_GetGlobalForScopeChain(cx)));
JS::Rooted<jsid> object_id(cx, OBJECT_TO_JSID(JS::CurrentGlobalOrNull(cx)));
breakpoint();

View File

@ -15,7 +15,7 @@ FRAGMENT(jsval, simple) {
friendly_string.setString(JS_NewStringCopyZ(cx, "Hello!"));
JS::Rooted<jsval> global(cx);
global.setObject(*JS_GetGlobalForScopeChain(cx));
global.setObject(*JS::CurrentGlobalOrNull(cx));
// Some interesting value that floating-point won't munge.
JS::Rooted<jsval> onehundredthirtysevenonehundredtwentyeighths(cx, DOUBLE_TO_JSVAL(137.0 / 128.0));

View File

@ -120,7 +120,7 @@ ThrowHook(JSContext *cx, JSScript *, jsbytecode *, jsval *rval, void *closure)
JS_ASSERT(!closure);
called = true;
JS::RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
char text[] = "new Error()";
jsval _;

View File

@ -57,7 +57,7 @@ struct LooseEqualityData
i42 = INT_TO_JSVAL(42);
undef = JSVAL_VOID;
null = JSVAL_NULL;
obj = OBJECT_TO_JSVAL(JS_GetGlobalForScopeChain(cx));
obj = OBJECT_TO_JSVAL(JS::CurrentGlobalOrNull(cx));
poszero = DOUBLE_TO_JSVAL(0.0);
negzero = DOUBLE_TO_JSVAL(-0.0);
#ifdef XP_WIN

View File

@ -41,7 +41,7 @@ static JSBool
test_fn2(JSContext *cx, unsigned argc, jsval *vp)
{
jsval r;
JS::RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
return JS_CallFunctionName(cx, global, "d", 0, NULL, &r);
}
@ -81,7 +81,7 @@ static JSObject*
initialize(JSContext *cx)
{
js::SetRuntimeProfilingStack(cx->runtime(), pstack, &psize, 10);
JS::RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
return JS_InitClass(cx, global, NULL, &ptestClass, Prof, 0,
NULL, ptestFunctions, NULL, NULL);
}

View File

@ -29,7 +29,7 @@ C_jsvalAlignmentTest();
BEGIN_TEST(testValueABI_retparam)
{
JS::RootedObject obj(cx, JS_GetGlobalForScopeChain(cx));
JS::RootedObject obj(cx, JS::CurrentGlobalOrNull(cx));
jsval v = OBJECT_TO_JSVAL(obj);
obj = NULL;
CHECK(C_ValueToObject(cx, v, obj.address()));

View File

@ -122,7 +122,7 @@ JSScript *createScriptViaXDR(JSPrincipals *prin, JSPrincipals *orig, int testCas
"function f() { return 1; }\n"
"f;\n";
JS::RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
JS::RootedScript script(cx, CompileScriptForPrincipalsVersionOrigin(cx, global, prin, orig,
src, strlen(src), "test", 1,
JSVERSION_DEFAULT));

View File

@ -1711,7 +1711,7 @@ JS_GetGlobalForCompartmentOrNull(JSContext *cx, JSCompartment *c)
}
JS_PUBLIC_API(JSObject *)
JS_GetGlobalForScopeChain(JSContext *cx)
JS::CurrentGlobalOrNull(JSContext *cx)
{
AssertHeapIsIdleOrIterating(cx);
CHECK_REQUEST(cx);

View File

@ -2227,8 +2227,12 @@ JS_IsGlobalObject(JSObject *obj);
extern JS_PUBLIC_API(JSObject *)
JS_GetGlobalForCompartmentOrNull(JSContext *cx, JSCompartment *c);
namespace JS {
extern JS_PUBLIC_API(JSObject *)
JS_GetGlobalForScopeChain(JSContext *cx);
CurrentGlobalOrNull(JSContext *cx);
}
/*
* This method returns the global corresponding to the most recent scripted

View File

@ -849,10 +849,10 @@ class AutoNewContext
if (!newcx)
return false;
JS_SetOptions(newcx, JS_GetOptions(newcx) | JSOPTION_DONT_REPORT_UNCAUGHT);
js::SetDefaultObjectForContext(newcx, JS_GetGlobalForScopeChain(cx));
js::SetDefaultObjectForContext(newcx, JS::CurrentGlobalOrNull(cx));
newRequest.construct(newcx);
newCompartment.construct(newcx, JS_GetGlobalForScopeChain(cx));
newCompartment.construct(newcx, JS::CurrentGlobalOrNull(cx));
return true;
}
@ -3143,7 +3143,7 @@ Compile(JSContext *cx, unsigned argc, jsval *vp)
return false;
}
RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
JSString *scriptContents = JSVAL_TO_STRING(arg0);
unsigned oldopts = JS_GetOptions(cx);
JS_SetOptions(cx, oldopts | JSOPTION_COMPILE_N_GO | JSOPTION_NO_SCRIPT_RVAL);
@ -4023,7 +4023,7 @@ Help(JSContext *cx, unsigned argc, jsval *vp)
RootedObject obj(cx);
if (argc == 0) {
RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
AutoIdArray ida(cx, JS_Enumerate(cx, global));
if (!ida)
return false;

View File

@ -208,7 +208,7 @@ File(JSContext *cx, unsigned argc, Value *vp)
}
nsXPConnect* xpc = nsXPConnect::XPConnect();
JSObject* glob = JS_GetGlobalForScopeChain(cx);
JSObject* glob = JS::CurrentGlobalOrNull(cx);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->WrapNativeToJSVal(cx, glob, native, nullptr,
@ -243,7 +243,7 @@ Blob(JSContext *cx, unsigned argc, Value *vp)
}
nsXPConnect* xpc = nsXPConnect::XPConnect();
JSObject* glob = JS_GetGlobalForScopeChain(cx);
JSObject* glob = JS::CurrentGlobalOrNull(cx);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->WrapNativeToJSVal(cx, glob, native, nullptr,

View File

@ -19,7 +19,7 @@ nsTArrayToJSArray(JSContext* aCx, const nsTArray<T>& aSourceArray,
return NS_ERROR_OUT_OF_MEMORY;
}
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
MOZ_ASSERT(global);
for (uint32_t index = 0; index < aSourceArray.Length(); index++) {

View File

@ -761,7 +761,7 @@ Blob(JSContext *cx, unsigned argc, jsval *vp)
return false;
}
JSObject* global = JS_GetGlobalForScopeChain(cx);
JSObject* global = JS::CurrentGlobalOrNull(cx);
rv = xpc->WrapNativeToJSVal(cx, global, native, nullptr,
&NS_GET_IID(nsISupports), true,
args.rval().address(), nullptr);
@ -800,7 +800,7 @@ File(JSContext *cx, unsigned argc, jsval *vp)
return false;
}
JSObject* global = JS_GetGlobalForScopeChain(cx);
JSObject* global = JS::CurrentGlobalOrNull(cx);
rv = xpc->WrapNativeToJSVal(cx, global, native, nullptr,
&NS_GET_IID(nsISupports), true,
args.rval().address(), nullptr);

View File

@ -2916,7 +2916,7 @@ CreateXMLHttpRequest(JSContext *cx, unsigned argc, jsval *vp)
if (!subjectPrincipal)
return false;
RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
MOZ_ASSERT(global);
nsIScriptObjectPrincipal *sop =

View File

@ -178,7 +178,7 @@ XPCConvert::NativeData2JS(jsval* d, const void* s,
nsID* iid2 = *((nsID**)s);
if (!iid2)
break;
RootedObject scope(cx, JS_GetGlobalForScopeChain(cx));
RootedObject scope(cx, JS::CurrentGlobalOrNull(cx));
JSObject* obj;
if (!(obj = xpc_NewIDObject(cx, scope, *iid2)))
return false;
@ -819,7 +819,7 @@ XPCConvert::NativeInterface2JSObject(jsval* d,
// optimal -- we could detect this and roll the functionality into a
// single wrapper, but the current solution is good enough for now.
AutoJSContext cx;
XPCWrappedNativeScope* xpcscope = GetObjectScope(JS_GetGlobalForScopeChain(cx));
XPCWrappedNativeScope* xpcscope = GetObjectScope(JS::CurrentGlobalOrNull(cx));
if (!xpcscope)
return false;

View File

@ -69,7 +69,7 @@ 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.
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
return nsContentUtils::WrapNative(aCx, global,
supports, &NS_GET_IID(nsISupports),
aRetval);

View File

@ -242,7 +242,7 @@ XPCThrower::ThrowExceptionObject(JSContext* cx, nsIException* e)
JS_SetPendingException(cx, thrown);
success = true;
} else if ((xpc = nsXPConnect::XPConnect())) {
JS::RootedObject glob(cx, JS_GetGlobalForScopeChain(cx));
JS::RootedObject glob(cx, JS::CurrentGlobalOrNull(cx));
if (!glob)
return false;

View File

@ -162,7 +162,7 @@ xpc_UnmarkGrayContext(JSContext *cx)
JSObject *global = js::DefaultObjectForContextOrNull(cx);
xpc_UnmarkGrayObject(global);
if (global && JS_IsInRequest(JS_GetRuntime(cx))) {
JSObject *scope = JS_GetGlobalForScopeChain(cx);
JSObject *scope = JS::CurrentGlobalOrNull(cx);
if (scope != global)
xpc_UnmarkGrayObject(scope);
}

View File

@ -1919,7 +1919,7 @@ nsCrypto::GenerateCRMFRequest(nsIDOMCRMFObject** aReturn)
JSAutoByteString jsCallback(cx, jsString);
NS_ENSURE_TRUE(!!jsCallback, NS_ERROR_OUT_OF_MEMORY);
nrv = xpc->WrapNative(cx, JS_GetGlobalForScopeChain(cx),
nrv = xpc->WrapNative(cx, JS::CurrentGlobalOrNull(cx),
static_cast<nsIDOMCrypto *>(this),
NS_GET_IID(nsIDOMCrypto), getter_AddRefs(holder));
NS_ENSURE_SUCCESS(nrv, nrv);

View File

@ -102,7 +102,7 @@ PlaceInfo::GetVisits(JSContext* aContext,
JS::Rooted<JSObject*> visits(aContext, JS_NewArrayObject(aContext, 0, NULL));
NS_ENSURE_TRUE(visits, NS_ERROR_OUT_OF_MEMORY);
JS::Rooted<JSObject*> global(aContext, JS_GetGlobalForScopeChain(aContext));
JS::Rooted<JSObject*> global(aContext, JS::CurrentGlobalOrNull(aContext));
NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIXPConnect> xpc = mozilla::services::GetXPConnect();

View File

@ -44,7 +44,7 @@ Module::Call(nsIXPConnectWrappedNative* wrapper,
const JS::CallArgs& args,
bool* _retval)
{
JSObject* global = JS_GetGlobalForScopeChain(cx);
JSObject* global = JS::CurrentGlobalOrNull(cx);
if (!global)
return NS_ERROR_NOT_AVAILABLE;

View File

@ -161,7 +161,7 @@ nsHTTPIndex::OnFTPControlLog(bool server, const char *msg)
AutoPushJSContext cx(context->GetNativeContext());
NS_ENSURE_TRUE(cx, NS_OK);
JS::Rooted<JSObject*> global(cx, JS_GetGlobalForScopeChain(cx));
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
NS_ENSURE_TRUE(global, NS_OK);
JS::Value params[2];
@ -236,7 +236,7 @@ nsHTTPIndex::OnStartRequest(nsIRequest *request, nsISupports* aContext)
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
AutoPushJSContext cx(context->GetNativeContext());
JS::Rooted<JSObject*> global(cx, JS_GetGlobalForScopeChain(cx));
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
// Using XPConnect, wrap the HTTP index object...
static NS_DEFINE_CID(kXPConnectCID, NS_XPCONNECT_CID);