Bug 868130 - Remove the lion's share of JSAutoRequests in gecko. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Wed, 22 May 2013 10:05:28 -0600
changeset 145017 bd355364bc33747548db82bfd267fecd518f3ec3
parent 145016 91c863ec30516ff72648a426227e77a3f39a5f93
child 145018 b96fa35bafe80b885806738e3842c86a828b376e
push id368
push userbbajaj@mozilla.com
push dateMon, 09 Sep 2013 22:57:58 +0000
treeherdermozilla-release@5a4f47ae1217 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs868130
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
caps/src/nsScriptSecurityManager.cpp
caps/src/nsSecurityManagerFactory.cpp
content/base/src/EventSource.cpp
content/base/src/WebSocket.cpp
content/base/src/nsContentUtils.cpp
content/base/src/nsDOMDataChannel.cpp
content/base/src/nsFrameMessageManager.cpp
content/base/src/nsObjectLoadingContent.cpp
content/base/src/nsScriptLoader.cpp
content/events/src/nsDOMEvent.cpp
content/events/src/nsEventListenerManager.cpp
content/events/src/nsEventListenerService.cpp
content/html/document/src/nsHTMLDocument.cpp
content/media/webaudio/AudioProcessingEvent.cpp
content/media/webaudio/ScriptProcessorNode.cpp
content/media/webspeech/synth/nsSpeechTask.cpp
content/xbl/src/nsXBLBinding.cpp
content/xbl/src/nsXBLDocumentInfo.cpp
content/xbl/src/nsXBLProtoImpl.cpp
content/xbl/src/nsXBLProtoImplField.cpp
content/xbl/src/nsXBLProtoImplMethod.cpp
content/xbl/src/nsXBLProtoImplProperty.cpp
content/xbl/src/nsXBLPrototypeHandler.cpp
content/xul/document/src/nsXULPrototypeDocument.cpp
content/xul/templates/src/nsXULTemplateBuilder.cpp
dom/base/DOMRequest.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsJSEnvironment.cpp
dom/base/nsJSTimeoutHandler.cpp
dom/base/nsStructuredCloneContainer.cpp
dom/bindings/CallbackObject.cpp
dom/bindings/CallbackObject.h
dom/bindings/Codegen.py
dom/bindings/DOMJSProxyHandler.cpp
dom/bluetooth/BluetoothService.cpp
dom/bluetooth/BluetoothUtils.cpp
dom/devicestorage/nsDeviceStorage.cpp
dom/file/ArchiveRequest.cpp
dom/file/FileRequest.cpp
dom/indexedDB/AsyncConnectionHelper.cpp
dom/indexedDB/IDBCursor.cpp
dom/indexedDB/IDBFactory.cpp
dom/indexedDB/IDBIndex.cpp
dom/indexedDB/IDBRequest.cpp
dom/ipc/TabChild.cpp
dom/ipc/TabParent.cpp
dom/mobilemessage/src/MobileMessageCallback.cpp
dom/mobilemessage/src/MobileMessageCursorCallback.cpp
dom/mobilemessage/src/MobileMessageManager.cpp
dom/mobilemessage/src/SmsManager.cpp
dom/mobilemessage/src/ipc/SmsParent.cpp
dom/network/src/TCPSocketChild.cpp
dom/plugins/base/nsJSNPRuntime.cpp
dom/plugins/base/nsNPAPIPlugin.cpp
dom/plugins/base/nsNPAPIPlugin.h
dom/plugins/ipc/PluginIdentifierParent.cpp
dom/plugins/ipc/PluginScriptableObjectParent.cpp
dom/src/json/nsJSON.cpp
dom/src/jsurl/nsJSProtocolHandler.cpp
dom/system/gonk/GonkGPSGeolocationProvider.cpp
dom/system/gonk/SystemWorkerManager.cpp
dom/system/gonk/TimeZoneSettingObserver.cpp
dom/time/DateCacheCleaner.cpp
extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp
js/ipc/ObjectWrapperChild.cpp
js/jsd/jsd_xpc.cpp
js/xpconnect/loader/mozJSComponentLoader.cpp
js/xpconnect/loader/mozJSSubScriptLoader.cpp
js/xpconnect/public/nsTArrayHelpers.h
js/xpconnect/shell/xpcshell.cpp
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/XPCDebug.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCJSWeakReference.cpp
js/xpconnect/src/XPCLog.cpp
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/dictionary_helper_gen.py
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcpublic.h
netwerk/base/src/Dashboard.cpp
security/manager/ssl/src/nsCrypto.cpp
xpcom/io/nsBinaryStream.cpp
xpfe/components/directory/nsDirectoryViewer.cpp
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -93,17 +93,16 @@ nsScriptSecurityManager::SubjectIsPrivil
 // Result of this function should not be freed.
 static inline const PRUnichar *
 IDToString(JSContext *cx, jsid id_)
 {
     JS::RootedId id(cx, 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;
     JSString *str = JS_ValueToString(cx, idval);
     if(!str)
         return nullptr;
     return JS_GetStringCharsZ(cx, str);
 }
@@ -175,23 +174,21 @@ GetPrincipalDomainOrigin(nsIPrincipal* a
 static nsIScriptContext *
 GetScriptContext(JSContext *cx)
 {
     return GetScriptContextFromJSContext(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);
 }
 
 // DomainPolicy members
 uint32_t DomainPolicy::sGeneration = 0;
 
 // Helper class to get stuff from the ClassInfo and not waste extra time with
 // virtual method calls for things it has already gotten
@@ -2801,18 +2798,16 @@ nsScriptSecurityManager::InitDomainPolic
         }
 
         // Get the property name
         start = end + 1;
         end = PL_strchr(start, '.');
         if (end)
             *end = '\0';
 
-        JSAutoRequest ar(cx);
-
         JSString* propertyKey = ::JS_InternString(cx, start);
         if (!propertyKey)
             return NS_ERROR_OUT_OF_MEMORY;
 
         // Store this property in the class policy
         PropertyPolicy* ppolicy = 
           static_cast<PropertyPolicy*>
                      (PL_DHashTableOperate(cpolicy->mPolicy, propertyKey,
--- a/caps/src/nsSecurityManagerFactory.cpp
+++ b/caps/src/nsSecurityManagerFactory.cpp
@@ -71,17 +71,16 @@ nsSecurityNameSet::InitializeNameSet(nsI
     JSAutoCompartment ac(cx, global);
 
     /*
      * Find Object.prototype's class by walking up the global object's
      * prototype chain.
      */
     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)
             break;
         obj = proto;
     }
     JSClass *objectClass = JS_GetClass(obj);
 
--- a/content/base/src/EventSource.cpp
+++ b/content/base/src/EventSource.cpp
@@ -1242,17 +1242,16 @@ EventSource::DispatchAllMessageEvents()
   while (mMessagesToDispatch.GetSize() > 0) {
     nsAutoPtr<Message>
       message(static_cast<Message*>(mMessagesToDispatch.PopFront()));
 
     // Now we can turn our string into a jsval
     JS::Rooted<JS::Value> jsData(cx);
     {
       JSString* jsString;
-      JSAutoRequest ar(cx);
       jsString = JS_NewUCStringCopyN(cx,
                                      message->mData.get(),
                                      message->mData.Length());
       NS_ENSURE_TRUE_VOID(jsString);
 
       jsData = STRING_TO_JSVAL(jsString);
     }
 
--- a/content/base/src/WebSocket.cpp
+++ b/content/base/src/WebSocket.cpp
@@ -881,40 +881,37 @@ WebSocket::CreateAndDispatchMessageEvent
   nsIScriptContext* scriptContext = sgo->GetContext();
   NS_ENSURE_TRUE(scriptContext, NS_ERROR_FAILURE);
 
   AutoPushJSContext cx(scriptContext->GetNativeContext());
   NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
 
   // 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);
+      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);
-    }
+    jsData = STRING_TO_JSVAL(jsString);
   }
 
   // create an event that uses the MessageEvent interface,
   // which does not bubble, is not cancelable, and has no default action
 
   nsCOMPtr<nsIDOMEvent> event;
   rv = NS_NewDOMMessageEvent(getter_AddRefs(event), this, nullptr, nullptr);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -6167,18 +6167,16 @@ nsContentUtils::IsPatternMatching(nsAStr
 {
   NS_ASSERTION(aDocument, "aDocument should be a valid pointer (not null)");
   NS_ENSURE_TRUE(aDocument->GetScriptGlobalObject(), true);
 
   AutoPushJSContext cx(aDocument->GetScriptGlobalObject()->
                        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(")$"));
 
   JSObject* re = JS_NewUCRegExpObjectNoStatics(cx, static_cast<jschar*>
                                                  (aPattern.BeginWriting()),
                                                aPattern.Length(), 0);
   if (!re) {
--- a/content/base/src/nsDOMDataChannel.cpp
+++ b/content/base/src/nsDOMDataChannel.cpp
@@ -356,17 +356,16 @@ nsDOMDataChannel::DoOnMessageAvailable(c
   NS_ENSURE_TRUE(sgo, NS_ERROR_FAILURE);
 
   nsIScriptContext* sc = sgo->GetContext();
   NS_ENSURE_TRUE(sc, NS_ERROR_FAILURE);
 
   AutoPushJSContext cx(sc->GetNativeContext());
   NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
 
-  JSAutoRequest ar(cx);
   JS::Rooted<JS::Value> jsData(cx);
 
   if (aBinary) {
     if (mBinaryType == DC_BINARY_TYPE_BLOB) {
       rv = nsContentUtils::CreateBlobBuffer(cx, aData, &jsData);
       NS_ENSURE_SUCCESS(rv, rv);
     } else if (mBinaryType == DC_BINARY_TYPE_ARRAYBUFFER) {
       JS::Rooted<JSObject*> arrayBuf(cx);
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -333,17 +333,16 @@ GetParamsForMessage(JSContext* aCx,
   }
   JS_ClearPendingException(aCx);
 
   // Not clonable, try JSON
   //XXX This is ugly but currently structured cloning doesn't handle
   //    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);
 
   JS::Rooted<JS::Value> val(aCx, JS::NullValue());
   NS_ENSURE_TRUE(JS_ParseJSON(aCx, static_cast<const jschar*>(json.get()),
                               json.Length(), val.address()), false);
 
@@ -373,17 +372,16 @@ nsFrameMessageManager::SendSyncMessage(c
       !GetParamsForMessage(aCx, aObject, buffer, data.mClosure)) {
     return NS_ERROR_DOM_DATA_CLONE_ERR;
   }
   data.mData = buffer.data();
   data.mDataLength = buffer.nbytes();
 
   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);
 
     for (uint32_t i = 0; i < len; ++i) {
       if (retval[i].IsEmpty()) {
         continue;
       }
@@ -649,17 +647,16 @@ nsFrameMessageManager::ReceiveMessage(ns
         }
         JS::Rooted<JSObject*> object(ctx, wrappedJS->GetJSObject());
         if (!object) {
           continue;
         }
         nsCxPusher pusher;
         pusher.Push(ctx);
 
-        JSAutoRequest ar(ctx);
         JSAutoCompartment ac(ctx, object);
 
         // The parameter for the listener function.
         JS::Rooted<JSObject*> param(ctx,
           JS_NewObject(ctx, nullptr, nullptr, nullptr));
         NS_ENSURE_TRUE(param, NS_ERROR_OUT_OF_MEMORY);
 
         JS::Rooted<JS::Value> targetv(ctx);
@@ -972,17 +969,16 @@ CachedScriptUnrooter(const nsAString& aK
 }
 
 // static
 void
 nsFrameScriptExecutor::Shutdown()
 {
   if (sCachedScripts) {
     AutoSafeJSContext cx;
-    JSAutoRequest ar(cx);
     NS_ASSERTION(sCachedScripts != nullptr, "Need cached scripts");
     sCachedScripts->Enumerate(CachedScriptUnrooter, cx);
 
     delete sCachedScripts;
     sCachedScripts = nullptr;
 
     nsRefPtr<nsScriptCacheCleaner> scriptCacheCleaner;
     scriptCacheCleaner.swap(sScriptCacheCleaner);
@@ -1000,24 +996,19 @@ nsFrameScriptExecutor::LoadFrameScriptIn
   if (!holder) {
     TryCacheLoadAndCompileScript(aURL, EXECUTE_IF_CANT_CACHE);
     holder = sCachedScripts->Get(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);
     }
   }
 }
 
 void
 nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
                                                     CacheFailedBehavior aBehavior)
 {
@@ -1058,46 +1049,41 @@ nsFrameScriptExecutor::TryCacheLoadAndCo
     }
     nsScriptLoader::ConvertToUTF16(channel, (uint8_t*)buffer.get(), avail,
                                    EmptyString(), nullptr, dataString);
   }
 
   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);
         }
       }
     }
   }
 }
 
 bool
 nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope,
@@ -1119,17 +1105,16 @@ nsFrameScriptExecutor::InitTabChildGloba
   mCx = cx;
 
   nsContentUtils::GetSecurityManager()->GetSystemPrincipal(getter_AddRefs(mPrincipal));
 
   JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_PRIVATE_IS_NSISUPPORTS);
   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;
 
 
   JS_SetContextPrivate(cx, aScope);
 
   nsresult rv =
     xpc->InitClassesWithNewWrappedGlobal(cx, aScope, mPrincipal,
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -2957,17 +2957,16 @@ nsObjectLoadingContent::SetupProtoChain(
     return;
   }
 
   // We get called on random compartments here for some reason
   // (perhaps because WrapObject can happen on a random compartment?)
   // so make sure to enter the compartment of aObject.
   MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
 
-  JSAutoRequest ar(aCx);
   JSAutoCompartment ac(aCx, aObject);
 
   nsRefPtr<nsNPAPIPluginInstance> pi;
   nsresult rv = ScriptRequestPluginInstance(aCx, getter_AddRefs(pi));
   if (NS_FAILED(rv)) {
     return;
   }
 
@@ -3067,18 +3066,16 @@ nsObjectLoadingContent::GetPluginJSObjec
                                           JS::Handle<JSObject*> obj,
                                           nsNPAPIPluginInstance *plugin_inst,
                                           JSObject **plugin_obj,
                                           JSObject **plugin_proto)
 {
   *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.
   JSAutoCompartment ac(cx, obj);
 
   if (plugin_inst) {
     plugin_inst->GetJSObject(cx, plugin_obj);
     if (*plugin_obj) {
@@ -3099,17 +3096,16 @@ nsObjectLoadingContent::TeardownProtoCha
 
   // Use the safe JSContext here as we're not always able to find the
   // JSContext associated with the NPP any more.
   AutoSafeJSContext cx;
   JS::Rooted<JSObject*> obj(cx, thisContent->GetWrapper());
   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
   // all JS objects of the class sNPObjectJSWrapperClass
   bool removed = false;
   while (obj) {
     if (!::JS_GetPrototype(cx, obj, proto.address())) {
       return;
--- a/content/base/src/nsScriptLoader.cpp
+++ b/content/base/src/nsScriptLoader.cpp
@@ -852,17 +852,16 @@ nsScriptLoader::EvaluateScript(nsScriptL
     JS::Rooted<JSObject*> global(cx, globalObject->GetGlobalJSObject());
     rv = context->EvaluateString(aScript, global,
                                  options, /* aCoerceToString = */ false, nullptr);
   }
 
   // Put the old script back in case it wants to do anything else.
   mCurrentScript = oldCurrent;
 
-  JSAutoRequest ar(cx);
   context->SetProcessingScriptTag(oldProcessingScriptTag);
   return rv;
 }
 
 void
 nsScriptLoader::ProcessPendingRequestsAsync()
 {
   if (mParserBlockingRequest || !mPendingChildLoaders.IsEmpty()) {
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -344,17 +344,16 @@ nsDOMEvent::Initialize(nsISupports* aOwn
       }
     }
   }
 
   if (!mOwner) {
     mOwner = w;
   }
 
-  JSAutoRequest ar(aCx);
   JSString* jsstr = JS_ValueToString(aCx, aArgs[0]);
   if (!jsstr) {
     return NS_ERROR_DOM_SYNTAX_ERR;
   }
 
   JS::Anchor<JSString*> deleteProtector(jsstr);
 
   nsDependentJSString type;
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -848,17 +848,16 @@ nsEventListenerManager::CompileEventHand
     // the only thing with weird arg names and SVG doesn't map event
     // listeners to the window.
     nsContentUtils::GetEventArgNames(content ?
                                        content->GetNameSpaceID() :
                                        kNameSpaceID_None,
                                      aListenerStruct->mTypeAtom,
                                      &argCount, &argNames);
 
-    JSAutoRequest ar(cx);
     JSAutoCompartment ac(cx, context->GetNativeGlobal());
     JS::CompileOptions options(cx);
     options.setFileAndLine(url.get(), lineNo)
            .setVersion(SCRIPTVERSION_DEFAULT);
 
     JS::Rooted<JSObject*> handlerFun(cx);
     result = nsJSUtils::CompileFunction(cx, JS::NullPtr(), options,
                                         nsAtomCString(aListenerStruct->mTypeAtom),
--- a/content/events/src/nsEventListenerService.cpp
+++ b/content/events/src/nsEventListenerService.cpp
@@ -107,28 +107,24 @@ nsEventListenerInfo::GetJSVal(JSContext*
 }
 
 NS_IMETHODIMP
 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);
       }
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsEventListenerInfo::GetDebugObject(nsISupports** aRetVal)
@@ -141,27 +137,23 @@ nsEventListenerInfo::GetDebugObject(nsIS
     do_GetService("@mozilla.org/js/jsd/debugger-service;1", &rv);
   NS_ENSURE_SUCCESS(rv, NS_OK);
 
   bool isOn = false;
   jsd->GetIsOn(&isOn);
   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
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsEventListenerService::GetListenerInfoFor(nsIDOMEventTarget* aEventTarget,
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -3292,17 +3292,16 @@ nsresult
 nsHTMLDocument::DoClipboardSecurityCheck(bool aPaste)
 {
   nsresult rv = NS_ERROR_FAILURE;
 
   JSContext *cx = nsContentUtils::GetCurrentJSContext();
   if (!cx) {
     return NS_OK;
   }
-  JSAutoRequest ar(cx);
 
   NS_NAMED_LITERAL_CSTRING(classNameStr, "Clipboard");
 
   nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager();
 
   if (aPaste) {
     if (nsHTMLDocument::sPasteInternal_id == JSID_VOID) {
       nsHTMLDocument::sPasteInternal_id =
--- a/content/media/webaudio/AudioProcessingEvent.cpp
+++ b/content/media/webaudio/AudioProcessingEvent.cpp
@@ -35,17 +35,16 @@ AudioProcessingEvent::WrapObject(JSConte
   return AudioProcessingEventBinding::Wrap(aCx, aScope, this);
 }
 
 void
 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());
   aBuffer->InitializeBuffers(aNumberOfChannels, cx);
 }
 
 }
 }
--- a/content/media/webaudio/ScriptProcessorNode.cpp
+++ b/content/media/webaudio/ScriptProcessorNode.cpp
@@ -308,17 +308,16 @@ private:
           node = static_cast<ScriptProcessorNode*>(mStream->Engine()->Node());
         }
         if (!node || !node->Context()) {
           return NS_OK;
         }
 
         AutoPushJSContext cx(node->Context()->GetJSContext());
         if (cx) {
-          JSAutoRequest ar(cx);
 
           // Create the input buffer
           nsRefPtr<AudioBuffer> inputBuffer;
           if (!mNullInput) {
             inputBuffer = new AudioBuffer(node->Context(),
                                           node->BufferSize(),
                                           node->Context()->SampleRate());
             if (!inputBuffer->InitializeBuffers(mInputChannels.Length(), cx)) {
--- a/content/media/webspeech/synth/nsSpeechTask.cpp
+++ b/content/media/webspeech/synth/nsSpeechTask.cpp
@@ -154,17 +154,16 @@ nsSpeechTask::SendAudio(const JS::Value&
   NS_ENSURE_FALSE(mStream->IsDestroyed(), NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mChannels, NS_ERROR_FAILURE);
 
   if (mIndirectAudio) {
     NS_WARNING("Can't call SendAudio from an indirect audio speech service.");
     return NS_ERROR_FAILURE;
   }
 
-  JSAutoRequest ar(aCx);
   JS::Rooted<JSObject*> darray(aCx, &aData.toObject());
   JSAutoCompartment ac(aCx, darray);
 
   JS::Rooted<JSObject*> tsrc(aCx, NULL);
 
   // Allow either Int16Array or plain JS Array
   if (JS_IsInt16Array(darray)) {
     tsrc = darray;
--- a/content/xbl/src/nsXBLBinding.cpp
+++ b/content/xbl/src/nsXBLBinding.cpp
@@ -949,17 +949,16 @@ nsXBLBinding::ChangeDocument(nsIDocument
           if (scope && scriptObject) {
             // XXX Stay in sync! What if a layered binding has an
             // <interface>?!
             // XXXbz what does that comment mean, really?  It seems to date
             // back to when there was such a thing as an <interface>, whever
             // that was...
 
             // Find the right prototype.
-            JSAutoRequest ar(cx);
             JSAutoCompartment ac(cx, scriptObject);
 
             JS::Rooted<JSObject*> base(cx, scriptObject);
             JS::Rooted<JSObject*> proto(cx);
             for ( ; true; base = proto) { // Will break out on null proto
               if (!JS_GetPrototype(cx, base, proto.address())) {
                 return;
               }
@@ -1084,17 +1083,16 @@ nsXBLBinding::DoInitJSClass(JSContext *c
                             nsXBLPrototypeBinding* aProtoBinding,
                             JS::MutableHandle<JSObject*> aClassObject,
                             bool* aNew)
 {
   // First ensure our JS class is initialized.
   nsAutoCString className(aClassName);
   nsAutoCString xblKey(aClassName);
 
-  JSAutoRequest ar(cx);
   JSAutoCompartment ac(cx, global);
 
   JS::Rooted<JSObject*> parent_proto(cx, nullptr);
   nsXBLJSClass* c = nullptr;
   if (obj) {
     // Retrieve the current prototype of obj.
     if (!JS_GetPrototype(cx, obj, parent_proto.address())) {
       return NS_ERROR_FAILURE;
--- a/content/xbl/src/nsXBLDocumentInfo.cpp
+++ b/content/xbl/src/nsXBLDocumentInfo.cpp
@@ -273,17 +273,16 @@ nsXBLDocGlobalObject::EnsureScriptEnviro
   // nsGlobalWindow.
   DebugOnly<nsresult> rv = newCtx->InitContext();
   NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Script Language's InitContext failed");
   newCtx->DidInitializeContext();
 
   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 
   // why - see bug 339647)
   JS_SetErrorReporter(cx, XBL_ProtoErrorReporter);
 
   mJSObject = JS_NewGlobalObject(cx, &gSharedGlobalClass,
                                  nsJSPrincipals::get(GetPrincipal()),
--- a/content/xbl/src/nsXBLProtoImpl.cpp
+++ b/content/xbl/src/nsXBLProtoImpl.cpp
@@ -83,17 +83,16 @@ nsXBLProtoImpl::InstallImplementation(ns
   // If the prototype already existed, we don't need to install anything. return early.
   if (!targetObjectIsNew)
     return NS_OK;
 
   JS::Rooted<JSObject*> targetScriptObject(context->GetNativeContext(),
                                            holder->GetJSObject());
 
   AutoPushJSContext cx(context->GetNativeContext());
-  JSAutoRequest ar(cx);
   JSAutoCompartment ac(cx, targetClassObject);
   AutoVersionChecker avc(cx);
 
   // Walk our member list and install each one in turn.
   for (nsXBLProtoImplMember* curr = mMembers;
        curr;
        curr = curr->GetNext())
     curr->InstallMember(cx, targetClassObject);
--- a/content/xbl/src/nsXBLProtoImplField.cpp
+++ b/content/xbl/src/nsXBLProtoImplField.cpp
@@ -406,18 +406,16 @@ nsXBLProtoImplField::InstallField(nsIScr
 
   AutoPushJSContext cx(aContext->GetNativeContext());
   NS_ASSERTION(!::JS_IsExceptionPending(cx),
                "Shouldn't get here when an exception is pending!");
 
   // 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));
   NS_ENSURE_TRUE(scopeObject, NS_ERROR_OUT_OF_MEMORY);
   JSAutoCompartment ac(cx, scopeObject);
 
   JS::Rooted<JSObject*> wrappedNode(cx, aBoundNode);
   if (!JS_WrapObject(cx, wrappedNode.address()))
--- a/content/xbl/src/nsXBLProtoImplMethod.cpp
+++ b/content/xbl/src/nsXBLProtoImplMethod.cpp
@@ -194,17 +194,16 @@ nsXBLProtoImplMethod::CompileMember(nsIS
   NS_ConvertUTF16toUTF8 cname(mName);
   nsAutoCString functionUri(aClassStr);
   int32_t hash = functionUri.RFindChar('#');
   if (hash != kNotFound) {
     functionUri.Truncate(hash);
   }
 
   AutoPushJSContext cx(aContext->GetNativeContext());
-  JSAutoRequest ar(cx);
   JSAutoCompartment ac(cx, aClassObject);
   JS::CompileOptions options(cx);
   options.setFileAndLine(functionUri.get(),
                          uncompiledMethod->mBodyText.GetLineNumber())
          .setVersion(JSVERSION_LATEST);
   JS::RootedObject rootedNull(cx, nullptr); // See bug 781070.
   JS::RootedObject methodObject(cx);
   nsresult rv = nsJSUtils::CompileFunction(cx, rootedNull, options, cname,
@@ -316,17 +315,16 @@ nsXBLProtoImplAnonymousMethod::Execute(n
   if (!pusher.Push(aBoundElement))
     return NS_ERROR_UNEXPECTED;
   MOZ_ASSERT(cx == nsContentUtils::GetCurrentJSContext());
 
   JS::Rooted<JSObject*> thisObject(cx, &v.toObject());
   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;
 
   // Clone the function object, using thisObject as the parent so "this" is in
   // the scope chain of the resulting function (for backwards compat to the
   // days when this was an event handler).
   JS::Rooted<JSObject*> method(cx, ::JS_CloneFunctionObject(cx, mJSMethodObject, thisObject));
--- a/content/xbl/src/nsXBLProtoImplProperty.cpp
+++ b/content/xbl/src/nsXBLProtoImplProperty.cpp
@@ -208,17 +208,16 @@ nsXBLProtoImplProperty::CompileMember(ns
     }
   }
 
   bool deletedGetter = false;
   if (mGetterText && mGetterText->GetText()) {
     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())
              .setVersion(JSVERSION_LATEST);
       nsCString name = NS_LITERAL_CSTRING("get_") + NS_ConvertUTF16toUTF8(mName);
       JS::RootedObject rootedNull(cx, nullptr); // See bug 781070.
       JS::RootedObject getterObject(cx);
       rv = nsJSUtils::CompileFunction(cx, rootedNull, options, name, 0, nullptr,
@@ -256,17 +255,16 @@ nsXBLProtoImplProperty::CompileMember(ns
     return rv;
   }
 
   bool deletedSetter = false;
   if (mSetterText && mSetterText->GetText()) {
     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())
              .setVersion(JSVERSION_LATEST);
       nsCString name = NS_LITERAL_CSTRING("set_") + NS_ConvertUTF16toUTF8(mName);
       JS::RootedObject rootedNull(cx, nullptr); // See bug 781070.
       JS::RootedObject setterObject(cx);
       rv = nsJSUtils::CompileFunction(cx, rootedNull, options, name, 1,
--- a/content/xbl/src/nsXBLPrototypeHandler.cpp
+++ b/content/xbl/src/nsXBLPrototypeHandler.cpp
@@ -285,17 +285,16 @@ nsXBLPrototypeHandler::ExecuteHandler(Ev
   NS_ENSURE_STATE(pusher.Push(aTarget));
 
   AutoPushJSContext cx(boundContext->GetNativeContext());
   JS::Rooted<JSObject*> handler(cx);
 
   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);
 
   // Bind it to the bound element. Note that if we're using a separate XBL scope,
   // we'll actually be binding the event handler to a cross-compartment wrapper
   // to the bound element's reflector.
 
@@ -376,17 +375,16 @@ nsXBLPrototypeHandler::EnsureEventHandle
   mPrototypeBinding->DocURI()->GetSpec(bindingURI);
 
   uint32_t argCount;
   const char **argNames;
   nsContentUtils::GetEventArgNames(kNameSpaceID_XBL, aName, &argCount,
                                    &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)
          .setVersion(JSVERSION_LATEST);
 
   JS::Rooted<JSObject*> rootedNull(cx); // See bug 781070.
   JS::Rooted<JSObject*> handlerFun(cx);
   nsresult rv = nsJSUtils::CompileFunction(cx, rootedNull, options,
--- a/content/xul/document/src/nsXULPrototypeDocument.cpp
+++ b/content/xul/document/src/nsXULPrototypeDocument.cpp
@@ -757,18 +757,16 @@ nsXULPDGlobalObject::EnsureScriptEnviron
   nsCOMPtr<nsIScriptContext> ctxNew = languageRuntime->CreateContext(false, nullptr);
   MOZ_ASSERT(ctxNew);
 
   // We have to setup a special global object.  We do this then
   // attach it as the global for this context.  Then, we
   // 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));
     if (!newGlob)
         return NS_OK;
 
     ::JS_SetGlobalObject(cx, newGlob);
 
--- a/content/xul/templates/src/nsXULTemplateBuilder.cpp
+++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp
@@ -1380,19 +1380,16 @@ nsXULTemplateBuilder::InitHTMLTemplateRo
         return NS_ERROR_UNEXPECTED;
 
     AutoPushJSContext jscontext(context->GetNativeContext());
     NS_ASSERTION(context != nullptr, "no jscontext");
     if (! jscontext)
         return NS_ERROR_UNEXPECTED;
 
     JS::Rooted<JSObject*> scope(jscontext, global->GetGlobalJSObject());
-
-    JSAutoRequest ar(jscontext);
-
     JS::Rooted<JS::Value> v(jscontext);
     nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
     rv = nsContentUtils::WrapNative(jscontext, scope, mRoot, mRoot, v.address(),
                                     getter_AddRefs(wrapper));
     NS_ENSURE_SUCCESS(rv, rv);
 
     JS::Rooted<JSObject*> jselement(jscontext, JSVAL_TO_OBJECT(v));
 
--- a/dom/base/DOMRequest.cpp
+++ b/dom/base/DOMRequest.cpp
@@ -259,17 +259,16 @@ public:
     nsIScriptContext* sc = mReq->GetContextForEventHandlers(&rv);
     if (!NS_SUCCEEDED(rv)) {
       return rv;
     }
     AutoPushJSContext cx(sc->GetNativeContext());
     if (!cx) {
       return NS_ERROR_FAILURE;
     }
-    JSAutoRequest ar(cx);
     JS_AddValueRoot(cx, &mResult);
     mIsSetup = true;
     return NS_OK;
   }
 
   // Due to the fact that initialization can fail during shutdown (since we
   // can't fetch a js context), set up an initiatization function to make sure
   // we can return the failure appropriately
@@ -303,19 +302,16 @@ public:
       return;
     }
     nsresult rv;
     nsIScriptContext* sc = mReq->GetContextForEventHandlers(&rv);
     MOZ_ASSERT(NS_SUCCEEDED(rv));
     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:
   nsRefPtr<DOMRequest> mReq;
   JS::Value mResult;
   bool mIsSetup;
 };
 
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -1139,18 +1139,16 @@ nsresult
 nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
 {
 #define SET_JSID_TO_STRING(_id, _cx, _str)                                    \
   if (JSString *str = ::JS_InternString(_cx, _str))                           \
       _id = INTERNED_STRING_TO_JSID(_cx, str);                                \
   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");
   SET_JSID_TO_STRING(sConstructor_id,     cx, "constructor");
   SET_JSID_TO_STRING(s_content_id,        cx, "_content");
   SET_JSID_TO_STRING(sContent_id,         cx, "content");
   SET_JSID_TO_STRING(sMenubar_id,         cx, "menubar");
   SET_JSID_TO_STRING(sToolbar_id,         cx, "toolbar");
@@ -2105,18 +2103,16 @@ nsDOMClassInfo::GetArrayIndexFromId(JSCo
   if (aIsNumber) {
     *aIsNumber = false;
   }
 
   int i;
   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) ||
           !::JS_ValueToNumber(cx, idval, &array_index) ||
           !::JS_DoubleIsInt32(array_index, &i)) {
         return -1;
       }
   }
@@ -2347,17 +2343,16 @@ nsDOMClassInfo::NewEnumerate(nsIXPConnec
 nsresult
 nsDOMClassInfo::ResolveConstructor(JSContext *cx, JSObject *aObj,
                                    JSObject **objp)
 {
   JS::Rooted<JSObject*> obj(cx, 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;
   }
 
   if (!JSVAL_IS_PRIMITIVE(val)) {
     // If val is not an (non-null) object there either is no
     // constructor for this class, or someone messed with
     // window.classname, just fall through and let the JS engine
@@ -2948,18 +2943,16 @@ nsWindowSH::GlobalScopePolluterNewResolv
 // static
 JSBool
 nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx,
                                           JS::Handle<JSObject*> aObj)
 {
   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;
     }
     if (!proto) {
       break;
     }
 
@@ -2982,18 +2975,16 @@ nsWindowSH::InvalidateGlobalScopePollute
 
   return JS_TRUE;
 }
 
 // static
 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;
   }
 
   JS::Rooted<JSObject*> o(cx, obj), proto(cx);
 
   // Find the place in the prototype chain where we want this global
@@ -3139,17 +3130,16 @@ BaseStubConstructor(nsIWeakReference* aW
       JS::Rooted<JSObject*> thisObject(cx, wrappedJS->GetJSObject());
       if (!thisObject) {
         return NS_ERROR_UNEXPECTED;
       }
 
       nsCxPusher pusher;
       pusher.Push(cx);
 
-      JSAutoRequest ar(cx);
       JSAutoCompartment ac(cx, thisObject);
 
       JS::Rooted<JS::Value> funval(cx);
       if (!JS_GetProperty(cx, thisObject, "constructor", funval.address()) ||
           !funval.isObject()) {
         return NS_ERROR_UNEXPECTED;
       }
 
@@ -4583,17 +4573,16 @@ nsWindowSH::NewResolve(nsIXPConnectWrapp
     {
       // Resolve standard classes on my_context's JSContext (or on cx,
       // if we don't have a my_context yet), in case the two contexts
       // have different origins.  We want lazy standard class
       // initialization to behave as if it were done eagerly, on each
       // 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);
 
       if (!ok) {
         // Trust the JS engine (or the script security manager) to set
         // the exception in the JS engine.
 
@@ -4746,17 +4735,16 @@ nsWindowSH::NewResolve(nsIXPConnectWrapp
   }
 
   if (flags & JSRESOLVE_ASSIGNING) {
     if (IsReadonlyReplaceable(id)) {
       // A readonly "replaceable" property is being set.  Define the property
       // 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)) {
         return NS_ERROR_FAILURE;
       }
       *objp = obj;
 
       return NS_OK;
@@ -5581,17 +5569,16 @@ nsGenericArraySH::Enumerate(nsIXPConnect
   if (sCurrentlyEnumerating) {
     // Don't recurse to death.
     return NS_OK;
   }
 
   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)) {
     int32_t length = JSVAL_TO_INT(len_val);
 
     for (int32_t i = 0; ok && i < length; ++i) {
       ok = ::JS_DefineElement(cx, obj, i, JSVAL_VOID, nullptr, nullptr,
                               JSPROP_ENUMERATE | JSPROP_SHARED);
@@ -6302,17 +6289,16 @@ nsHTMLFormElementSH::NewResolve(nsIXPCon
     nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
 
     nsDependentJSString name(id);
     nsWrapperCache* cache;
     nsCOMPtr<nsISupports> result =
       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);
 
       *objp = obj;
 
       return *_retval ? NS_OK : NS_ERROR_FAILURE;
     }
   }
@@ -6407,18 +6393,16 @@ nsHTMLFormElementSH::NewEnumerate(nsIXPC
 
         nsAutoString attr;
         domElement->GetAttribute(NS_LITERAL_STRING("name"), attr);
         if (attr.IsEmpty()) {
           // If name is not there, use index instead
           attr.AppendInt(index);
         }
 
-        JSAutoRequest ar(cx);
-
         JSString *jsname =
           JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
                                                   (attr.get()),
                               attr.Length());
         NS_ENSURE_TRUE(jsname, NS_ERROR_OUT_OF_MEMORY);
 
         JS_ValueToId(cx, STRING_TO_JSVAL(jsname), idp);
 
@@ -6518,18 +6502,16 @@ nsStringArraySH::GetProperty(nsIXPConnec
     return NS_OK;
   }
 
   nsAutoString val;
 
   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;
   }
 
   NS_ENSURE_TRUE(xpc::NonVoidStringToJsval(cx, val, vp),
                  NS_ERROR_OUT_OF_MEMORY);
   return NS_SUCCESS_I_DID_SOMETHING;
@@ -6738,18 +6720,16 @@ nsStorage2SH::GetProperty(nsIXPConnectWr
   if (ObjectIsNativeWrapper(cx, obj)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   nsAutoString val;
   nsresult rv = storage->GetItem(keyStr, val);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  JSAutoRequest ar(cx);
-
   if (DOMStringIsNull(val)) {
     // No such key.
     *vp = JSVAL_VOID;
   } else {
     JSString* str =
       JS_NewUCStringCopyN(cx, static_cast<const jschar *>(val.get()),
                           val.Length());
     NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -1454,17 +1454,16 @@ nsGlobalWindow::FreeInnerObjects()
   // other members that the window destroyed observers could
   // re-create.
   NotifyDOMWindowDestroyed(this);
 
   // Kill all of the workers for this window.
   // 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.
   quota::QuotaManager* quotaManager = quota::QuotaManager::Get();
   if (quotaManager) {
     quotaManager->AbortCloseStoragesForWindow(this);
   }
 
@@ -2251,18 +2250,16 @@ nsGlobalWindow::SetNewDocument(nsIDocume
   nsRefPtr<nsGlobalWindow> newInnerWindow;
   bool createdInnerWindow = false;
 
   bool thisChrome = IsChromeWindow();
 
   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?");
 
   if (reUseInnerWindow) {
     // We're reusing the current inner window.
     NS_ASSERTION(!currentInner->IsFrozen(),
                  "We should never be reusing a shared inner window");
     newInnerWindow = currentInner;
@@ -6727,17 +6724,16 @@ PostMessageEvent::Run()
       ssm->CheckSameOriginURI(mProvidedOrigin, targetURI, true);
     if (NS_FAILED(rv))
       return NS_OK;
   }
 
   // Deserialize the structured clone data
   JS::Rooted<JS::Value> messageData(cx);
   {
-    JSAutoRequest ar(cx);
     StructuredCloneInfo scInfo;
     scInfo.event = this;
 
     if (!buffer.read(cx, messageData.address(), &kPostMessageCallbacks,
                      &scInfo)) {
       return NS_ERROR_DOM_DATA_CLONE_ERR;
     }
   }
@@ -7375,17 +7371,16 @@ public:
         window->IsInnerWindow() ? static_cast<nsGlobalWindow*>(window.get()) :
                                   static_cast<nsGlobalWindow*>(window->GetCurrentInnerWindow());
       NS_ENSURE_TRUE(currentInner, NS_OK);
 
       AutoSafeJSContext cx;
       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)),
                                          window->IsInnerWindow() ? js::DontNukeWindowReferences :
                                                                    js::NukeWindowReferences);
       }
     }
 
@@ -10924,17 +10919,16 @@ nsGlobalWindow::SuspendTimeouts(uint32_t
         ac->RemoveWindowListener(mEnabledSensors[i], this);
     }
     DisableGamepadUpdates();
 
     // Suspend all of the workers for this window.
   // 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();
     for (nsTimeout *t = mTimeouts.getFirst(); t; t = t->getNext()) {
       // Set mTimeRemaining to be the time remaining for this timer.
       if (t->mWhen > now)
         t->mTimeRemaining = t->mWhen - now;
       else
@@ -11017,17 +11011,16 @@ nsGlobalWindow::ResumeTimeouts(bool aTha
     for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) {
       mAudioContexts[i]->Resume();
     }
 
     // Resume all of the workers for this window.
     // 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
     // (stored in timeout->mTimeRemaining).
 
     TimeStamp now = TimeStamp::Now();
 
 #ifdef DEBUG
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1262,17 +1262,16 @@ nsJSContext::EvaluateString(const nsAStr
 
   bool ok = false;
   nsresult rv = sSecurityManager->CanExecuteScripts(mContext, nsJSPrincipals::get(p), &ok);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(ok, NS_OK);
 
   // 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);
 
     ++mExecuteDepth;
 
     JS::RootedObject rootedScope(mContext, aScopeObject);
     ok = JS::Evaluate(mContext, rootedScope, aOptions,
                       PromiseFlatString(aScript).get(),
@@ -1334,17 +1333,16 @@ nsJSContext::CompileScript(const PRUnich
   aScriptObject.set(nullptr); // ensure old object not used on failure...
 
   // Don't compile if SecurityManager said "not ok" or aVersion is unknown.
   // Since the caller is responsible for parsing the version strings, we just
   // check it isn't JSVERSION_UNKNOWN.
   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 :
     JS::CompileOptions::LAZY_SOURCE;
   options.setPrincipals(nsJSPrincipals::get(aPrincipal))
          .setFileAndLine(aURL, aLineNo)
          .setVersion(JSVersion(aVersion))
          .setSourcePolicy(sp);
@@ -1382,18 +1380,16 @@ nsJSContext::ExecuteScript(JSScript* aSc
   xpc_UnmarkGrayScript(aScriptObject);
   xpc_UnmarkGrayObject(aScopeObject);
 
   // Push our JSContext on our thread's context stack, in case native code
   // called from JS calls back into JS via XPConnect.
   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.
   {
     JSAutoCompartment ac(mContext, aScopeObject);
     ++mExecuteDepth;
 
     // The result of evaluation, used only if there were no errors. This need
     // not be a GC root currently, provided we run the GC only from the
@@ -1480,18 +1476,16 @@ nsJSContext::BindCompiledEventHandler(ns
   NS_ENSURE_ARG(aHandler);
   NS_ENSURE_TRUE(mIsInitialized, NS_ERROR_NOT_INITIALIZED);
   NS_PRECONDITION(!aBoundHandler, "Shouldn't already have a bound handler!");
 
   xpc_UnmarkGrayObject(aScope);
   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);
   nsresult rv = JSObjectFromInterface(aTarget, scope, target.address());
   NS_ENSURE_SUCCESS(rv, rv);
 
 #ifdef DEBUG
   {
@@ -1641,17 +1635,16 @@ nsJSContext::InitializeExternalClasses()
 nsresult
 nsJSContext::SetProperty(JS::Handle<JSObject*> aTarget, const char* aPropName, nsISupports* aArgs)
 {
   uint32_t  argc;
   JS::Value *argv = nullptr;
 
   nsCxPusher pusher;
   pusher.Push(mContext);
-  XPCAutoRequest ar(mContext);
 
   Maybe<nsRootedJSValueArray> tempStorage;
 
   JS::Rooted<JSObject*> global(mContext, GetNativeGlobal());
   nsresult rv =
     ConvertSupportsTojsvals(aArgs, global, &argc, &argv, tempStorage);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -2289,18 +2282,16 @@ static const JSFunctionSpec JProfFunctio
 #endif /* defined(MOZ_JPROF) */
 
 nsresult
 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);
 
   // Attempt to initialize profiling functions
   ::JS_DefineProfilingFunctions(cx, aGlobalObj);
 
 #ifdef NS_TRACE_MALLOC
   // Attempt to initialize TraceMalloc functions
--- a/dom/base/nsJSTimeoutHandler.cpp
+++ b/dom/base/nsJSTimeoutHandler.cpp
@@ -183,18 +183,16 @@ nsJSScriptTimeoutHandler::Init(nsGlobalW
   JS::Value *argv = nullptr;
 
   ncc->GetArgc(&argc);
   ncc->GetArgvPtr(&argv);
 
   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);
     return NS_ERROR_DOM_TYPE_ERR;
   }
 
   int32_t interval = 0;
   if (argc > 1 && !::JS_ValueToECMAInt32(cx, argv[1], &interval)) {
--- a/dom/base/nsStructuredCloneContainer.cpp
+++ b/dom/base/nsStructuredCloneContainer.cpp
@@ -46,17 +46,16 @@ nsStructuredCloneContainer::InitFromVari
   // First, try to extract a JS::Value from the variant |aData|.  This works only
   // if the variant implements GetAsJSVal.
   JS::Rooted<JS::Value> jsData(aCx);
   nsresult rv = aData->GetAsJSVal(jsData.address());
   NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
 
   // 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;
   bool success = JS_WriteStructuredClone(aCx, jsData, &jsBytes, &mSize,
                                            nullptr, nullptr, JSVAL_VOID);
   NS_ENSURE_STATE(success);
   NS_ENSURE_STATE(jsBytes);
 
--- a/dom/bindings/CallbackObject.cpp
+++ b/dom/bindings/CallbackObject.cpp
@@ -85,20 +85,17 @@ CallbackObject::CallSetup::CallSetup(JS:
   }
 
   if (!cx) {
     // We didn't manage to hunt down a script global to work with.  Just fall
     // back on using the safe context.
     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);
 
   // Make sure our JSContext is pushed on the stack.
   mCxPusher.Push(cx);
 
   // After this point we guarantee calling ScriptEvaluated() if we
--- a/dom/bindings/CallbackObject.h
+++ b/dom/bindings/CallbackObject.h
@@ -140,20 +140,16 @@ protected:
     nsCOMPtr<nsIScriptContext> mCtx;
 
     // And now members whose construction/destruction order we need to control.
 
     // Put our nsAutoMicrotask first, so it gets destroyed after everything else
     // 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.
     Maybe<JS::Rooted<JSObject*> > mRootedCallable;
 
     nsCxPusher mCxPusher;
 
     // Can't construct a JSAutoCompartment without a JSContext either.  Also,
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -7621,17 +7621,16 @@ class CGDictionary(CGThing):
         ], body=body)
 
     def initFromJSONMethod(self):
         assert not self.workers
         return ClassMethod("Init", "bool", [
                 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"
                 "return Init(cx, json);"
             ))
 
     def toObjectMethod(self):
         body = ""
--- a/dom/bindings/DOMJSProxyHandler.cpp
+++ b/dom/bindings/DOMJSProxyHandler.cpp
@@ -24,18 +24,16 @@ using namespace JS;
 namespace mozilla {
 namespace dom {
 
 jsid s_length_id = JSID_VOID;
 
 bool
 DefineStaticJSVals(JSContext* cx)
 {
-  JSAutoRequest ar(cx);
-
   return InternJSString(cx, s_length_id, "length");
 }
 
 
 int HandlerFamily;
 
 js::ListBaseShadowsResult
 DOMListShadows(JSContext* cx, JSHandleObject proxy, JSHandleId id)
@@ -290,18 +288,16 @@ DOMProxyHandler::AppendNamedPropertyIds(
   }
 
   return true;
 }
 
 int32_t
 IdToInt32(JSContext* cx, JS::Handle<jsid> id)
 {
-  JSAutoRequest ar(cx);
-
   JS::Value idval;
   double array_index;
   int32_t i;
   if (!::JS_IdToValue(cx, id, &idval) ||
       !::JS_ValueToNumber(cx, idval, &array_index) ||
       !::JS_DoubleIsInt32(array_index, &i)) {
     return -1;
   }
--- a/dom/bluetooth/BluetoothService.cpp
+++ b/dom/bluetooth/BluetoothService.cpp
@@ -753,17 +753,16 @@ void
 BluetoothService::Notify(const BluetoothSignal& aData)
 {
   nsString type = NS_LITERAL_STRING("bluetooth-pairing-request");
 
   AutoSafeJSContext cx;
   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!");
     return;
   }
 
   if (!SetJsObject(cx, aData.value(), obj)) {
     NS_WARNING("Failed to set properties of system message!");
--- a/dom/bluetooth/BluetoothUtils.cpp
+++ b/dom/bluetooth/BluetoothUtils.cpp
@@ -104,17 +104,16 @@ GetAddressFromObjectPath(const nsAString
 bool
 BroadcastSystemMessage(const nsAString& aType,
                        const InfallibleTArray<BluetoothNamedValue>& aData)
 {
   mozilla::AutoSafeJSContext cx;
   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!");
     return false;
   }
 
   if (!SetJsObject(cx, aData, obj)) {
     NS_WARNING("Failed to set properties of system message!");
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -1421,18 +1421,16 @@ JS::Value StringToJsval(nsPIDOMWindow* a
     return JSVAL_NULL;
   }
 
   AutoPushJSContext cx(scriptContext->GetNativeContext());
   if (!cx) {
     return JSVAL_NULL;
   }
 
-  JSAutoRequest ar(cx);
-
   JS::Value result = JSVAL_NULL;
   if (!xpc::StringToJsval(cx, aString, &result)) {
     return JSVAL_NULL;
   }
 
   return result;
 }
 
--- a/dom/file/ArchiveRequest.cpp
+++ b/dom/file/ArchiveRequest.cpp
@@ -137,17 +137,16 @@ ArchiveRequest::ReaderReady(nsTArray<nsC
   NS_ENSURE_STATE(sc);
 
   AutoPushJSContext cx(sc->GetNativeContext());
   NS_ASSERTION(cx, "Failed to get a context!");
 
   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);
   switch (mOperation) {
     case GetFilenames:
       rv = GetFilenamesResult(cx, result.address(), aFileList);
       break;
 
--- a/dom/file/FileRequest.cpp
+++ b/dom/file/FileRequest.cpp
@@ -78,17 +78,16 @@ FileRequest::NotifyHelperCompleted(FileH
   AutoPushJSContext cx(sc->GetNativeContext());
   NS_ASSERTION(cx, "Failed to get a context!");
 
   JS::Rooted<JS::Value> result(cx);
 
   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());
   if (NS_FAILED(rv)) {
     NS_WARNING("GetSuccessResult failed!");
   }
 
   if (NS_SUCCEEDED(rv)) {
--- a/dom/indexedDB/AsyncConnectionHelper.cpp
+++ b/dom/indexedDB/AsyncConnectionHelper.cpp
@@ -612,18 +612,16 @@ nsresult
 AsyncConnectionHelper::ConvertToArrayAndCleanup(
                                   JSContext* aCx,
                                   nsTArray<StructuredCloneReadInfo>& aReadInfos,
                                   jsval* aResult)
 {
   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++) {
     aReadInfos[index].mCloneBuffer.clear();
   }
   aReadInfos.Clear();
 
   return rv;
--- a/dom/indexedDB/IDBCursor.cpp
+++ b/dom/indexedDB/IDBCursor.cpp
@@ -539,18 +539,16 @@ IDBCursor::GetKey(JSContext* aCx,
   }
 
   if (!mHaveCachedKey) {
     if (!mRooted) {
       NS_HOLD_JS_OBJECTS(this, IDBCursor);
       mRooted = true;
     }
 
-    JSAutoRequest ar(aCx);
-
     nsresult rv = mKey.ToJSVal(aCx, &mCachedKey);
     NS_ENSURE_SUCCESS(rv, rv);
 
     mHaveCachedKey = true;
   }
 
   *aKey = mCachedKey;
   return NS_OK;
--- a/dom/indexedDB/IDBFactory.cpp
+++ b/dom/indexedDB/IDBFactory.cpp
@@ -205,17 +205,16 @@ IDBFactory::Create(ContentParent* aConte
 
   NS_ASSERTION(!nsContentUtils::GetCurrentJSContext(), "Should be called from C++");
 
   nsCOMPtr<nsIPrincipal> principal =
     do_CreateInstance("@mozilla.org/nullprincipal;1");
   NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
 
   AutoSafeJSContext cx;
-  JSAutoRequest ar(cx);
 
   nsIXPConnect* xpc = nsContentUtils::XPConnect();
   NS_ASSERTION(xpc, "This should never be null!");
 
   nsCOMPtr<nsIXPConnectJSObjectHolder> globalHolder;
   nsresult rv = xpc->CreateSandbox(cx, principal, getter_AddRefs(globalHolder));
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/dom/indexedDB/IDBIndex.cpp
+++ b/dom/indexedDB/IDBIndex.cpp
@@ -1486,18 +1486,16 @@ nsresult
 GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
                                    jsval* aVal)
 {
   NS_ASSERTION(mKeys.Length() <= mLimit, "Too many results!");
 
   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!");
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   if (!keys.IsEmpty()) {
     if (!JS_SetArrayLength(aCx, array, uint32_t(keys.Length()))) {
--- a/dom/indexedDB/IDBRequest.cpp
+++ b/dom/indexedDB/IDBRequest.cpp
@@ -112,17 +112,16 @@ IDBRequest::NotifyHelperCompleted(Helper
     rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
     SetError(rv);
     return rv;
   }
 
   JS::Rooted<JSObject*> global(cx, GetParentObject());
   NS_ASSERTION(global, "This should never be null!");
 
-  JSAutoRequest ar(cx);
   JSAutoCompartment ac(cx, global);
   AssertIsRooted();
 
   rv = aHelper->GetSuccessResult(cx, &mResultVal);
   if (NS_FAILED(rv)) {
     NS_WARNING("GetSuccessResult failed!");
   }
 
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1414,17 +1414,16 @@ TabChild::RecvUpdateDimensions(const nsR
     return true;
 }
 
 void
 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;
     if (JS_ParseJSON(cx,
                       static_cast<const jschar*>(NS_ConvertUTF8toUTF16(aJSONData).get()),
                       aJSONData.Length(),
                       json.address())) {
         WriteStructuredClone(cx, json, buffer, cloneData.mClosure);
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1093,17 +1093,16 @@ TabParent::ReceiveMessage(const nsString
                           const StructuredCloneData* aCloneData,
                           InfallibleTArray<nsString>* aJSONRetVal)
 {
   nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
   if (frameLoader && frameLoader->GetFrameMessageManager()) {
     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.
     JS::Rooted<JSObject*> objectsArray(ctx, JS_NewArrayObject(ctx, len, NULL));
     if (!objectsArray) {
       return false;
     }
 
--- a/dom/mobilemessage/src/MobileMessageCallback.cpp
+++ b/dom/mobilemessage/src/MobileMessageCallback.cpp
@@ -54,17 +54,16 @@ MobileMessageCallback::NotifySuccess(nsI
   NS_ENSURE_TRUE(scriptContext, NS_ERROR_FAILURE);
 
   AutoPushJSContext cx(scriptContext->GetNativeContext());
   NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
 
   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);
   rv = nsContentUtils::WrapNative(cx, global, aMessage,
                                   wrappedMessage.address());
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NotifySuccess(wrappedMessage);
--- a/dom/mobilemessage/src/MobileMessageCursorCallback.cpp
+++ b/dom/mobilemessage/src/MobileMessageCursorCallback.cpp
@@ -66,17 +66,16 @@ MobileMessageCursorCallback::NotifyCurso
   NS_ENSURE_TRUE(scriptContext, NS_ERROR_FAILURE);
 
   AutoPushJSContext cx(scriptContext->GetNativeContext());
   NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
 
   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);
   rv = nsContentUtils::WrapNative(cx, global, aResult, wrappedResult.address());
   NS_ENSURE_SUCCESS(rv, rv);
 
   mDOMCursor->FireSuccess(wrappedResult);
   return NS_OK;
--- a/dom/mobilemessage/src/MobileMessageManager.cpp
+++ b/dom/mobilemessage/src/MobileMessageManager.cpp
@@ -148,17 +148,16 @@ MobileMessageManager::Send(const JS::Val
   if (!aNumber.isString() &&
       !(aNumber.isObject() && JS_IsArrayObject(cx, &aNumber.toObject()))) {
     return NS_ERROR_INVALID_ARG;
   }
 
   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()) {
     JS::Rooted<JSString*> str(cx, aNumber.toString());
     return Send(cx, global, str, aMessage, aReturn);
   }
 
   // Must be an array then.
--- a/dom/mobilemessage/src/SmsManager.cpp
+++ b/dom/mobilemessage/src/SmsManager.cpp
@@ -182,17 +182,16 @@ SmsManager::Send(const JS::Value& aNumbe
   if (!aNumber.isString() &&
       !(aNumber.isObject() && JS_IsArrayObject(cx, &aNumber.toObject()))) {
     return NS_ERROR_INVALID_ARG;
   }
 
   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()) {
     JS::Rooted<JSString*> number(cx, aNumber.toString());
     return Send(cx, global, number, aMessage, aReturn);
   }
 
   // Must be an object then.
--- a/dom/mobilemessage/src/ipc/SmsParent.cpp
+++ b/dom/mobilemessage/src/ipc/SmsParent.cpp
@@ -28,18 +28,16 @@
 namespace mozilla {
 namespace dom {
 namespace mobilemessage {
 
 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);
 
   JSString* idStr = JS_NewUCStringCopyN(aContext,
                                         aAttachment.id().get(),
                                         aAttachment.id().Length());
   NS_ENSURE_TRUE(idStr, nullptr);
   if (!JS_DefineProperty(aContext, obj, "id", JS::StringValue(idStr),
@@ -73,18 +71,16 @@ MmsAttachmentDataToJSObject(JSContext* a
   return obj;
 }
 
 static bool
 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);
 
   // smil
   JSString* smilStr = JS_NewUCStringCopyN(aCx,
                                           aRequest.smil().get(),
                                           aRequest.smil().Length());
   NS_ENSURE_TRUE(smilStr, false);
--- a/dom/network/src/TCPSocketChild.cpp
+++ b/dom/network/src/TCPSocketChild.cpp
@@ -18,17 +18,16 @@ using mozilla::net::gNeckoChild;
 namespace IPC {
 
 bool
 DeserializeArrayBuffer(JS::Handle<JSObject*> aObj,
                        const InfallibleTArray<uint8_t>& aBuffer,
                        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()));
   if (!obj)
     return false;
   uint8_t* data = JS_GetArrayBufferData(obj);
   if (!data)
     return false;
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -564,17 +564,16 @@ nsJSObjWrapper::NP_HasMethod(NPObject *n
 
     return false;
   }
 
   nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
 
   nsCxPusher pusher;
   pusher.Push(cx);
-  JSAutoRequest ar(cx);
   JSAutoCompartment ac(cx, npjsobj->mJSObj);
 
   AutoJSExceptionReporter reporter(cx);
 
   JS::Rooted<JS::Value> v(cx);
   JSBool ok = GetProperty(cx, npjsobj->mJSObj, id, v.address());
 
   return ok && !JSVAL_IS_PRIMITIVE(v) &&
@@ -601,17 +600,16 @@ doInvoke(NPObject *npobj, NPIdentifier m
   // Initialize *result
   VOID_TO_NPVARIANT(*result);
 
   nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
   JS::Rooted<JS::Value> fv(cx);
 
   nsCxPusher pusher;
   pusher.Push(cx);
-  JSAutoRequest ar(cx);
   JSAutoCompartment ac(cx, npjsobj->mJSObj);
 
   AutoJSExceptionReporter reporter(cx);
 
   if (method != NPIdentifier_VOID) {
     if (!GetProperty(cx, npjsobj->mJSObj, method, fv.address()) ||
         ::JS_TypeOfValue(cx, fv) != JSTYPE_FUNCTION) {
       return false;
@@ -713,17 +711,16 @@ nsJSObjWrapper::NP_HasProperty(NPObject 
     return false;
   }
 
   nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
   JSBool found, ok = JS_FALSE;
 
   nsCxPusher pusher;
   pusher.Push(cx);
-  JSAutoRequest ar(cx);
   AutoJSExceptionReporter reporter(cx);
   JSAutoCompartment ac(cx, npjsobj->mJSObj);
 
   NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id),
                "id must be either string or int!\n");
   ok = ::JS_HasPropertyById(cx, npjsobj->mJSObj, NPIdentifierToJSId(id), &found);
   return ok && found;
 }
@@ -746,17 +743,16 @@ nsJSObjWrapper::NP_GetProperty(NPObject 
 
     return false;
   }
 
   nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
 
   nsCxPusher pusher;
   pusher.Push(cx);
-  JSAutoRequest ar(cx);
   AutoJSExceptionReporter reporter(cx);
   JSAutoCompartment ac(cx, npjsobj->mJSObj);
 
   JS::Rooted<JS::Value> v(cx);
   return (GetProperty(cx, npjsobj->mJSObj, id, v.address()) &&
           JSValToNPVariant(npp, cx, v, result));
 }
 
@@ -779,17 +775,16 @@ nsJSObjWrapper::NP_SetProperty(NPObject 
     return false;
   }
 
   nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
   JSBool ok = JS_FALSE;
 
   nsCxPusher pusher;
   pusher.Push(cx);
-  JSAutoRequest ar(cx);
   AutoJSExceptionReporter reporter(cx);
   JSAutoCompartment ac(cx, npjsobj->mJSObj);
 
   JS::Rooted<JS::Value> v(cx, NPVariantToJSVal(npp, cx, value));
 
   NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id),
                "id must be either string or int!\n");
   ok = ::JS_SetPropertyById(cx, npjsobj->mJSObj, NPIdentifierToJSId(id),
@@ -818,17 +813,16 @@ nsJSObjWrapper::NP_RemoveProperty(NPObje
     return false;
   }
 
   nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
   JSBool ok = JS_FALSE;
 
   nsCxPusher pusher;
   pusher.Push(cx);
-  JSAutoRequest ar(cx);
   AutoJSExceptionReporter reporter(cx);
   JS::Rooted<JS::Value> deleted(cx, JSVAL_FALSE);
   JSAutoCompartment ac(cx, npjsobj->mJSObj);
 
   NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id),
                "id must be either string or int!\n");
   ok = ::JS_DeletePropertyById2(cx, npjsobj->mJSObj, NPIdentifierToJSId(id), deleted.address());
   if (ok && deleted == JSVAL_TRUE) {
@@ -872,17 +866,16 @@ nsJSObjWrapper::NP_Enumerate(NPObject *n
 
     return false;
   }
 
   nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
 
   nsCxPusher pusher;
   pusher.Push(cx);
-  JSAutoRequest ar(cx);
   AutoJSExceptionReporter reporter(cx);
   JSAutoCompartment ac(cx, npjsobj->mJSObj);
 
   JS::AutoIdArray ida(cx, JS_Enumerate(cx, npjsobj->mJSObj));
   if (!ida) {
     return false;
   }
 
@@ -1056,18 +1049,16 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JS
   }
 
   wrapper->mJSObj = obj;
 
   entry->mJSObjWrapper = wrapper;
 
   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")) {
     NS_ERROR("Failed to root JSObject!");
 
     _releaseobject(wrapper);
 
     PL_DHashTableRawRemove(&sJSObjWrappers, entry);
@@ -1787,18 +1778,16 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JS
       return NULL;
     }
     return obj;
   }
 
   entry->mNPObj = npobj;
   entry->mNpp = npp;
 
-  JSAutoRequest ar(cx);
-
   uint32_t generation = sNPObjWrappers.generation;
 
   // No existing JSObject, create one.
 
   JS::Rooted<JSObject*> obj(cx, ::JS_NewObject(cx, &sNPObjectJSWrapperClass, nullptr, nullptr));
 
   if (generation != sNPObjWrappers.generation) {
       // Reload entry if the JS_NewObject call caused a GC and reallocated
@@ -1926,18 +1915,16 @@ nsJSNPRuntime::OnPluginDestroy(NPP npp)
   if (sJSObjWrappers.ops) {
     PL_DHashTableEnumerate(&sJSObjWrappers,
                            JSObjWrapperPluginDestroyedCallback, 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,
                            NPObjWrapperPluginDestroyedCallback, &nppcx);
   }
 }
 
 
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -1259,30 +1259,28 @@ NPIdentifier NP_CALLBACK
     NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS, ("NPN_getstringidentifier: passed null name"));
     return NULL;
   }
   if (!NS_IsMainThread()) {
     NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getstringidentifier called from the wrong thread\n"));
   }
 
   AutoSafeJSContext cx;
-  JSAutoRequest ar(cx);
   return doGetIdentifier(cx, name);
 }
 
 void NP_CALLBACK
 _getstringidentifiers(const NPUTF8** names, int32_t nameCount,
                       NPIdentifier *identifiers)
 {
   if (!NS_IsMainThread()) {
     NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getstringidentifiers called from the wrong thread\n"));
   }
 
   AutoSafeJSContext cx;
-  JSAutoRequest ar(cx);
 
   for (int32_t i = 0; i < nameCount; ++i) {
     if (names[i]) {
       identifiers[i] = doGetIdentifier(cx, names[i]);
     } else {
       NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS, ("NPN_getstringidentifiers: passed null name"));
       identifiers[i] = NULL;
     }
@@ -1488,18 +1486,16 @@ bool NP_CALLBACK
   NS_ENSURE_TRUE(doc, false);
 
   AutoPushJSContext cx(GetJSContextFromDoc(doc));
   NS_ENSURE_TRUE(cx, false);
 
   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) {
     return false;
   }
 
   obj = JS_ObjectToInnerObject(cx, obj);
   NS_ABORT_IF_FALSE(obj,
--- a/dom/plugins/base/nsNPAPIPlugin.h
+++ b/dom/plugins/base/nsNPAPIPlugin.h
@@ -134,17 +134,16 @@ IntToNPIdentifier(int i)
 }
 
 JSContext* GetJSContext(NPP npp);
 
 inline bool
 NPStringIdentifierIsPermanent(NPP npp, NPIdentifier id)
 {
   AutoSafeJSContext cx;
-  JSAutoRequest ar(cx);
   return JS_StringHasBeenInterned(cx, NPIdentifierToString(id));
 }
 
 #define NPIdentifier_VOID (JSIdToNPIdentifier(JSID_VOID))
 
 NPObject* NP_CALLBACK
 _getwindowobject(NPP npp);
 
--- a/dom/plugins/ipc/PluginIdentifierParent.cpp
+++ b/dom/plugins/ipc/PluginIdentifierParent.cpp
@@ -27,17 +27,16 @@ PluginIdentifierParent::RecvRetain()
   AutoSafeJSContext cx;
   JS::Rooted<jsid> id(cx, NPIdentifierToJSId(mIdentifier));
   if (JSID_IS_INT(id)) {
     return true;
   }
 
   // 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) {
     return false;
   }
 
   NS_ASSERTION(str == str2, "Interning a string in a JSID should always return the same string.");
 
--- a/dom/plugins/ipc/PluginScriptableObjectParent.cpp
+++ b/dom/plugins/ipc/PluginScriptableObjectParent.cpp
@@ -1037,18 +1037,16 @@ PluginScriptableObjectParent::AnswerEnum
   if (!npn->enumerate(instance->GetNPP(), mObject, &ids, &idCount)) {
     *aSuccess = false;
     return true;
   }
 
   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.
     if (_identifierisstring(ids[index])) {
       JSString* str = NPIdentifierToString(ids[index]);
       if (!JS_StringHasBeenInterned(cx, str)) {
         DebugOnly<JSString*> str2 = JS_InternJSString(cx, str);
         NS_ASSERTION(str2 == str, "Interning a JS string which is currently an ID should return itself.");
--- a/dom/src/json/nsJSON.cpp
+++ b/dom/src/json/nsJSON.cpp
@@ -170,19 +170,16 @@ WriteCallback(const jschar *buf, uint32_
   return JS_TRUE;
 }
 
 NS_IMETHODIMP
 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());
   }
 
   nsJSONWriter writer;
   if (!JS_Stringify(cx, value, NULL, JSVAL_NULL, WriteCallback, &writer)) {
     return NS_ERROR_XPC_BAD_CONVERT_JS;
@@ -193,18 +190,16 @@ nsJSON::EncodeFromJSVal(JS::Value *value
   result.Assign(writer.mOutputString);
   return NS_OK;
 }
 
 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()) {
     return NS_ERROR_INVALID_ARG;
   }
   JS::Rooted<JSObject*> obj(cx, &aValue.toObject());
 
   /* Backward compatibility:
@@ -385,36 +380,32 @@ nsJSON::DecodeFromStream(nsIInputStream 
                          JSContext* cx, JS::Value* aRetval)
 {
   return DecodeInternal(cx, aStream, aContentLength, true, aRetval);
 }
 
 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;
   }
 
   return NS_OK;
 }
 
 nsresult
 nsJSON::DecodeInternal(JSContext* cx,
                        nsIInputStream *aStream,
                        int32_t aContentLength,
                        bool aNeedsConverter,
                        JS::Value* aRetval,
                        DecodingMode mode /* = STRICT */)
 {
-  JSAutoRequest ar(cx);
-
   // Consume the stream
   nsCOMPtr<nsIChannel> jsonChannel;
   if (!mURI) {
     NS_NewURI(getter_AddRefs(mURI), NS_LITERAL_CSTRING("about:blank"), 0, 0 );
     if (!mURI)
       return NS_ERROR_OUT_OF_MEMORY;
   }
 
@@ -494,18 +485,16 @@ nsJSON::LegacyDecodeFromStream(nsIInputS
                                JSContext* cx, JS::Value* aRetval)
 {
   return DecodeInternal(cx, aStream, aContentLength, true, aRetval, LEGACY);
 }
 
 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()),
                           str.Length());
   if (!js::ParseJSONWithReviver(cx, chars, str.Length(), reviver,
                                 &value, LEGACY)) {
     return NS_ERROR_UNEXPECTED;
   }
--- a/dom/src/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/src/jsurl/nsJSProtocolHandler.cpp
@@ -254,18 +254,16 @@ nsresult nsJSThunk::EvaluateScript(nsICh
         if (NS_FAILED(rv))
             return rv;
 
         useSandbox = !subsumes;
     }
 
     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
         // sandbox to prevent it from accessing data it doesn't have
         // permissions to access.
 
         // First check to make sure it's OK to evaluate this script to
         // start with.  For example, script could be disabled.
--- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp
@@ -674,17 +674,16 @@ GonkGPSGeolocationProvider::ReceiveDataC
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::Handle(const nsAString& aName,
                                    const JS::Value& aResult)
 {
   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()) {
       // NB: No need to enter a compartment to read the contents of a string.
       nsDependentJSString apn;
       apn.init(cx, aResult.toString());
       if (!apn.IsEmpty()) {
         SetAGpsDataConn(apn);
--- a/dom/system/gonk/SystemWorkerManager.cpp
+++ b/dom/system/gonk/SystemWorkerManager.cpp
@@ -482,17 +482,16 @@ SystemWorkerManager::RegisterRilWorker(u
 
   mRilConsumers.EnsureLengthAtLeast(aClientId + 1);
 
   if (mRilConsumers[aClientId]) {
     NS_WARNING("RilConsumer already registered");
     return NS_ERROR_FAILURE;
   }
 
-  JSAutoRequest ar(aCx);
   JSAutoCompartment ac(aCx, JSVAL_TO_OBJECT(aWorker));
 
   WorkerCrossThreadDispatcher *wctd =
     GetWorkerCrossThreadDispatcher(aCx, aWorker);
   if (!wctd) {
     NS_WARNING("Failed to GetWorkerCrossThreadDispatcher for ril");
     return NS_ERROR_FAILURE;
   }
@@ -515,17 +514,16 @@ SystemWorkerManager::InitNetd(JSContext 
   nsCOMPtr<nsIWorkerHolder> worker = do_GetService(kNetworkManagerCID);
   NS_ENSURE_TRUE(worker, NS_ERROR_FAILURE);
 
   JS::Value workerval;
   nsresult rv = worker->GetWorker(&workerval);
   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 =
     GetWorkerCrossThreadDispatcher(cx, workerval);
   if (!wctd) {
     NS_WARNING("Failed to GetWorkerCrossThreadDispatcher for netd");
     return NS_ERROR_FAILURE;
   }
--- a/dom/system/gonk/TimeZoneSettingObserver.cpp
+++ b/dom/system/gonk/TimeZoneSettingObserver.cpp
@@ -76,17 +76,16 @@ public:
       }
       settingsService->CreateLock(getter_AddRefs(lock));
       lock->Set(TIME_TIMEZONE, STRING_TO_JSVAL(jsStr), nullptr, nullptr);
       return NS_OK;
     }
 
     // Set the system timezone based on the current settings.
     if (aResult.isString()) {
-      JSAutoRequest ar(cx);
       return TimeZoneSettingObserver::SetTimeZone(aResult, cx);
     }
 
     return NS_OK;
   }
 
   NS_IMETHOD HandleError(const nsAString &aName) {
     ERR("TimeZoneSettingCb::HandleError: %s\n", NS_LossyConvertUTF16toASCII(aName).get());
--- a/dom/time/DateCacheCleaner.cpp
+++ b/dom/time/DateCacheCleaner.cpp
@@ -27,17 +27,16 @@ public:
 
   ~DateCacheCleaner()
   {
     UnregisterSystemTimezoneChangeObserver(this);
   }
   void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo)
   {
     mozilla::AutoSafeJSContext cx;
-    JSAutoRequest ar(cx);
     JS_ClearDateCaches(cx);
   }
 
 };
 
 StaticAutoPtr<DateCacheCleaner> sDateCacheCleaner;
 
 void
--- a/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp
+++ b/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp
@@ -47,17 +47,16 @@ nsresult CentralizedAdminPrefManagerInit
 
     // Grab the system principal.
     nsCOMPtr<nsIPrincipal> principal;
     nsContentUtils::GetSecurityManager()->GetSystemPrincipal(getter_AddRefs(principal));
 
 
     // Create a sandbox.
     AutoSafeJSContext cx;
-    JSAutoRequest ar(cx);
     nsCOMPtr<nsIXPConnectJSObjectHolder> sandbox;
     rv = xpc->CreateSandbox(cx, principal, getter_AddRefs(sandbox));
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Unwrap, store and root the sandbox.
     autoconfigSb = sandbox->GetJSObject();
     NS_ENSURE_STATE(autoconfigSb);
     autoconfigSb = js::UncheckedUnwrap(autoconfigSb);
@@ -67,17 +66,16 @@ nsresult CentralizedAdminPrefManagerInit
 
     return NS_OK;
 }
 
 nsresult CentralizedAdminPrefManagerFinish()
 {
     if (autoconfigSb) {
         AutoSafeJSContext cx;
-        JSAutoRequest ar(cx);
         JSAutoCompartment(cx, autoconfigSb);
         JS_RemoveObjectRoot(cx, &autoconfigSb);
         JS_MaybeGC(cx);
     }
     return NS_OK;
 }
 
 nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length,
@@ -110,17 +108,16 @@ nsresult EvaluateAdminConfigScript(const
 
     // Grab XPConnect.
     nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID(), &rv);
     if (NS_FAILED(rv)) {
         return rv;
     }
 
     AutoSafeJSContext cx;
-    JSAutoRequest ar(cx);
     JSAutoCompartment ac(cx, autoconfigSb);
 
     nsAutoCString script(js_buffer, length);
     JS::RootedValue v(cx);
     rv = xpc->EvalInSandboxObject(NS_ConvertASCIItoUTF16(script), filename, cx, autoconfigSb,
                                   /* returnStringOnly = */ false, v.address());
     NS_ENSURE_SUCCESS(rv, rv);
 
--- a/js/ipc/ObjectWrapperChild.cpp
+++ b/js/ipc/ObjectWrapperChild.cpp
@@ -22,27 +22,25 @@
 using namespace mozilla::jsipc;
 using namespace js;
 
 namespace {
 
     class MOZ_STACK_CLASS AutoContextPusher {
 
         nsCxPusher mStack;
-        JSAutoRequest mRequest;
         JSContext* const mContext;
         const uint32_t mSavedOptions;
         MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
     public:
 
         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)))
         {
             MOZ_GUARD_OBJECT_NOTIFIER_INIT;
             mStack.Push(cx);
         }
 
         ~AutoContextPusher() {
@@ -112,30 +110,28 @@ ObjectWrapperChild::CheckOperation(JSCon
         JS_ClearPendingException(cx);
     }
 }
 
 ObjectWrapperChild::ObjectWrapperChild(JSContext* cx, JSObject* obj)
     : mObj(obj)
 {
     AutoContextPusher acp(cx);
-    JSAutoRequest request(cx);
 #ifdef DEBUG
     bool added =
 #endif
          JS_AddObjectRoot(cx, &mObj);
     NS_ASSERTION(added, "ObjectWrapperChild constructor failed to root JSObject*");
 }
 
 void
 ObjectWrapperChild::ActorDestroy(ActorDestroyReason why)
 {
     JSContext* cx = Manager()->GetContext();
     AutoContextPusher acp(cx);
-    JSAutoRequest request(cx);
     JS_RemoveObjectRoot(cx, &mObj);
 }
 
 bool
 ObjectWrapperChild::JSObject_to_JSVariant(JSContext* cx, JSObject* from,
                                           JSVariant* to)
 {
     *to = Manager()->GetOrCreateWrapper(from);
--- a/js/jsd/jsd_xpc.cpp
+++ b/js/jsd/jsd_xpc.cpp
@@ -990,17 +990,16 @@ jsdScript::~jsdScript ()
  * This method populates a line <-> pc map for a pretty printed version of this
  * script.  It does this by decompiling, and then recompiling the script.  The
  * resulting script is scanned for the line map, and then left as GC fodder.
  */
 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;
     JS::RootedFunction fun(cx, JSD_GetJSFunction (mCx, mScript));
     JS::RootedScript script(cx); /* In JSD compartment */
     uint32_t    baseLine;
     JS::RootedString jsstr(cx);
     size_t      length;
@@ -1235,17 +1234,16 @@ jsdScript::GetParameterNames(uint32_t* c
     }
     JS::RootedFunction fun(cx, JSD_GetJSFunction (mCx, mScript));
     if (!fun) {
         *count = 0;
         *paramNames = nullptr;
         return NS_OK;
     }
 
-    JSAutoRequest ar(cx);
     JSAutoCompartment ac(cx, JS_GetFunctionObject(fun));
 
     unsigned nargs;
     if (!JS_FunctionHasLocalNames(cx, fun) ||
         (nargs = JS_GetFunctionArgumentCount(cx, fun)) == 0) {
         *count = 0;
         *paramNames = nullptr;
         return NS_OK;
@@ -1325,18 +1323,16 @@ jsdScript::GetFunctionSource(nsAString &
     ASSERT_VALID_EPHEMERAL;
     JSContext *cx = JSD_GetDefaultJSContext (mCx);
     if (!cx) {
         NS_WARNING("No default context !?");
         return NS_ERROR_FAILURE;
     }
     JS::RootedFunction fun(cx, JSD_GetJSFunction (mCx, mScript));
 
-    JSAutoRequest ar(cx);
-
     JSString *jsstr;
     mozilla::Maybe<JSAutoCompartment> ac;
     if (fun) {
         ac.construct(cx, JS_GetFunctionObject(fun));
         jsstr = JS_DecompileFunction (cx, fun, 4);
     } else {
         JS::RootedScript script(cx, JSD_GetJSScript (mCx, mScript));
         ac.construct(cx, script);
@@ -2035,17 +2031,16 @@ jsdStackFrame::Eval (const nsAString &by
     bytes.BeginReading(h);
     const jschar *char_bytes = reinterpret_cast<const jschar *>(h.get());
 
     JSExceptionState *estate = 0;
 
     JSContext *cx = JSD_GetJSContext (mCx, mThreadState);
 
     JS::RootedValue jv(cx);
-    JSAutoRequest ar(cx);
 
     estate = JS_SaveExceptionState (cx);
     JS_ClearPendingException (cx);
 
     nsCxPusher pusher;
     pusher.Push(cx);
 
     *_rval = JSD_AttemptUCScriptInStackFrame (mCx, mThreadState,
@@ -2349,18 +2344,16 @@ jsdValue::GetProperties (jsdIProperty **
 }
 
 NS_IMETHODIMP
 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)
         return NS_ERROR_OUT_OF_MEMORY;
 
     JSDProperty *prop = JSD_GetValueProperty (mCx, mValue, jstr_name);
     
     *_rval = jsdProperty::FromPtr (mCx, prop);
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -1133,17 +1133,16 @@ mozJSComponentLoader::UnloadModules()
 {
     mInitialized = false;
 
     if (mLoaderGlobal) {
         MOZ_ASSERT(mReuseLoaderGlobal, "How did this happen?");
 
         RootedObject global(mContext, mLoaderGlobal->GetJSObject());
         if (global) {
-            JSAutoRequest ar(mContext);
             JS_SetAllNonReservedSlotsToUndefined(mContext, global);
         } else {
             NS_WARNING("Going to leak!");
         }
 
         mLoaderGlobal = nullptr;
     }
 
@@ -1165,17 +1164,16 @@ mozJSComponentLoader::UnloadModules()
 
 NS_IMETHODIMP
 mozJSComponentLoader::Import(const nsACString& registryLocation,
                              const JS::Value& targetValArg,
                              JSContext* cx,
                              uint8_t optionalArgc,
                              JS::Value* retval)
 {
-    JSAutoRequest ar(cx);
     MOZ_ASSERT(nsContentUtils::IsCallerChrome());
 
     RootedValue targetVal(cx, targetValArg);
     RootedObject targetObject(cx, nullptr);
     if (optionalArgc) {
         // The caller passed in the optional second argument. Get it.
         if (targetVal.isObject()) {
             // If we're passing in something like a content DOM window, chances
--- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp
+++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
@@ -193,18 +193,16 @@ mozJSSubScriptLoader::LoadSubScript(cons
         if (!secman)
             return NS_OK;
 
         rv = secman->GetSystemPrincipal(getter_AddRefs(mSystemPrincipal));
         if (NS_FAILED(rv) || !mSystemPrincipal)
             return rv;
     }
 
-    JSAutoRequest ar(cx);
-
     RootedObject targetObj(cx);
     mozJSComponentLoader* loader = mozJSComponentLoader::Get();
     rv = loader->FindTargetObject(cx, &targetObj);
     NS_ENSURE_SUCCESS(rv, rv);
 
     bool reusingGlobal = !JS_IsGlobalObject(targetObj);
 
     // We base reusingGlobal off of what the loader told us, but we may not
--- a/js/xpconnect/public/nsTArrayHelpers.h
+++ b/js/xpconnect/public/nsTArrayHelpers.h
@@ -6,17 +6,16 @@
 #define __NSTARRAYHELPERS_H__
 
 template <class T>
 inline nsresult
 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));
   if (!arrayObj) {
     NS_WARNING("JS_NewArrayObject failed!");
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
@@ -50,17 +49,16 @@ nsTArrayToJSArray(JSContext* aCx, const 
 
 template <>
 inline nsresult
 nsTArrayToJSArray<nsString>(JSContext* aCx,
                             const nsTArray<nsString>& aSourceArray,
                             JSObject** aResultArray)
 {
   MOZ_ASSERT(aCx);
-  JSAutoRequest ar(aCx);
 
   JS::Rooted<JSObject*> arrayObj(aCx,
     JS_NewArrayObject(aCx, aSourceArray.Length(), nullptr));
   if (!arrayObj) {
     NS_WARNING("JS_NewArrayObject failed!");
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
--- a/js/xpconnect/shell/xpcshell.cpp
+++ b/js/xpconnect/shell/xpcshell.cpp
@@ -1892,17 +1892,16 @@ main(int argc, char **argv, char **envp)
 
         glob = holder->GetJSObject();
         if (!glob) {
             return 1;
         }
 
         backstagePass->SetGlobalObject(glob);
 
-        JS_BeginRequest(cx);
         {
             JSAutoCompartment ac(cx, glob);
 
             if (!JS_InitReflect(cx, glob)) {
                 JS_EndRequest(cx);
                 return 1;
             }
 
@@ -1927,18 +1926,17 @@ main(int argc, char **argv, char **envp)
             JS_DefineProperty(cx, glob, "__LOCATION__", JSVAL_VOID,
                               GetLocationProperty, NULL, 0);
 
             result = ProcessArgs(cx, glob, argv, argc, &dirprovider);
 
             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);
     } // this scopes the nsCOMPtrs
 
     if (!XRE_ShutdownTestShell())
         NS_ERROR("problem shutting down testshell");
 
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -2690,18 +2690,16 @@ nsXPCComponents_Utils::GetSandbox(nsIXPC
 
 /* void lookupMethod (); */
 NS_IMETHODIMP
 nsXPCComponents_Utils::LookupMethod(const JS::Value& object,
                                     const JS::Value& name,
                                     JSContext *cx,
                                     JS::Value *retval)
 {
-    JSAutoRequest ar(cx);
-
     // first param must be a JSObject
     if (!object.isObject())
         return NS_ERROR_XPC_BAD_CONVERT_JS;
     JS::RootedObject obj(cx, &object.toObject());
 
     // second param must be a string.
     if (!JSVAL_IS_STRING(name))
         return NS_ERROR_XPC_BAD_CONVERT_JS;
@@ -2768,18 +2766,16 @@ nsXPCComponents_Utils::ReportError(const
 
     nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
 
     nsCOMPtr<nsIScriptError> scripterr(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
 
     if (!scripterr || !console)
         return NS_OK;
 
-    JSAutoRequest ar(cx);
-
     const uint64_t innerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx);
 
     JSErrorReport *err = JS_ErrorFromException(cx, error);
     if (err) {
         // It's a proper JS Error
         nsAutoString fileUni;
         CopyUTF8toUTF16(err->filename, fileUni);
 
@@ -3801,17 +3797,16 @@ ContextHolder::ContextHolder(JSContext *
       mPrincipal(aPrincipal)
 {
     if (mJSContext) {
         bool isChrome;
         DebugOnly<nsresult> rv = XPCWrapper::GetSecurityManager()->
                                    IsSystemPrincipal(mPrincipal, &isChrome);
         MOZ_ASSERT(NS_SUCCEEDED(rv));
 
-        JSAutoRequest ar(mJSContext);
         JS_SetOptions(mJSContext,
                       JS_GetOptions(mJSContext) |
                       JSOPTION_DONT_REPORT_UNCAUGHT |
                       JSOPTION_PRIVATE_IS_NSISUPPORTS);
         JS_SetGlobalObject(mJSContext, aSandbox);
         JS_SetContextPrivate(mJSContext, this);
         JS_SetOperationCallback(mJSContext, ContextHolderOperationCallback);
     }
@@ -3906,17 +3901,16 @@ nsXPCComponents_Utils::EvalInSandbox(con
 }
 
 nsresult
 xpc_EvalInSandbox(JSContext *cx, HandleObject sandboxArg, const nsAString& source,
                   const char *filename, int32_t lineNo,
                   JSVersion jsVersion, bool returnStringOnly, MutableHandleValue rval)
 {
     JS_AbortIfWrongThread(JS_GetRuntime(cx));
-    JSAutoRequest ar(cx);
     rval.set(UndefinedValue());
 
     bool waiveXray = xpc::WrapperFactory::HasWaiveXrayFlag(sandboxArg);
     RootedObject sandbox(cx, js::CheckedUnwrap(sandboxArg));
     if (!sandbox || js::GetObjectJSClass(sandbox) != &SandboxClass) {
         return NS_ERROR_INVALID_ARG;
     }
 
@@ -3945,18 +3939,16 @@ xpc_EvalInSandbox(JSContext *cx, HandleO
         nsRefPtr<ContextHolder> sandcxHolder = new ContextHolder(cx, sandbox, prin);
         JSContext *sandcx = sandcxHolder->GetJSContext();
         if (!sandcx) {
             JS_ReportError(cx, "Can't prepare context for evalInSandbox");
             return NS_ERROR_OUT_OF_MEMORY;
         }
         nsCxPusher pusher;
         pusher.Push(sandcx);
-
-        JSAutoRequest req(sandcx);
         JSAutoCompartment ac(sandcx, sandbox);
 
         if (jsVersion != JSVERSION_DEFAULT)
             JS_SetVersion(sandcx, jsVersion);
 
         JS::CompileOptions options(sandcx);
         options.setPrincipals(nsJSPrincipals::get(prin))
                .setFileAndLine(filename, lineNo);
--- a/js/xpconnect/src/XPCDebug.cpp
+++ b/js/xpconnect/src/XPCDebug.cpp
@@ -92,18 +92,16 @@ xpc_DumpEvalInJSStackFrame(JSContext* cx
         num++;
     }
 
     if (!frame) {
         DebugDump("%s", "invalid frame number!\n");
         return false;
     }
 
-    JSAutoRequest ar(cx);
-
     JSExceptionState* exceptionState = JS_SaveExceptionState(cx);
     JSErrorReporter older = JS_SetErrorReporter(cx, xpcDumpEvalErrorReporter);
 
     JS::RootedValue rval(cx);
     JSString* str;
     JSAutoByteString bytes;
     if (frame.evaluateInStackFrame(cx, text, strlen(text), "eval", 1, &rval) &&
         nullptr != (str = JS_ValueToString(cx, rval)) &&
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -3018,17 +3018,16 @@ XPCJSRuntime::RemoveGCCallback(JSGCCallb
 
 JSObject *
 XPCJSRuntime::GetJunkScope()
 {
     if (!mJunkScope) {
         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(),
                                               options);
 
         NS_ENSURE_SUCCESS(rv, nullptr);
 
         mJunkScope = js::UncheckedUnwrap(&v.toObject());
@@ -3038,13 +3037,12 @@ XPCJSRuntime::GetJunkScope()
 }
 
 void
 XPCJSRuntime::DeleteJunkScope()
 {
     if(!mJunkScope)
         return;
 
-    JSContext *cx = mJSContextStack->GetSafeJSContext();
-    JSAutoRequest ac(cx);
+    AutoSafeJSContext cx;
     JS_RemoveObjectRoot(cx, &mJunkScope);
     mJunkScope = nullptr;
 }
--- a/js/xpconnect/src/XPCJSWeakReference.cpp
+++ b/js/xpconnect/src/XPCJSWeakReference.cpp
@@ -11,18 +11,16 @@
 xpcJSWeakReference::xpcJSWeakReference()
 {
 }
 
 NS_IMPL_ISUPPORTS1(xpcJSWeakReference, xpcIJSWeakReference)
 
 nsresult xpcJSWeakReference::Init(JSContext* cx, const JS::Value& object)
 {
-    JSAutoRequest ar(cx);
-
     if (!object.isObject())
         return NS_OK;
 
     JS::RootedObject obj(cx, &object.toObject());
 
     XPCCallContext ccx(NATIVE_CALLER, cx);
 
     // See if the object is a wrapped native that supports weak references.
--- a/js/xpconnect/src/XPCLog.cpp
+++ b/js/xpconnect/src/XPCLog.cpp
@@ -115,12 +115,11 @@ LogSlimWrapperNotCreated(JSContext *cx, 
     char* className = nullptr;
     nsCOMPtr<nsIClassInfo> ci = do_QueryInterface(obj);
     if (ci)
         ci->GetClassDescription(&className);
     printf("***** refusing to create slim wrapper%s%s, reason: %s (%p)\n",
            className ? " for " : "", className ? className : "", reason, obj);
     if (className)
         PR_Free(className);
-    JSAutoRequest autoRequest(cx);
     xpc_DumpJSStack(cx, false, false, false);
 }
 #endif
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -249,17 +249,16 @@ XPCWrappedNativeScope::EnsureXBLScope(JS
     nsIPrincipal *principal = GetPrincipal();
     nsCOMPtr<nsIExpandedPrincipal> ep;
     MOZ_ASSERT(!(ep = do_QueryInterface(principal)));
     nsTArray< nsCOMPtr<nsIPrincipal> > principalAsArray(1);
     principalAsArray.AppendElement(principal);
     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);
     mXBLScope = &v.toObject();
 
     // Tag it.
     EnsureCompartmentPrivate(js::UncheckedUnwrap(mXBLScope))->scope->mIsXBLScope = true;
 
--- a/js/xpconnect/src/dictionary_helper_gen.py
+++ b/js/xpconnect/src/dictionary_helper_gen.py
@@ -206,17 +206,16 @@ def print_cpp_file(fd, conf):
              "    id = INTERNED_STRING_TO_JSID(aCx, str);\n"
              "    return true;\n"
              "  }\n"
              "  return false;\n"
              "}\n\n"
              "bool\n"
              "InternStaticDictionaryJSVals(JSContext* aCx)\n"
              "{\n"
-             "  JSAutoRequest ar(aCx);\n"
              "  return\n")
     for a in attrnames:
         fd.write("    InternStaticJSVal(aCx, %s, \"%s\") &&\n"
                  % (get_jsid(a), a))
 
     fd.write("    true;\n")
     fd.write("}\n\n")
 
@@ -402,17 +401,16 @@ def write_cpp(iface, fd):
              "    return NS_OK;\n"
              "  }\n"
              "  if (!aVal->isObject()) {\n"
              "    return aVal->isNullOrUndefined() ? NS_OK : NS_ERROR_TYPE_ERR;\n"
              "  }\n\n"
              "  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" %
                  iface.name)
 
 
 if __name__ == '__main__':
     from optparse import OptionParser
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -2012,17 +2012,16 @@ nsXPConnect::CheckForDebugMode(JSRuntime
     }
 
     {
         struct AutoDestroyContext {
             JSContext *cx;
             AutoDestroyContext(JSContext *cx) : cx(cx) {}
             ~AutoDestroyContext() { JS_DestroyContext(cx); }
         } adc(cx);
-        JSAutoRequest ar(cx);
 
         if (!JS_SetDebugModeForAllCompartments(cx, gDesiredDebugMode))
             goto fail;
     }
 
     if (gDesiredDebugMode) {
         rv = jsds->ActivateDebugger(rt);
     }
@@ -2473,17 +2472,16 @@ WriteScriptOrFunction(nsIObjectOutputStr
         rv = stream->WriteObject(originPrincipal, true);
         if (NS_FAILED(rv))
             return rv;
     }
 
     uint32_t size;
     void* data;
     {
-        JSAutoRequest ar(cx);
         if (functionObj)
             data = JS_EncodeInterpretedFunction(cx, functionObj, &size);
         else
             data = JS_EncodeScript(cx, script, &size);
     }
 
     if (!data)
         return NS_ERROR_OUT_OF_MEMORY;
@@ -2532,17 +2530,16 @@ ReadScriptOrFunction(nsIObjectInputStrea
         return rv;
 
     char* data;
     rv = stream->ReadBytes(size, &data);
     if (NS_FAILED(rv))
         return rv;
 
     {
-        JSAutoRequest ar(cx);
         if (scriptp) {
             JSScript *script = JS_DecodeScript(cx, data, size, principal, originPrincipal);
             if (!script)
                 rv = NS_ERROR_OUT_OF_MEMORY;
             else
                 *scriptp = script;
         } else {
             JSObject *funobj = JS_DecodeInterpretedFunction(cx, data, size,
--- a/js/xpconnect/src/xpcpublic.h
+++ b/js/xpconnect/src/xpcpublic.h
@@ -200,25 +200,16 @@ xpc_UnmarkGrayContext(JSContext *cx)
             JSObject *scope = JS_GetGlobalForScopeChain(cx);
             if (scope != global)
                 xpc_UnmarkGrayObject(scope);
         }
     }
     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
 xpc_MarkInCCGeneration(nsISupports* aVariant, uint32_t aGeneration);
 
 // If aWrappedJS is a JS wrapper, unmark its JSObject.
 extern void
 xpc_TryUnmarkWrappedGrayObject(nsISupports* aWrappedJS);
--- a/netwerk/base/src/Dashboard.cpp
+++ b/netwerk/base/src/Dashboard.cpp
@@ -1,18 +1,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * 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 {
 
 NS_IMPL_THREADSAFE_ISUPPORTS2(Dashboard, nsIDashboard, nsIDashboardEventNotifier)
 using mozilla::dom::Sequence;
 
 Dashboard::Dashboard()
 {
@@ -44,18 +46,17 @@ Dashboard::GetSocketsDispatch()
         gSocketTransportService->GetSocketConnections(&mSock.data);
     nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &Dashboard::GetSockets);
     mSock.thread->Dispatch(event, NS_DISPATCH_NORMAL);
 }
 
 nsresult
 Dashboard::GetSockets()
 {
-    JSContext* cx = nsContentUtils::GetSafeJSContext();
-    JSAutoRequest request(cx);
+    AutoSafeJSContext cx;
 
     mozilla::dom::SocketsDict dict;
     dict.mHost.Construct();
     dict.mPort.Construct();
     dict.mActive.Construct();
     dict.mTcp.Construct();
     dict.mSocksent.Construct();
     dict.mSockreceived.Construct();
@@ -123,18 +124,17 @@ Dashboard::GetHttpDispatch()
     nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &Dashboard::GetHttpConnections);
     mHttp.thread->Dispatch(event, NS_DISPATCH_NORMAL);
 }
 
 
 nsresult
 Dashboard::GetHttpConnections()
 {
-    JSContext* cx = nsContentUtils::GetSafeJSContext();
-    JSAutoRequest request(cx);
+    AutoSafeJSContext cx;
 
     mozilla::dom::HttpConnDict dict;
     dict.mActive.Construct();
     dict.mHost.Construct();
     dict.mIdle.Construct();
     dict.mPort.Construct();
     dict.mSpdy.Construct();
     dict.mSsl.Construct();
@@ -294,18 +294,17 @@ Dashboard::RequestWebsocketConnections(N
     nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &Dashboard::GetWebSocketConnections);
     mWs.thread->Dispatch(event, NS_DISPATCH_NORMAL);
     return NS_OK;
 }
 
 nsresult
 Dashboard::GetWebSocketConnections()
 {
-    JSContext* cx = nsContentUtils::GetSafeJSContext();
-    JSAutoRequest request(cx);
+    AutoSafeJSContext cx;
 
     mozilla::dom::WebSocketDict dict;
     dict.mEncrypted.Construct();
     dict.mHostport.Construct();
     dict.mMsgreceived.Construct();
     dict.mMsgsent.Construct();
     dict.mReceivedsize.Construct();
     dict.mSentsize.Construct();
@@ -377,18 +376,17 @@ Dashboard::GetDnsInfoDispatch()
         mDns.serv->GetDNSCacheEntries(&mDns.data);
     nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &Dashboard::GetDNSCacheEntries);
     mDns.thread->Dispatch(event, NS_DISPATCH_NORMAL);
 }
 
 nsresult
 Dashboard::GetDNSCacheEntries()
 {
-    JSContext* cx = nsContentUtils::GetSafeJSContext();
-    JSAutoRequest request(cx);
+    AutoSafeJSContext cx;
 
     mozilla::dom::DNSCacheDict dict;
     dict.mExpiration.Construct();
     dict.mFamily.Construct();
     dict.mHostaddr.Construct();
     dict.mHostname.Construct();
 
     Sequence<double> &expiration = dict.mExpiration.Value();
--- a/security/manager/ssl/src/nsCrypto.cpp
+++ b/security/manager/ssl/src/nsCrypto.cpp
@@ -1854,18 +1854,16 @@ nsCrypto::GenerateCRMFRequest(nsIDOMCRMF
 
   JSContext *cx;
 
   nrv = ncc->GetJSContext(&cx);
   NS_ENSURE_SUCCESS(nrv, nrv);
 
   nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
 
-  JSAutoRequest ar(cx);
-
   /*
    * Get all of the parameters.
    */
   if (argc < 5 || ((argc-5) % 3) != 0) {
     JS_ReportError(cx, "%s", "%s%s\n", JS_ERROR,
                   "incorrect number of parameters");
     return NS_ERROR_FAILURE;
   }
--- a/xpcom/io/nsBinaryStream.cpp
+++ b/xpcom/io/nsBinaryStream.cpp
@@ -711,17 +711,16 @@ NS_IMETHODIMP
 nsBinaryInputStream::ReadByteArray(uint32_t aLength, uint8_t* *_rval)
 {
     return ReadBytes(aLength, reinterpret_cast<char **>(_rval));
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength, const JS::Value& aBuffer, JSContext* cx)
 {
-    JSAutoRequest ar(cx);
     if (!aBuffer.isObject()) {
         return NS_ERROR_FAILURE;
     }
     JS::RootedObject buffer(cx, &aBuffer.toObject());
     if (!JS_IsArrayBufferObject(buffer) ||
         JS_GetArrayBufferByteLength(buffer) < aLength) {
         return NS_ERROR_FAILURE;
     }
--- a/xpfe/components/directory/nsDirectoryViewer.cpp
+++ b/xpfe/components/directory/nsDirectoryViewer.cpp
@@ -163,17 +163,16 @@ nsHTTPIndex::OnFTPControlLog(bool server
 
     JS::Rooted<JSObject*> global(cx, JS_GetGlobalForScopeChain(cx));
     NS_ENSURE_TRUE(global, NS_OK);
 
     JS::Value params[2];
 
     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);
 
     params[0] = BOOLEAN_TO_JSVAL(server);
     params[1] = STRING_TO_JSVAL(jsMsgStr);
 
     JS::Value val;
     JS_CallFunctionName(cx,
@@ -257,17 +256,16 @@ nsHTTPIndex::OnStartRequest(nsIRequest *
     JS::Rooted<JSObject*> jsobj(cx, wrapper->GetJSObject());
     NS_ASSERTION(jsobj,
                  "unable to get jsobj from xpconnect wrapper");
     if (!jsobj) return NS_ERROR_UNEXPECTED;
 
     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)
       return NS_ERROR_FAILURE;
   }
 
   if (!aContext) {
     nsCOMPtr<nsIChannel> channel(do_QueryInterface(request));