mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 04:58:00 +00:00
Bug 868130 - Remove the lion's share of JSAutoRequests in gecko. r=gabor
There are still a handful that either are used with other runtimes, or that happen very early/late in cx the lifetime of various things where it doesn't necessarily make sense to have a cx on the stack. This should definitely ensure that we're not doing double-duty with the nsCxPusher change, though.
This commit is contained in:
parent
01402a7f2f
commit
f2943090bd
@ -98,7 +98,6 @@ IDToString(JSContext *cx, jsid id_)
|
||||
if (JSID_IS_STRING(id))
|
||||
return JS_GetInternedStringChars(JSID_TO_STRING(id));
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JS::Value idval;
|
||||
if (!JS_IdToValue(cx, id, &idval))
|
||||
return nullptr;
|
||||
@ -180,13 +179,11 @@ GetScriptContext(JSContext *cx)
|
||||
|
||||
inline void SetPendingException(JSContext *cx, const char *aMsg)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
JS_ReportError(cx, "%s", aMsg);
|
||||
}
|
||||
|
||||
inline void SetPendingException(JSContext *cx, const PRUnichar *aMsg)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
JS_ReportError(cx, "%hs", aMsg);
|
||||
}
|
||||
|
||||
@ -2806,8 +2803,6 @@ nsScriptSecurityManager::InitDomainPolicy(JSContext* cx,
|
||||
if (end)
|
||||
*end = '\0';
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JSString* propertyKey = ::JS_InternString(cx, start);
|
||||
if (!propertyKey)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -76,7 +76,6 @@ nsSecurityNameSet::InitializeNameSet(nsIScriptContext* aScriptContext)
|
||||
*/
|
||||
JS::Rooted<JSObject*> obj(cx, global);
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
for (;;) {
|
||||
MOZ_ALWAYS_TRUE(JS_GetPrototype(cx, obj, proto.address()));
|
||||
if (!proto)
|
||||
|
@ -1247,7 +1247,6 @@ EventSource::DispatchAllMessageEvents()
|
||||
JS::Rooted<JS::Value> jsData(cx);
|
||||
{
|
||||
JSString* jsString;
|
||||
JSAutoRequest ar(cx);
|
||||
jsString = JS_NewUCStringCopyN(cx,
|
||||
message->mData.get(),
|
||||
message->mData.Length());
|
||||
|
@ -886,30 +886,27 @@ WebSocket::CreateAndDispatchMessageEvent(const nsACString& aData,
|
||||
|
||||
// Create appropriate JS object for message
|
||||
JS::Rooted<JS::Value> jsData(cx);
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
if (isBinary) {
|
||||
if (mBinaryType == dom::BinaryType::Blob) {
|
||||
rv = nsContentUtils::CreateBlobBuffer(cx, aData, &jsData);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else if (mBinaryType == dom::BinaryType::Arraybuffer) {
|
||||
JS::Rooted<JSObject*> arrayBuf(cx);
|
||||
rv = nsContentUtils::CreateArrayBuffer(cx, aData, arrayBuf.address());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
jsData = OBJECT_TO_JSVAL(arrayBuf);
|
||||
} else {
|
||||
NS_RUNTIMEABORT("Unknown binary type!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
if (isBinary) {
|
||||
if (mBinaryType == dom::BinaryType::Blob) {
|
||||
rv = nsContentUtils::CreateBlobBuffer(cx, aData, &jsData);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else if (mBinaryType == dom::BinaryType::Arraybuffer) {
|
||||
JS::Rooted<JSObject*> arrayBuf(cx);
|
||||
rv = nsContentUtils::CreateArrayBuffer(cx, aData, arrayBuf.address());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
jsData = OBJECT_TO_JSVAL(arrayBuf);
|
||||
} else {
|
||||
// JS string
|
||||
NS_ConvertUTF8toUTF16 utf16Data(aData);
|
||||
JSString* jsString;
|
||||
jsString = JS_NewUCStringCopyN(cx, utf16Data.get(), utf16Data.Length());
|
||||
NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
|
||||
|
||||
jsData = STRING_TO_JSVAL(jsString);
|
||||
NS_RUNTIMEABORT("Unknown binary type!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
} else {
|
||||
// JS string
|
||||
NS_ConvertUTF8toUTF16 utf16Data(aData);
|
||||
JSString* jsString;
|
||||
jsString = JS_NewUCStringCopyN(cx, utf16Data.get(), utf16Data.Length());
|
||||
NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
|
||||
|
||||
jsData = STRING_TO_JSVAL(jsString);
|
||||
}
|
||||
|
||||
// create an event that uses the MessageEvent interface,
|
||||
|
@ -6172,8 +6172,6 @@ nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern,
|
||||
GetContext()->GetNativeContext());
|
||||
NS_ENSURE_TRUE(cx, true);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// The pattern has to match the entire value.
|
||||
aPattern.Insert(NS_LITERAL_STRING("^(?:"), 0);
|
||||
aPattern.Append(NS_LITERAL_STRING(")$"));
|
||||
|
@ -361,7 +361,6 @@ nsDOMDataChannel::DoOnMessageAvailable(const nsACString& aData,
|
||||
AutoPushJSContext cx(sc->GetNativeContext());
|
||||
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JS::Rooted<JS::Value> jsData(cx);
|
||||
|
||||
if (aBinary) {
|
||||
|
@ -338,7 +338,6 @@ GetParamsForMessage(JSContext* aCx,
|
||||
// properly cases when interface is implemented in JS and used
|
||||
// as a dictionary.
|
||||
nsAutoString json;
|
||||
JSAutoRequest ar(aCx);
|
||||
JS::Value v = aObject;
|
||||
NS_ENSURE_TRUE(JS_Stringify(aCx, &v, nullptr, JSVAL_NULL, JSONCreator, &json), false);
|
||||
NS_ENSURE_TRUE(!json.IsEmpty(), false);
|
||||
@ -378,7 +377,6 @@ nsFrameMessageManager::SendSyncMessage(const nsAString& aMessageName,
|
||||
|
||||
InfallibleTArray<nsString> retval;
|
||||
if (mCallback->DoSendSyncMessage(aMessageName, data, &retval)) {
|
||||
JSAutoRequest ar(aCx);
|
||||
uint32_t len = retval.Length();
|
||||
JS::Rooted<JSObject*> dataArray(aCx, JS_NewArrayObject(aCx, len, nullptr));
|
||||
NS_ENSURE_TRUE(dataArray, NS_ERROR_OUT_OF_MEMORY);
|
||||
@ -654,7 +652,6 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(ctx);
|
||||
|
||||
JSAutoRequest ar(ctx);
|
||||
JSAutoCompartment ac(ctx, object);
|
||||
|
||||
// The parameter for the listener function.
|
||||
@ -977,7 +974,6 @@ nsFrameScriptExecutor::Shutdown()
|
||||
{
|
||||
if (sCachedScripts) {
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
NS_ASSERTION(sCachedScripts != nullptr, "Need cached scripts");
|
||||
sCachedScripts->Enumerate(CachedScriptUnrooter, cx);
|
||||
|
||||
@ -1005,14 +1001,9 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
|
||||
if (holder) {
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(mCx);
|
||||
{
|
||||
// Need to scope JSAutoRequest to happen after Push but before Pop,
|
||||
// at least for now. See bug 584673.
|
||||
JSAutoRequest ar(mCx);
|
||||
JS::Rooted<JSObject*> global(mCx, mGlobal->GetJSObject());
|
||||
if (global) {
|
||||
(void) JS_ExecuteScript(mCx, global, holder->mScript, nullptr);
|
||||
}
|
||||
JS::Rooted<JSObject*> global(mCx, mGlobal->GetJSObject());
|
||||
if (global) {
|
||||
(void) JS_ExecuteScript(mCx, global, holder->mScript, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1063,36 +1054,31 @@ nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
|
||||
if (!dataString.IsEmpty()) {
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(mCx);
|
||||
{
|
||||
// Need to scope JSAutoRequest to happen after Push but before Pop,
|
||||
// at least for now. See bug 584673.
|
||||
JSAutoRequest ar(mCx);
|
||||
JS::Rooted<JSObject*> global(mCx, mGlobal->GetJSObject());
|
||||
if (global) {
|
||||
JSAutoCompartment ac(mCx, global);
|
||||
JS::CompileOptions options(mCx);
|
||||
options.setNoScriptRval(true)
|
||||
.setFileAndLine(url.get(), 1)
|
||||
.setPrincipals(nsJSPrincipals::get(mPrincipal));
|
||||
JS::RootedObject empty(mCx, nullptr);
|
||||
JS::Rooted<JSScript*> script(mCx,
|
||||
JS::Compile(mCx, empty, options, dataString.get(),
|
||||
dataString.Length()));
|
||||
JS::Rooted<JSObject*> global(mCx, mGlobal->GetJSObject());
|
||||
if (global) {
|
||||
JSAutoCompartment ac(mCx, global);
|
||||
JS::CompileOptions options(mCx);
|
||||
options.setNoScriptRval(true)
|
||||
.setFileAndLine(url.get(), 1)
|
||||
.setPrincipals(nsJSPrincipals::get(mPrincipal));
|
||||
JS::RootedObject empty(mCx, nullptr);
|
||||
JS::Rooted<JSScript*> script(mCx,
|
||||
JS::Compile(mCx, empty, options, dataString.get(),
|
||||
dataString.Length()));
|
||||
|
||||
if (script) {
|
||||
nsAutoCString scheme;
|
||||
uri->GetScheme(scheme);
|
||||
// We don't cache data: scripts!
|
||||
if (!scheme.EqualsLiteral("data")) {
|
||||
nsFrameJSScriptExecutorHolder* holder =
|
||||
new nsFrameJSScriptExecutorHolder(script);
|
||||
// Root the object also for caching.
|
||||
JS_AddNamedScriptRoot(mCx, &(holder->mScript),
|
||||
"Cached message manager script");
|
||||
sCachedScripts->Put(aURL, holder);
|
||||
} else if (aBehavior == EXECUTE_IF_CANT_CACHE) {
|
||||
(void) JS_ExecuteScript(mCx, global, script, nullptr);
|
||||
}
|
||||
if (script) {
|
||||
nsAutoCString scheme;
|
||||
uri->GetScheme(scheme);
|
||||
// We don't cache data: scripts!
|
||||
if (!scheme.EqualsLiteral("data")) {
|
||||
nsFrameJSScriptExecutorHolder* holder =
|
||||
new nsFrameJSScriptExecutorHolder(script);
|
||||
// Root the object also for caching.
|
||||
JS_AddNamedScriptRoot(mCx, &(holder->mScript),
|
||||
"Cached message manager script");
|
||||
sCachedScripts->Put(aURL, holder);
|
||||
} else if (aBehavior == EXECUTE_IF_CANT_CACHE) {
|
||||
(void) JS_ExecuteScript(mCx, global, script, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1124,7 +1110,6 @@ nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope,
|
||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
||||
JS_SetErrorReporter(cx, ContentScriptErrorReporter);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
const uint32_t flags = nsIXPConnect::INIT_JS_STANDARD_CLASSES;
|
||||
|
||||
|
@ -2962,7 +2962,6 @@ nsObjectLoadingContent::SetupProtoChain(JSContext* aCx,
|
||||
// so make sure to enter the compartment of aObject.
|
||||
MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
|
||||
|
||||
JSAutoRequest ar(aCx);
|
||||
JSAutoCompartment ac(aCx, aObject);
|
||||
|
||||
nsRefPtr<nsNPAPIPluginInstance> pi;
|
||||
@ -3072,8 +3071,6 @@ nsObjectLoadingContent::GetPluginJSObject(JSContext *cx,
|
||||
*plugin_obj = nullptr;
|
||||
*plugin_proto = nullptr;
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// NB: We need an AutoEnterCompartment because we can be called from
|
||||
// nsObjectFrame when the plugin loads after the JS object for our content
|
||||
// node has been created.
|
||||
@ -3104,7 +3101,6 @@ nsObjectLoadingContent::TeardownProtoChain()
|
||||
NS_ENSURE_TRUE(obj, /* void */);
|
||||
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
|
||||
// Loop over the DOM element's JS object prototype chain and remove
|
||||
|
@ -857,7 +857,6 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
|
||||
// Put the old script back in case it wants to do anything else.
|
||||
mCurrentScript = oldCurrent;
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
context->SetProcessingScriptTag(oldProcessingScriptTag);
|
||||
return rv;
|
||||
}
|
||||
|
@ -349,7 +349,6 @@ nsDOMEvent::Initialize(nsISupports* aOwner, JSContext* aCx, JSObject* aObj,
|
||||
mOwner = w;
|
||||
}
|
||||
|
||||
JSAutoRequest ar(aCx);
|
||||
JSString* jsstr = JS_ValueToString(aCx, aArgs[0]);
|
||||
if (!jsstr) {
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
|
@ -853,7 +853,6 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS
|
||||
aListenerStruct->mTypeAtom,
|
||||
&argCount, &argNames);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, context->GetNativeGlobal());
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(url.get(), lineNo)
|
||||
|
@ -112,18 +112,14 @@ nsEventListenerInfo::ToSource(nsAString& aResult)
|
||||
aResult.SetIsVoid(true);
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
{
|
||||
// Extra block to finish the auto request before calling pop
|
||||
JSAutoRequest ar(cx);
|
||||
mozilla::Maybe<JSAutoCompartment> ac;
|
||||
JS::Rooted<JS::Value> v(cx, JSVAL_NULL);
|
||||
if (GetJSVal(cx, ac, v.address())) {
|
||||
JSString* str = JS_ValueToSource(cx, v);
|
||||
if (str) {
|
||||
nsDependentJSString depStr;
|
||||
if (depStr.init(cx, str)) {
|
||||
aResult.Assign(depStr);
|
||||
}
|
||||
mozilla::Maybe<JSAutoCompartment> ac;
|
||||
JS::Rooted<JS::Value> v(cx, JSVAL_NULL);
|
||||
if (GetJSVal(cx, ac, v.address())) {
|
||||
JSString* str = JS_ValueToSource(cx, v);
|
||||
if (str) {
|
||||
nsDependentJSString depStr;
|
||||
if (depStr.init(cx, str)) {
|
||||
aResult.Assign(depStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,17 +142,13 @@ nsEventListenerInfo::GetDebugObject(nsISupports** aRetVal)
|
||||
NS_ENSURE_TRUE(isOn, NS_OK);
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
{
|
||||
// Extra block to finish the auto request before calling pop
|
||||
JSAutoRequest ar(cx);
|
||||
mozilla::Maybe<JSAutoCompartment> ac;
|
||||
JS::Rooted<JS::Value> v(cx, JSVAL_NULL);
|
||||
if (GetJSVal(cx, ac, v.address())) {
|
||||
nsCOMPtr<jsdIValue> jsdValue;
|
||||
rv = jsd->WrapValue(v, getter_AddRefs(jsdValue));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
jsdValue.forget(aRetVal);
|
||||
}
|
||||
mozilla::Maybe<JSAutoCompartment> ac;
|
||||
JS::Rooted<JS::Value> v(cx, JSVAL_NULL);
|
||||
if (GetJSVal(cx, ac, v.address())) {
|
||||
nsCOMPtr<jsdIValue> jsdValue;
|
||||
rv = jsd->WrapValue(v, getter_AddRefs(jsdValue));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
jsdValue.forget(aRetVal);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -3297,7 +3297,6 @@ nsHTMLDocument::DoClipboardSecurityCheck(bool aPaste)
|
||||
if (!cx) {
|
||||
return NS_OK;
|
||||
}
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(classNameStr, "Clipboard");
|
||||
|
||||
|
@ -40,7 +40,6 @@ AudioProcessingEvent::LazilyCreateBuffer(nsRefPtr<AudioBuffer>& aBuffer,
|
||||
uint32_t aNumberOfChannels)
|
||||
{
|
||||
AutoPushJSContext cx(mNode->Context()->GetJSContext());
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
aBuffer = new AudioBuffer(mNode->Context(), mNode->BufferSize(),
|
||||
mNode->Context()->SampleRate());
|
||||
|
@ -313,7 +313,6 @@ private:
|
||||
|
||||
AutoPushJSContext cx(node->Context()->GetJSContext());
|
||||
if (cx) {
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// Create the input buffer
|
||||
nsRefPtr<AudioBuffer> inputBuffer;
|
||||
|
@ -159,7 +159,6 @@ nsSpeechTask::SendAudio(const JS::Value& aData, const JS::Value& aLandmarks,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSAutoRequest ar(aCx);
|
||||
JS::Rooted<JSObject*> darray(aCx, &aData.toObject());
|
||||
JSAutoCompartment ac(aCx, darray);
|
||||
|
||||
|
@ -954,7 +954,6 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
|
||||
// that was...
|
||||
|
||||
// Find the right prototype.
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, scriptObject);
|
||||
|
||||
JS::Rooted<JSObject*> base(cx, scriptObject);
|
||||
@ -1089,7 +1088,6 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JS::Handle<JSObject*> global,
|
||||
nsAutoCString className(aClassName);
|
||||
nsAutoCString xblKey(aClassName);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
JS::Rooted<JSObject*> parent_proto(cx, nullptr);
|
||||
|
@ -278,7 +278,6 @@ nsXBLDocGlobalObject::EnsureScriptEnvironment()
|
||||
mScriptContext = newCtx;
|
||||
|
||||
AutoPushJSContext cx(mScriptContext->GetNativeContext());
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// nsJSEnvironment set the error reporter to NS_ScriptErrorReporter so
|
||||
// we must apparently override that with our own (although it isn't clear
|
||||
|
@ -88,7 +88,6 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
|
||||
holder->GetJSObject());
|
||||
|
||||
AutoPushJSContext cx(context->GetNativeContext());
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, targetClassObject);
|
||||
AutoVersionChecker avc(cx);
|
||||
|
||||
|
@ -411,8 +411,6 @@ nsXBLProtoImplField::InstallField(nsIScriptContext* aContext,
|
||||
// compile the literal string
|
||||
nsCOMPtr<nsIScriptContext> context = aContext;
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// First, enter the xbl scope, wrap the node, and use that as the scope for
|
||||
// the evaluation.
|
||||
JS::Rooted<JSObject*> scopeObject(cx, xpc::GetXBLScope(cx, aBoundNode));
|
||||
|
@ -199,7 +199,6 @@ nsXBLProtoImplMethod::CompileMember(nsIScriptContext* aContext, const nsCString&
|
||||
}
|
||||
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, aClassObject);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(functionUri.get(),
|
||||
@ -321,7 +320,6 @@ nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement)
|
||||
JS::Rooted<JSObject*> scopeObject(cx, xpc::GetXBLScope(cx, globalObject));
|
||||
NS_ENSURE_TRUE(scopeObject, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, scopeObject);
|
||||
if (!JS_WrapObject(cx, thisObject.address()))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -213,7 +213,6 @@ nsXBLProtoImplProperty::CompileMember(nsIScriptContext* aContext, const nsCStrin
|
||||
nsDependentString getter(mGetterText->GetText());
|
||||
if (!getter.IsEmpty()) {
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, aClassObject);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(functionUri.get(), mGetterText->GetLineNumber())
|
||||
@ -261,7 +260,6 @@ nsXBLProtoImplProperty::CompileMember(nsIScriptContext* aContext, const nsCStrin
|
||||
nsDependentString setter(mSetterText->GetText());
|
||||
if (!setter.IsEmpty()) {
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, aClassObject);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(functionUri.get(), mSetterText->GetLineNumber())
|
||||
|
@ -290,7 +290,6 @@ nsXBLPrototypeHandler::ExecuteHandler(EventTarget* aTarget,
|
||||
rv = EnsureEventHandler(boundGlobal, boundContext, onEventAtom, &handler);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JS::Rooted<JSObject*> globalObject(cx, boundGlobal->GetGlobalJSObject());
|
||||
JS::Rooted<JSObject*> scopeObject(cx, xpc::GetXBLScope(cx, globalObject));
|
||||
NS_ENSURE_TRUE(scopeObject, NS_ERROR_OUT_OF_MEMORY);
|
||||
@ -381,7 +380,6 @@ nsXBLPrototypeHandler::EnsureEventHandler(nsIScriptGlobalObject* aGlobal,
|
||||
&argNames);
|
||||
|
||||
// Compile the event handler in the xbl scope.
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, scopeObject);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(bindingURI.get(), mLineNumber)
|
||||
|
@ -762,8 +762,6 @@ nsXULPDGlobalObject::EnsureScriptEnvironment()
|
||||
// will re-fetch the global and set it up in our language globals array.
|
||||
{
|
||||
AutoPushJSContext cx(ctxNew->GetNativeContext());
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JS::Rooted<JSObject*> newGlob(cx,
|
||||
JS_NewGlobalObject(cx, &gSharedGlobalClass,
|
||||
nsJSPrincipals::get(GetPrincipal()), JS::SystemZone));
|
||||
|
@ -1385,9 +1385,6 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
JS::Rooted<JSObject*> scope(jscontext, global->GetGlobalJSObject());
|
||||
|
||||
JSAutoRequest ar(jscontext);
|
||||
|
||||
JS::Rooted<JS::Value> v(jscontext);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
|
||||
rv = nsContentUtils::WrapNative(jscontext, scope, mRoot, mRoot, v.address(),
|
||||
|
@ -264,7 +264,6 @@ public:
|
||||
if (!cx) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JSAutoRequest ar(cx);
|
||||
JS_AddValueRoot(cx, &mResult);
|
||||
mIsSetup = true;
|
||||
return NS_OK;
|
||||
@ -308,9 +307,6 @@ public:
|
||||
AutoPushJSContext cx(sc->GetNativeContext());
|
||||
MOZ_ASSERT(cx);
|
||||
|
||||
// We need to build a new request, otherwise we assert since there won't be
|
||||
// a request available yet.
|
||||
JSAutoRequest ar(cx);
|
||||
JS_RemoveValueRoot(cx, &mResult);
|
||||
}
|
||||
private:
|
||||
|
@ -1144,8 +1144,6 @@ nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
|
||||
else \
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
SET_JSID_TO_STRING(sParent_id, cx, "parent");
|
||||
SET_JSID_TO_STRING(sScrollbars_id, cx, "scrollbars");
|
||||
SET_JSID_TO_STRING(sLocation_id, cx, "location");
|
||||
@ -2110,8 +2108,6 @@ nsDOMClassInfo::GetArrayIndexFromId(JSContext *cx, JS::Handle<jsid> id, bool *aI
|
||||
if (JSID_IS_INT(id)) {
|
||||
i = JSID_TO_INT(id);
|
||||
} else {
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
jsval idval;
|
||||
double array_index;
|
||||
if (!::JS_IdToValue(cx, id, &idval) ||
|
||||
@ -2352,7 +2348,6 @@ nsDOMClassInfo::ResolveConstructor(JSContext *cx, JSObject *aObj,
|
||||
JS::Rooted<JSObject*> global(cx, ::JS_GetGlobalForObject(cx, obj));
|
||||
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
if (!::JS_LookupProperty(cx, global, mData->mName, val.address())) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
@ -2953,8 +2948,6 @@ nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx,
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
JS::Rooted<JSObject*> obj(cx, aObj);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
for (;;) {
|
||||
if (!::JS_GetPrototype(cx, obj, proto.address())) {
|
||||
return JS_FALSE;
|
||||
@ -2987,8 +2980,6 @@ nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx,
|
||||
nsresult
|
||||
nsWindowSH::InstallGlobalScopePolluter(JSContext *cx, JS::Handle<JSObject*> obj)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JS::Rooted<JSObject*> gsp(cx, ::JS_NewObjectWithUniqueType(cx, &sGlobalScopePolluterClass, nullptr, obj));
|
||||
if (!gsp) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -3144,7 +3135,6 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(cx);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, thisObject);
|
||||
|
||||
JS::Rooted<JS::Value> funval(cx);
|
||||
@ -4588,7 +4578,6 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
// window's own context (not on some other window-caller's
|
||||
// context).
|
||||
AutoPushJSContext my_cx(my_context ? my_context->GetNativeContext() : cx);
|
||||
JSAutoRequest ar(my_cx);
|
||||
JSAutoCompartment ac(my_cx, obj);
|
||||
|
||||
ok = JS_ResolveStandardClass(my_cx, obj, id, &did_resolve);
|
||||
@ -4751,7 +4740,6 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
// on obj with the value undefined to override the predefined property.
|
||||
// This isn't quite what WebIDL requires for [Replaceable] properties,
|
||||
// but it'll do until we move Window over to the new DOM bindings.
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
if (!::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, JS_PropertyStub,
|
||||
JS_StrictPropertyStub, JSPROP_ENUMERATE)) {
|
||||
@ -5586,7 +5574,6 @@ nsGenericArraySH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
sCurrentlyEnumerating = true;
|
||||
|
||||
JS::Rooted<JS::Value> len_val(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
JSBool ok = ::JS_GetProperty(cx, obj, "length", len_val.address());
|
||||
|
||||
if (ok && JSVAL_IS_INT(len_val)) {
|
||||
@ -6307,7 +6294,6 @@ nsHTMLFormElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
static_cast<nsHTMLFormElement*>(form.get())->FindNamedItem(name, &cache);
|
||||
|
||||
if (result) {
|
||||
JSAutoRequest ar(cx);
|
||||
*_retval = ::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, nullptr,
|
||||
nullptr, JSPROP_ENUMERATE);
|
||||
|
||||
@ -6412,8 +6398,6 @@ nsHTMLFormElementSH::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
||||
attr.AppendInt(index);
|
||||
}
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JSString *jsname =
|
||||
JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
|
||||
(attr.get()),
|
||||
@ -6523,8 +6507,6 @@ nsStringArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
nsresult rv = GetStringAt(GetNative(wrapper, obj), n, val);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
if (DOMStringIsNull(val)) {
|
||||
*vp = JSVAL_VOID;
|
||||
return NS_SUCCESS_I_DID_SOMETHING;
|
||||
@ -6743,8 +6725,6 @@ nsStorage2SH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
nsresult rv = storage->GetItem(keyStr, val);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
if (DOMStringIsNull(val)) {
|
||||
// No such key.
|
||||
*vp = JSVAL_VOID;
|
||||
|
@ -1459,7 +1459,6 @@ nsGlobalWindow::FreeInnerObjects()
|
||||
// We push a cx so that exceptions get reported in the right DOM Window.
|
||||
nsIScriptContext *scx = GetContextInternal();
|
||||
AutoPushJSContext cx(scx ? scx->GetNativeContext() : nsContentUtils::GetSafeJSContext());
|
||||
JSAutoRequest ar(cx);
|
||||
mozilla::dom::workers::CancelWorkersForWindow(cx, this);
|
||||
|
||||
// Close all offline storages for this window.
|
||||
@ -2256,8 +2255,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
nsCxPusher cxPusher;
|
||||
cxPusher.Push(cx);
|
||||
|
||||
XPCAutoRequest ar(cx);
|
||||
|
||||
nsCOMPtr<WindowStateHolder> wsh = do_QueryInterface(aState);
|
||||
NS_ASSERTION(!aState || wsh, "What kind of weird state are you giving me here?");
|
||||
|
||||
@ -6732,7 +6729,6 @@ PostMessageEvent::Run()
|
||||
// Deserialize the structured clone data
|
||||
JS::Rooted<JS::Value> messageData(cx);
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
StructuredCloneInfo scInfo;
|
||||
scInfo.event = this;
|
||||
|
||||
@ -7380,7 +7376,6 @@ public:
|
||||
JS::Rooted<JSObject*> obj(cx, currentInner->FastGetGlobalJSObject());
|
||||
// We only want to nuke wrappers for the chrome->content case
|
||||
if (obj && !js::IsSystemCompartment(js::GetObjectCompartment(obj))) {
|
||||
JSAutoRequest ar(cx);
|
||||
js::NukeCrossCompartmentWrappers(cx,
|
||||
js::ChromeCompartmentsOnly(),
|
||||
js::SingleCompartment(js::GetObjectCompartment(obj)),
|
||||
@ -10929,7 +10924,6 @@ nsGlobalWindow::SuspendTimeouts(uint32_t aIncrease,
|
||||
// We push a cx so that exceptions get reported in the right DOM Window.
|
||||
nsIScriptContext *scx = GetContextInternal();
|
||||
AutoPushJSContext cx(scx ? scx->GetNativeContext() : nsContentUtils::GetSafeJSContext());
|
||||
JSAutoRequest ar(cx);
|
||||
mozilla::dom::workers::SuspendWorkersForWindow(cx, this);
|
||||
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
@ -11022,7 +11016,6 @@ nsGlobalWindow::ResumeTimeouts(bool aThawChildren)
|
||||
// We push a cx so that exceptions get reported in the right DOM Window.
|
||||
nsIScriptContext *scx = GetContextInternal();
|
||||
AutoPushJSContext cx(scx ? scx->GetNativeContext() : nsContentUtils::GetSafeJSContext());
|
||||
JSAutoRequest ar(cx);
|
||||
mozilla::dom::workers::ResumeWorkersForWindow(cx, this);
|
||||
|
||||
// Restore all of the timeouts, using the stored time remaining
|
||||
|
@ -1267,7 +1267,6 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
||||
|
||||
// Scope the JSAutoCompartment so that it gets destroyed before we pop the
|
||||
// cx and potentially call JS_RestoreFrameChain.
|
||||
XPCAutoRequest ar(mContext);
|
||||
{
|
||||
JSAutoCompartment ac(mContext, aScopeObject);
|
||||
|
||||
@ -1339,7 +1338,6 @@ nsJSContext::CompileScript(const PRUnichar* aText,
|
||||
if (!ok || JSVersion(aVersion) == JSVERSION_UNKNOWN)
|
||||
return NS_OK;
|
||||
|
||||
XPCAutoRequest ar(cx);
|
||||
JS::CompileOptions options(cx);
|
||||
JS::CompileOptions::SourcePolicy sp = aSaveSource ?
|
||||
JS::CompileOptions::SAVE_SOURCE :
|
||||
@ -1387,8 +1385,6 @@ nsJSContext::ExecuteScript(JSScript* aScriptObject_,
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(mContext);
|
||||
|
||||
XPCAutoRequest ar(mContext);
|
||||
|
||||
// Scope the JSAutoCompartment so that it gets destroyed before we pop the
|
||||
// cx and potentially call JS_RestoreFrameChain.
|
||||
{
|
||||
@ -1485,8 +1481,6 @@ nsJSContext::BindCompiledEventHandler(nsISupports* aTarget,
|
||||
xpc_UnmarkGrayObject(aHandler);
|
||||
AutoPushJSContext cx(mContext);
|
||||
|
||||
XPCAutoRequest ar(mContext);
|
||||
|
||||
// Get the jsobject associated with this target
|
||||
JS::Rooted<JSObject*> target(cx);
|
||||
JS::Rooted<JSObject*> scope(cx, aScope);
|
||||
@ -1646,7 +1640,6 @@ nsJSContext::SetProperty(JS::Handle<JSObject*> aTarget, const char* aPropName, n
|
||||
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(mContext);
|
||||
XPCAutoRequest ar(mContext);
|
||||
|
||||
Maybe<nsRootedJSValueArray> tempStorage;
|
||||
|
||||
@ -2294,8 +2287,6 @@ nsJSContext::InitClasses(JS::Handle<JSObject*> aGlobalObj)
|
||||
nsresult rv = InitializeExternalClasses();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSAutoRequest ar(mContext);
|
||||
|
||||
JSOptionChangedCallback(js_options_dot_str, this);
|
||||
AutoPushJSContext cx(mContext);
|
||||
|
||||
|
@ -188,8 +188,6 @@ nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, bool *aIsInterval,
|
||||
JS::Rooted<JSFlatString*> expr(cx);
|
||||
JS::Rooted<JSObject*> funobj(cx);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
if (argc < 1) {
|
||||
::JS_ReportError(cx, "Function %s requires at least 2 parameter",
|
||||
*aIsInterval ? kSetIntervalStr : kSetTimeoutStr);
|
||||
|
@ -51,7 +51,6 @@ nsStructuredCloneContainer::InitFromVariant(nsIVariant *aData, JSContext *aCx)
|
||||
|
||||
// Make sure that we serialize in the right context.
|
||||
MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
|
||||
JSAutoRequest ar(aCx);
|
||||
JS_WrapValue(aCx, jsData.address());
|
||||
|
||||
uint64_t* jsBytes = nullptr;
|
||||
|
@ -90,10 +90,7 @@ CallbackObject::CallSetup::CallSetup(JS::Handle<JSObject*> aCallback,
|
||||
cx = nsContentUtils::GetSafeJSContext();
|
||||
}
|
||||
|
||||
// Victory! We have a JSContext. Now do the things we need a JSContext for.
|
||||
mAr.construct(cx);
|
||||
|
||||
// And go ahead and stick our callable in a Rooted, to make sure it can't go
|
||||
// Go ahead and stick our callable in a Rooted, to make sure it can't go
|
||||
// gray again. We can do this even though we're not in the right compartment
|
||||
// yet, because Rooted<> does not care about compartments.
|
||||
mRootedCallable.construct(cx, aCallback);
|
||||
|
@ -145,10 +145,6 @@ protected:
|
||||
// is gone
|
||||
nsAutoMicroTask mMt;
|
||||
|
||||
// Can't construct an XPCAutoRequest until we have a JSContext, so
|
||||
// this needs to be a Maybe.
|
||||
Maybe<XPCAutoRequest> mAr;
|
||||
|
||||
// We construct our JS::Rooted right after our JSAutoRequest; let's just
|
||||
// hope that the change in ordering wrt the mCxPusher constructor here is
|
||||
// ok.
|
||||
|
@ -7626,7 +7626,6 @@ class CGDictionary(CGThing):
|
||||
Argument('const nsAString&', 'aJSON'),
|
||||
], body=(
|
||||
"AutoSafeJSContext cx;\n"
|
||||
"JSAutoRequest ar(cx);\n"
|
||||
"JS::Rooted<JS::Value> json(cx);\n"
|
||||
"bool ok = ParseJSON(cx, aJSON, &json);\n"
|
||||
"NS_ENSURE_TRUE(ok, false);\n"
|
||||
|
@ -29,8 +29,6 @@ jsid s_length_id = JSID_VOID;
|
||||
bool
|
||||
DefineStaticJSVals(JSContext* cx)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
return InternJSString(cx, s_length_id, "length");
|
||||
}
|
||||
|
||||
@ -295,8 +293,6 @@ DOMProxyHandler::AppendNamedPropertyIds(JSContext* cx,
|
||||
int32_t
|
||||
IdToInt32(JSContext* cx, JS::Handle<jsid> id)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JS::Value idval;
|
||||
double array_index;
|
||||
int32_t i;
|
||||
|
@ -758,7 +758,6 @@ BluetoothService::Notify(const BluetoothSignal& aData)
|
||||
NS_ASSERTION(!::JS_IsExceptionPending(cx),
|
||||
"Shouldn't get here when an exception is pending!");
|
||||
|
||||
JSAutoRequest jsar(cx);
|
||||
JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
|
||||
if (!obj) {
|
||||
NS_WARNING("Failed to new JSObject for system message!");
|
||||
|
@ -109,7 +109,6 @@ BroadcastSystemMessage(const nsAString& aType,
|
||||
NS_ASSERTION(!::JS_IsExceptionPending(cx),
|
||||
"Shouldn't get here when an exception is pending!");
|
||||
|
||||
JSAutoRequest jsar(cx);
|
||||
JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
|
||||
if (!obj) {
|
||||
NS_WARNING("Failed to new JSObject for system message!");
|
||||
|
@ -1426,8 +1426,6 @@ JS::Value StringToJsval(nsPIDOMWindow* aWindow, nsAString& aString)
|
||||
return JSVAL_NULL;
|
||||
}
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JS::Value result = JSVAL_NULL;
|
||||
if (!xpc::StringToJsval(cx, aString, &result)) {
|
||||
return JSVAL_NULL;
|
||||
|
@ -142,7 +142,6 @@ ArchiveRequest::ReaderReady(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList,
|
||||
JS::Rooted<JSObject*> global(cx, sc->GetNativeGlobal());
|
||||
NS_ASSERTION(global, "Failed to get global object!");
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
JS::Rooted<JS::Value> result(cx);
|
||||
|
@ -83,7 +83,6 @@ FileRequest::NotifyHelperCompleted(FileHelper* aFileHelper)
|
||||
JS::Rooted<JSObject*> global(cx, sc->GetNativeGlobal());
|
||||
NS_ASSERTION(global, "Failed to get global object!");
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
rv = aFileHelper->GetSuccessResult(cx, result.address());
|
||||
|
@ -617,8 +617,6 @@ AsyncConnectionHelper::ConvertToArrayAndCleanup(
|
||||
NS_ASSERTION(aCx, "Null context!");
|
||||
NS_ASSERTION(aResult, "Null pointer!");
|
||||
|
||||
JSAutoRequest ar(aCx);
|
||||
|
||||
nsresult rv = ConvertCloneReadInfosToArrayInternal(aCx, aReadInfos, aResult);
|
||||
|
||||
for (uint32_t index = 0; index < aReadInfos.Length(); index++) {
|
||||
|
@ -544,8 +544,6 @@ IDBCursor::GetKey(JSContext* aCx,
|
||||
mRooted = true;
|
||||
}
|
||||
|
||||
JSAutoRequest ar(aCx);
|
||||
|
||||
nsresult rv = mKey.ToJSVal(aCx, &mCachedKey);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -210,7 +210,6 @@ IDBFactory::Create(ContentParent* aContentParent,
|
||||
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
NS_ASSERTION(xpc, "This should never be null!");
|
||||
|
@ -1491,8 +1491,6 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
|
||||
nsTArray<Key> keys;
|
||||
mKeys.SwapElements(keys);
|
||||
|
||||
JSAutoRequest ar(aCx);
|
||||
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, NULL));
|
||||
if (!array) {
|
||||
NS_WARNING("Failed to make array!");
|
||||
|
@ -117,7 +117,6 @@ IDBRequest::NotifyHelperCompleted(HelperBase* aHelper)
|
||||
JS::Rooted<JSObject*> global(cx, GetParentObject());
|
||||
NS_ASSERTION(global, "This should never be null!");
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
AssertIsRooted();
|
||||
|
||||
|
@ -1419,7 +1419,6 @@ TabChild::DispatchMessageManagerMessage(const nsAString& aMessageName,
|
||||
const nsACString& aJSONData)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
JS::Rooted<JS::Value> json(cx, JSVAL_NULL);
|
||||
StructuredCloneData cloneData;
|
||||
JSAutoStructuredCloneBuffer buffer;
|
||||
|
@ -1098,7 +1098,6 @@ TabParent::ReceiveMessage(const nsString& aMessage,
|
||||
nsRefPtr<nsFrameMessageManager> manager =
|
||||
frameLoader->GetFrameMessageManager();
|
||||
AutoPushJSContext ctx(manager->GetJSContext());
|
||||
JSAutoRequest ar(ctx);
|
||||
uint32_t len = 0; //TODO: obtain a real value in bug 572685
|
||||
// Because we want JS messages to have always the same properties,
|
||||
// create array even if len == 0.
|
||||
|
@ -59,7 +59,6 @@ MobileMessageCallback::NotifySuccess(nsISupports *aMessage)
|
||||
JS::Rooted<JSObject*> global(cx, scriptContext->GetNativeGlobal());
|
||||
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
JS::Rooted<JS::Value> wrappedMessage(cx);
|
||||
|
@ -71,7 +71,6 @@ MobileMessageCursorCallback::NotifyCursorResult(nsISupports* aResult)
|
||||
JS::Rooted<JSObject*> global(cx, scriptContext->GetNativeGlobal());
|
||||
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
JS::Rooted<JS::Value> wrappedResult(cx);
|
||||
|
@ -153,7 +153,6 @@ MobileMessageManager::Send(const JS::Value& aNumber_, const nsAString& aMessage,
|
||||
JS::Rooted<JSObject*> global(cx, sc->GetNativeGlobal());
|
||||
NS_ASSERTION(global, "Failed to get global object!");
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
if (aNumber.isString()) {
|
||||
|
@ -187,7 +187,6 @@ SmsManager::Send(const JS::Value& aNumber, const nsAString& aMessage, JS::Value*
|
||||
JS::Rooted<JSObject*> global(cx, sc->GetNativeGlobal());
|
||||
NS_ASSERTION(global, "Failed to get global object!");
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
if (aNumber.isString()) {
|
||||
|
@ -33,8 +33,6 @@ static JSObject*
|
||||
MmsAttachmentDataToJSObject(JSContext* aContext,
|
||||
const MmsAttachmentData& aAttachment)
|
||||
{
|
||||
JSAutoRequest ar(aContext);
|
||||
|
||||
JS::Rooted<JSObject*> obj(aContext, JS_NewObject(aContext, nullptr, nullptr, nullptr));
|
||||
NS_ENSURE_TRUE(obj, nullptr);
|
||||
|
||||
@ -78,8 +76,6 @@ GetParamsFromSendMmsMessageRequest(JSContext* aCx,
|
||||
const SendMmsMessageRequest& aRequest,
|
||||
JS::Value* aParam)
|
||||
{
|
||||
JSAutoRequest ar(aCx);
|
||||
|
||||
JS::Rooted<JSObject*> paramsObj(aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr));
|
||||
NS_ENSURE_TRUE(paramsObj, false);
|
||||
|
||||
|
@ -23,7 +23,6 @@ DeserializeArrayBuffer(JS::Handle<JSObject*> aObj,
|
||||
JS::MutableHandle<JS::Value> aVal)
|
||||
{
|
||||
JSContext* cx = nsContentUtils::GetSafeJSContext();
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, aObj);
|
||||
|
||||
JS::Rooted<JSObject*> obj(cx, JS_NewArrayBuffer(cx, aBuffer.Length()));
|
||||
|
@ -569,7 +569,6 @@ nsJSObjWrapper::NP_HasMethod(NPObject *npobj, NPIdentifier id)
|
||||
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, npjsobj->mJSObj);
|
||||
|
||||
AutoJSExceptionReporter reporter(cx);
|
||||
@ -606,7 +605,6 @@ doInvoke(NPObject *npobj, NPIdentifier method, const NPVariant *args,
|
||||
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, npjsobj->mJSObj);
|
||||
|
||||
AutoJSExceptionReporter reporter(cx);
|
||||
@ -718,7 +716,6 @@ nsJSObjWrapper::NP_HasProperty(NPObject *npobj, NPIdentifier id)
|
||||
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
AutoJSExceptionReporter reporter(cx);
|
||||
JSAutoCompartment ac(cx, npjsobj->mJSObj);
|
||||
|
||||
@ -751,7 +748,6 @@ nsJSObjWrapper::NP_GetProperty(NPObject *npobj, NPIdentifier id,
|
||||
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
AutoJSExceptionReporter reporter(cx);
|
||||
JSAutoCompartment ac(cx, npjsobj->mJSObj);
|
||||
|
||||
@ -784,7 +780,6 @@ nsJSObjWrapper::NP_SetProperty(NPObject *npobj, NPIdentifier id,
|
||||
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
AutoJSExceptionReporter reporter(cx);
|
||||
JSAutoCompartment ac(cx, npjsobj->mJSObj);
|
||||
|
||||
@ -823,7 +818,6 @@ nsJSObjWrapper::NP_RemoveProperty(NPObject *npobj, NPIdentifier id)
|
||||
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
AutoJSExceptionReporter reporter(cx);
|
||||
JS::Rooted<JS::Value> deleted(cx, JSVAL_FALSE);
|
||||
JSAutoCompartment ac(cx, npjsobj->mJSObj);
|
||||
@ -877,7 +871,6 @@ nsJSObjWrapper::NP_Enumerate(NPObject *npobj, NPIdentifier **idarray,
|
||||
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
AutoJSExceptionReporter reporter(cx);
|
||||
JSAutoCompartment ac(cx, npjsobj->mJSObj);
|
||||
|
||||
@ -1061,8 +1054,6 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, JS::Handle<JSObject*> obj)
|
||||
|
||||
NS_ASSERTION(wrapper->mNpp == npp, "nsJSObjWrapper::mNpp not initialized!");
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// Root the JSObject, its lifetime is now tied to that of the
|
||||
// NPObject.
|
||||
if (!::JS_AddNamedObjectRoot(cx, &wrapper->mJSObj, "nsJSObjWrapper::mJSObject")) {
|
||||
@ -1792,8 +1783,6 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj)
|
||||
entry->mNPObj = npobj;
|
||||
entry->mNpp = npp;
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
uint32_t generation = sNPObjWrappers.generation;
|
||||
|
||||
// No existing JSObject, create one.
|
||||
@ -1931,8 +1920,6 @@ nsJSNPRuntime::OnPluginDestroy(NPP npp)
|
||||
// Use the safe JSContext here as we're not always able to find the
|
||||
// JSContext associated with the NPP any more.
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
if (sNPObjWrappers.ops) {
|
||||
NppAndCx nppcx = { npp, cx };
|
||||
PL_DHashTableEnumerate(&sNPObjWrappers,
|
||||
|
@ -1264,7 +1264,6 @@ _getstringidentifier(const NPUTF8* name)
|
||||
}
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
return doGetIdentifier(cx, name);
|
||||
}
|
||||
|
||||
@ -1277,7 +1276,6 @@ _getstringidentifiers(const NPUTF8** names, int32_t nameCount,
|
||||
}
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
for (int32_t i = 0; i < nameCount; ++i) {
|
||||
if (names[i]) {
|
||||
@ -1493,8 +1491,6 @@ _evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result)
|
||||
nsCOMPtr<nsIScriptContext> scx = GetScriptContextFromJSContext(cx);
|
||||
NS_ENSURE_TRUE(scx, false);
|
||||
|
||||
JSAutoRequest req(cx);
|
||||
|
||||
JS::Rooted<JSObject*> obj(cx, nsNPObjWrapper::GetNewOrUsed(npp, cx, npobj));
|
||||
|
||||
if (!obj) {
|
||||
|
@ -139,7 +139,6 @@ inline bool
|
||||
NPStringIdentifierIsPermanent(NPP npp, NPIdentifier id)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
return JS_StringHasBeenInterned(cx, NPIdentifierToString(id));
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ PluginIdentifierParent::RecvRetain()
|
||||
|
||||
// The following is what nsNPAPIPlugin.cpp does. Gross, but the API doesn't
|
||||
// give you a NPP to play with.
|
||||
JSAutoRequest ar(cx);
|
||||
JSString* str = JSID_TO_STRING(id);
|
||||
JSString* str2 = JS_InternJSString(cx, str);
|
||||
if (!str2) {
|
||||
|
@ -1042,8 +1042,6 @@ PluginScriptableObjectParent::AnswerEnumerate(InfallibleTArray<PPluginIdentifier
|
||||
aProperties->SetCapacity(idCount);
|
||||
|
||||
mozilla::AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
for (uint32_t index = 0; index < idCount; index++) {
|
||||
// Because of GC hazards, all identifiers returned from enumerate
|
||||
// must be made permanent.
|
||||
|
@ -175,9 +175,6 @@ nsJSON::EncodeFromJSVal(JS::Value *value, JSContext *cx, nsAString &result)
|
||||
{
|
||||
result.Truncate();
|
||||
|
||||
// Begin a new request
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
mozilla::Maybe<JSAutoCompartment> ac;
|
||||
if (value->isObject()) {
|
||||
ac.construct(cx, &value->toObject());
|
||||
@ -198,8 +195,6 @@ nsresult
|
||||
nsJSON::EncodeInternal(JSContext* cx, const JS::Value& aValue,
|
||||
nsJSONWriter* writer)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// Backward compatibility:
|
||||
// nsIJSON does not allow to serialize anything other than objects
|
||||
if (!aValue.isObject()) {
|
||||
@ -390,8 +385,6 @@ nsJSON::DecodeFromStream(nsIInputStream *aStream, int32_t aContentLength,
|
||||
NS_IMETHODIMP
|
||||
nsJSON::DecodeToJSVal(const nsAString &str, JSContext *cx, JS::Value *result)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
if (!JS_ParseJSON(cx, static_cast<const jschar*>(PromiseFlatString(str).get()),
|
||||
str.Length(), result)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
@ -408,8 +401,6 @@ nsJSON::DecodeInternal(JSContext* cx,
|
||||
JS::Value* aRetval,
|
||||
DecodingMode mode /* = STRICT */)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// Consume the stream
|
||||
nsCOMPtr<nsIChannel> jsonChannel;
|
||||
if (!mURI) {
|
||||
@ -499,8 +490,6 @@ nsJSON::LegacyDecodeFromStream(nsIInputStream *aStream, int32_t aContentLength,
|
||||
NS_IMETHODIMP
|
||||
nsJSON::LegacyDecodeToJSVal(const nsAString &str, JSContext *cx, JS::Value *result)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JS::RootedValue reviver(cx, JS::NullValue()), value(cx);
|
||||
|
||||
JS::StableCharPtr chars(static_cast<const jschar*>(PromiseFlatString(str).get()),
|
||||
|
@ -259,8 +259,6 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
|
||||
|
||||
JS::Rooted<JS::Value> v (cx, JS::UndefinedValue());
|
||||
// Finally, we have everything needed to evaluate the expression.
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
if (useSandbox) {
|
||||
// We were asked to use a sandbox, or the channel owner isn't allowed
|
||||
// to execute in this context. Evaluate the javascript URL in a
|
||||
|
@ -679,7 +679,6 @@ GonkGPSGeolocationProvider::Handle(const nsAString& aName,
|
||||
if (aName.EqualsLiteral("ril.supl.apn")) {
|
||||
JSContext *cx = nsContentUtils::GetCurrentJSContext();
|
||||
NS_ENSURE_TRUE(cx, NS_OK);
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// When we get the APN, we attempt to call data_call_open of AGPS.
|
||||
if (aResult.isString()) {
|
||||
|
@ -487,7 +487,6 @@ SystemWorkerManager::RegisterRilWorker(unsigned int aClientId,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSAutoRequest ar(aCx);
|
||||
JSAutoCompartment ac(aCx, JSVAL_TO_OBJECT(aWorker));
|
||||
|
||||
WorkerCrossThreadDispatcher *wctd =
|
||||
@ -520,7 +519,6 @@ SystemWorkerManager::InitNetd(JSContext *cx)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(workerval), NS_ERROR_UNEXPECTED);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(workerval));
|
||||
|
||||
WorkerCrossThreadDispatcher *wctd =
|
||||
|
@ -81,7 +81,6 @@ public:
|
||||
|
||||
// Set the system timezone based on the current settings.
|
||||
if (aResult.isString()) {
|
||||
JSAutoRequest ar(cx);
|
||||
return TimeZoneSettingObserver::SetTimeZone(aResult, cx);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ public:
|
||||
void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo)
|
||||
{
|
||||
mozilla::AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
JS_ClearDateCaches(cx);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,6 @@ nsresult CentralizedAdminPrefManagerInit()
|
||||
|
||||
// Create a sandbox.
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> sandbox;
|
||||
rv = xpc->CreateSandbox(cx, principal, getter_AddRefs(sandbox));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -72,7 +71,6 @@ nsresult CentralizedAdminPrefManagerFinish()
|
||||
{
|
||||
if (autoconfigSb) {
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment(cx, autoconfigSb);
|
||||
JS_RemoveObjectRoot(cx, &autoconfigSb);
|
||||
JS_MaybeGC(cx);
|
||||
@ -115,7 +113,6 @@ nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length,
|
||||
}
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, autoconfigSb);
|
||||
|
||||
nsAutoCString script(js_buffer, length);
|
||||
|
@ -27,7 +27,6 @@ namespace {
|
||||
class MOZ_STACK_CLASS AutoContextPusher {
|
||||
|
||||
nsCxPusher mStack;
|
||||
JSAutoRequest mRequest;
|
||||
JSContext* const mContext;
|
||||
const uint32_t mSavedOptions;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
@ -36,8 +35,7 @@ namespace {
|
||||
|
||||
AutoContextPusher(JSContext* cx
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mRequest(cx)
|
||||
, mContext(cx)
|
||||
: mContext(cx)
|
||||
, mSavedOptions(JS_SetOptions(cx, (JS_GetOptions(cx) |
|
||||
JSOPTION_DONT_REPORT_UNCAUGHT)))
|
||||
{
|
||||
@ -117,7 +115,6 @@ ObjectWrapperChild::ObjectWrapperChild(JSContext* cx, JSObject* obj)
|
||||
: mObj(obj)
|
||||
{
|
||||
AutoContextPusher acp(cx);
|
||||
JSAutoRequest request(cx);
|
||||
#ifdef DEBUG
|
||||
bool added =
|
||||
#endif
|
||||
@ -130,7 +127,6 @@ ObjectWrapperChild::ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
JSContext* cx = Manager()->GetContext();
|
||||
AutoContextPusher acp(cx);
|
||||
JSAutoRequest request(cx);
|
||||
JS_RemoveObjectRoot(cx, &mObj);
|
||||
}
|
||||
|
||||
|
@ -995,7 +995,6 @@ PCMapEntry *
|
||||
jsdScript::CreatePPLineMap()
|
||||
{
|
||||
JSContext *cx = JSD_GetDefaultJSContext (mCx);
|
||||
JSAutoRequest ar(cx);
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
@ -1240,7 +1239,6 @@ jsdScript::GetParameterNames(uint32_t* count, PRUnichar*** paramNames)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, JS_GetFunctionObject(fun));
|
||||
|
||||
unsigned nargs;
|
||||
@ -1330,8 +1328,6 @@ jsdScript::GetFunctionSource(nsAString & aFunctionSource)
|
||||
}
|
||||
JS::RootedFunction fun(cx, JSD_GetJSFunction (mCx, mScript));
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JSString *jsstr;
|
||||
mozilla::Maybe<JSAutoCompartment> ac;
|
||||
if (fun) {
|
||||
@ -2040,7 +2036,6 @@ jsdStackFrame::Eval (const nsAString &bytes, const nsACString &fileName,
|
||||
JSContext *cx = JSD_GetJSContext (mCx, mThreadState);
|
||||
|
||||
JS::RootedValue jv(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
estate = JS_SaveExceptionState (cx);
|
||||
JS_ClearPendingException (cx);
|
||||
@ -2354,8 +2349,6 @@ jsdValue::GetProperty (const nsACString &name, jsdIProperty **_rval)
|
||||
ASSERT_VALID_EPHEMERAL;
|
||||
JSContext *cx = JSD_GetDefaultJSContext (mCx);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
/* not rooting this */
|
||||
JSString *jstr_name = JS_NewStringCopyZ(cx, PromiseFlatCString(name).get());
|
||||
if (!jstr_name)
|
||||
|
@ -1138,7 +1138,6 @@ mozJSComponentLoader::UnloadModules()
|
||||
|
||||
RootedObject global(mContext, mLoaderGlobal->GetJSObject());
|
||||
if (global) {
|
||||
JSAutoRequest ar(mContext);
|
||||
JS_SetAllNonReservedSlotsToUndefined(mContext, global);
|
||||
} else {
|
||||
NS_WARNING("Going to leak!");
|
||||
@ -1170,7 +1169,6 @@ mozJSComponentLoader::Import(const nsACString& registryLocation,
|
||||
uint8_t optionalArgc,
|
||||
JS::Value* retval)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
|
||||
|
||||
RootedValue targetVal(cx, targetValArg);
|
||||
|
@ -198,8 +198,6 @@ mozJSSubScriptLoader::LoadSubScript(const nsAString& url,
|
||||
return rv;
|
||||
}
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
RootedObject targetObj(cx);
|
||||
mozJSComponentLoader* loader = mozJSComponentLoader::Get();
|
||||
rv = loader->FindTargetObject(cx, &targetObj);
|
||||
|
@ -11,7 +11,6 @@ nsTArrayToJSArray(JSContext* aCx, const nsTArray<T>& aSourceArray,
|
||||
JSObject** aResultArray)
|
||||
{
|
||||
MOZ_ASSERT(aCx);
|
||||
JSAutoRequest ar(aCx);
|
||||
|
||||
JS::Rooted<JSObject*> arrayObj(aCx,
|
||||
JS_NewArrayObject(aCx, aSourceArray.Length(), nullptr));
|
||||
@ -55,7 +54,6 @@ nsTArrayToJSArray<nsString>(JSContext* aCx,
|
||||
JSObject** aResultArray)
|
||||
{
|
||||
MOZ_ASSERT(aCx);
|
||||
JSAutoRequest ar(aCx);
|
||||
|
||||
JS::Rooted<JSObject*> arrayObj(aCx,
|
||||
JS_NewArrayObject(aCx, aSourceArray.Length(), nullptr));
|
||||
|
@ -1897,7 +1897,6 @@ main(int argc, char **argv, char **envp)
|
||||
|
||||
backstagePass->SetGlobalObject(glob);
|
||||
|
||||
JS_BeginRequest(cx);
|
||||
{
|
||||
JSAutoCompartment ac(cx, glob);
|
||||
|
||||
@ -1932,8 +1931,7 @@ main(int argc, char **argv, char **envp)
|
||||
JS_DropPrincipals(rt, gJSPrincipals);
|
||||
JS_SetAllNonReservedSlotsToUndefined(cx, glob);
|
||||
JS_GC(rt);
|
||||
} //this scopes the JSAutoCrossCompartmentCall
|
||||
JS_EndRequest(cx);
|
||||
}
|
||||
pusher.Pop();
|
||||
JS_GC(rt);
|
||||
JS_DestroyContext(cx);
|
||||
|
@ -2695,8 +2695,6 @@ nsXPCComponents_Utils::LookupMethod(const JS::Value& object,
|
||||
JSContext *cx,
|
||||
JS::Value *retval)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// first param must be a JSObject
|
||||
if (!object.isObject())
|
||||
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
||||
@ -2773,8 +2771,6 @@ nsXPCComponents_Utils::ReportError(const JS::Value &errorArg, JSContext *cx)
|
||||
if (!scripterr || !console)
|
||||
return NS_OK;
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
const uint64_t innerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx);
|
||||
|
||||
JSErrorReport *err = JS_ErrorFromException(cx, error);
|
||||
@ -3806,7 +3802,6 @@ ContextHolder::ContextHolder(JSContext *aOuterCx,
|
||||
IsSystemPrincipal(mPrincipal, &isChrome);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
JSAutoRequest ar(mJSContext);
|
||||
JS_SetOptions(mJSContext,
|
||||
JS_GetOptions(mJSContext) |
|
||||
JSOPTION_DONT_REPORT_UNCAUGHT |
|
||||
@ -3911,7 +3906,6 @@ xpc_EvalInSandbox(JSContext *cx, HandleObject sandboxArg, const nsAString& sourc
|
||||
JSVersion jsVersion, bool returnStringOnly, MutableHandleValue rval)
|
||||
{
|
||||
JS_AbortIfWrongThread(JS_GetRuntime(cx));
|
||||
JSAutoRequest ar(cx);
|
||||
rval.set(UndefinedValue());
|
||||
|
||||
bool waiveXray = xpc::WrapperFactory::HasWaiveXrayFlag(sandboxArg);
|
||||
@ -3950,8 +3944,6 @@ xpc_EvalInSandbox(JSContext *cx, HandleObject sandboxArg, const nsAString& sourc
|
||||
}
|
||||
nsCxPusher pusher;
|
||||
pusher.Push(sandcx);
|
||||
|
||||
JSAutoRequest req(sandcx);
|
||||
JSAutoCompartment ac(sandcx, sandbox);
|
||||
|
||||
if (jsVersion != JSVERSION_DEFAULT)
|
||||
|
@ -97,8 +97,6 @@ xpc_DumpEvalInJSStackFrame(JSContext* cx, uint32_t frameno, const char* text)
|
||||
return false;
|
||||
}
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JSExceptionState* exceptionState = JS_SaveExceptionState(cx);
|
||||
JSErrorReporter older = JS_SetErrorReporter(cx, xpcDumpEvalErrorReporter);
|
||||
|
||||
|
@ -3023,7 +3023,6 @@ XPCJSRuntime::GetJunkScope()
|
||||
AutoSafeJSContext cx;
|
||||
SandboxOptions options(cx);
|
||||
options.sandboxName.AssignASCII("XPConnect Junk Compartment");
|
||||
JSAutoRequest ac(cx);
|
||||
RootedValue v(cx);
|
||||
nsresult rv = xpc_CreateSandboxObject(cx, v.address(),
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
@ -3043,8 +3042,7 @@ XPCJSRuntime::DeleteJunkScope()
|
||||
if(!mJunkScope)
|
||||
return;
|
||||
|
||||
JSContext *cx = mJSContextStack->GetSafeJSContext();
|
||||
JSAutoRequest ac(cx);
|
||||
AutoSafeJSContext cx;
|
||||
JS_RemoveObjectRoot(cx, &mJunkScope);
|
||||
mJunkScope = nullptr;
|
||||
}
|
||||
|
@ -16,8 +16,6 @@ NS_IMPL_ISUPPORTS1(xpcJSWeakReference, xpcIJSWeakReference)
|
||||
|
||||
nsresult xpcJSWeakReference::Init(JSContext* cx, const JS::Value& object)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
if (!object.isObject())
|
||||
return NS_OK;
|
||||
|
||||
|
@ -120,7 +120,6 @@ LogSlimWrapperNotCreated(JSContext *cx, nsISupports *obj, const char *reason)
|
||||
className ? " for " : "", className ? className : "", reason, obj);
|
||||
if (className)
|
||||
PR_Free(className);
|
||||
JSAutoRequest autoRequest(cx);
|
||||
xpc_DumpJSStack(cx, false, false, false);
|
||||
}
|
||||
#endif
|
||||
|
@ -254,7 +254,6 @@ XPCWrappedNativeScope::EnsureXBLScope(JSContext *cx)
|
||||
ep = new nsExpandedPrincipal(principalAsArray);
|
||||
|
||||
// Create the sandbox.
|
||||
JSAutoRequest ar(cx);
|
||||
JS::RootedValue v(cx, JS::UndefinedValue());
|
||||
nsresult rv = xpc_CreateSandboxObject(cx, v.address(), ep, options);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
@ -211,7 +211,6 @@ def print_cpp_file(fd, conf):
|
||||
"bool\n"
|
||||
"InternStaticDictionaryJSVals(JSContext* aCx)\n"
|
||||
"{\n"
|
||||
" JSAutoRequest ar(aCx);\n"
|
||||
" return\n")
|
||||
for a in attrnames:
|
||||
fd.write(" InternStaticJSVal(aCx, %s, \"%s\") &&\n"
|
||||
@ -407,7 +406,6 @@ def write_cpp(iface, fd):
|
||||
" JS::RootedObject obj(aCx, &aVal->toObject());\n"
|
||||
" nsCxPusher pusher;\n"
|
||||
" pusher.Push(aCx);\n"
|
||||
" JSAutoRequest ar(aCx);\n"
|
||||
" JSAutoCompartment ac(aCx, obj);\n")
|
||||
|
||||
fd.write(" return %s_InitInternal(*this, aCx, obj);\n}\n\n" %
|
||||
|
@ -2017,7 +2017,6 @@ nsXPConnect::CheckForDebugMode(JSRuntime *rt)
|
||||
AutoDestroyContext(JSContext *cx) : cx(cx) {}
|
||||
~AutoDestroyContext() { JS_DestroyContext(cx); }
|
||||
} adc(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
if (!JS_SetDebugModeForAllCompartments(cx, gDesiredDebugMode))
|
||||
goto fail;
|
||||
@ -2478,7 +2477,6 @@ WriteScriptOrFunction(nsIObjectOutputStream *stream, JSContext *cx,
|
||||
uint32_t size;
|
||||
void* data;
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
if (functionObj)
|
||||
data = JS_EncodeInterpretedFunction(cx, functionObj, &size);
|
||||
else
|
||||
@ -2537,7 +2535,6 @@ ReadScriptOrFunction(nsIObjectInputStream *stream, JSContext *cx,
|
||||
return rv;
|
||||
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
if (scriptp) {
|
||||
JSScript *script = JS_DecodeScript(cx, data, size, principal, originPrincipal);
|
||||
if (!script)
|
||||
|
@ -205,15 +205,6 @@ xpc_UnmarkGrayContext(JSContext *cx)
|
||||
return cx;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
class XPCAutoRequest : public JSAutoRequest {
|
||||
public:
|
||||
XPCAutoRequest(JSContext *cx) : JSAutoRequest(cx) {
|
||||
xpc_UnmarkGrayContext(cx);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
// If aVariant is an XPCVariant, this marks the object to be in aGeneration.
|
||||
// This also unmarks the gray JSObject.
|
||||
extern void
|
||||
|
@ -3,11 +3,13 @@
|
||||
* file, You can obtain one at http:mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCxPusher.h"
|
||||
#include "mozilla/net/Dashboard.h"
|
||||
#include "mozilla/net/HttpInfo.h"
|
||||
#include "mozilla/dom/NetDashboardBinding.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
using mozilla::AutoSafeJSContext;
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
@ -49,8 +51,7 @@ Dashboard::GetSocketsDispatch()
|
||||
nsresult
|
||||
Dashboard::GetSockets()
|
||||
{
|
||||
JSContext* cx = nsContentUtils::GetSafeJSContext();
|
||||
JSAutoRequest request(cx);
|
||||
AutoSafeJSContext cx;
|
||||
|
||||
mozilla::dom::SocketsDict dict;
|
||||
dict.mHost.Construct();
|
||||
@ -128,8 +129,7 @@ Dashboard::GetHttpDispatch()
|
||||
nsresult
|
||||
Dashboard::GetHttpConnections()
|
||||
{
|
||||
JSContext* cx = nsContentUtils::GetSafeJSContext();
|
||||
JSAutoRequest request(cx);
|
||||
AutoSafeJSContext cx;
|
||||
|
||||
mozilla::dom::HttpConnDict dict;
|
||||
dict.mActive.Construct();
|
||||
@ -299,8 +299,7 @@ Dashboard::RequestWebsocketConnections(NetDashboardCallback* cb)
|
||||
nsresult
|
||||
Dashboard::GetWebSocketConnections()
|
||||
{
|
||||
JSContext* cx = nsContentUtils::GetSafeJSContext();
|
||||
JSAutoRequest request(cx);
|
||||
AutoSafeJSContext cx;
|
||||
|
||||
mozilla::dom::WebSocketDict dict;
|
||||
dict.mEncrypted.Construct();
|
||||
@ -382,8 +381,7 @@ Dashboard::GetDnsInfoDispatch()
|
||||
nsresult
|
||||
Dashboard::GetDNSCacheEntries()
|
||||
{
|
||||
JSContext* cx = nsContentUtils::GetSafeJSContext();
|
||||
JSAutoRequest request(cx);
|
||||
AutoSafeJSContext cx;
|
||||
|
||||
mozilla::dom::DNSCacheDict dict;
|
||||
dict.mExpiration.Construct();
|
||||
|
@ -1859,8 +1859,6 @@ nsCrypto::GenerateCRMFRequest(nsIDOMCRMFObject** aReturn)
|
||||
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
/*
|
||||
* Get all of the parameters.
|
||||
*/
|
||||
|
@ -716,7 +716,6 @@ nsBinaryInputStream::ReadByteArray(uint32_t aLength, uint8_t* *_rval)
|
||||
NS_IMETHODIMP
|
||||
nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength, const JS::Value& aBuffer, JSContext* cx)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
if (!aBuffer.isObject()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -168,7 +168,6 @@ nsHTTPIndex::OnFTPControlLog(bool server, const char *msg)
|
||||
|
||||
nsString unicodeMsg;
|
||||
unicodeMsg.AssignWithConversion(msg);
|
||||
JSAutoRequest ar(cx);
|
||||
JSString* jsMsgStr = JS_NewUCStringCopyZ(cx, (jschar*) unicodeMsg.get());
|
||||
NS_ENSURE_TRUE(jsMsgStr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
@ -262,7 +261,6 @@ nsHTTPIndex::OnStartRequest(nsIRequest *request, nsISupports* aContext)
|
||||
JS::Rooted<JS::Value> jslistener(cx, OBJECT_TO_JSVAL(jsobj));
|
||||
|
||||
// ...and stuff it into the global context
|
||||
JSAutoRequest ar(cx);
|
||||
bool ok = JS_SetProperty(cx, global, "HTTPIndex", jslistener.address());
|
||||
NS_ASSERTION(ok, "unable to set Listener property");
|
||||
if (!ok)
|
||||
|
Loading…
x
Reference in New Issue
Block a user