diff --git a/dom/bluetooth/BluetoothService.cpp b/dom/bluetooth/BluetoothService.cpp index 64bc3284a64..4c8cf82c1af 100644 --- a/dom/bluetooth/BluetoothService.cpp +++ b/dom/bluetooth/BluetoothService.cpp @@ -550,7 +550,7 @@ BluetoothService::HandleSettingsChanged(const nsAString& aData) // The string that we're interested in will be a JSON string that looks like: // {"key":"bluetooth.enabled","value":true} - JSContext* cx = nsContentUtils::GetSafeJSContext(); + AutoSafeJSContext cx; if (!cx) { return NS_OK; } diff --git a/dom/indexedDB/ipc/IndexedDBParent.cpp b/dom/indexedDB/ipc/IndexedDBParent.cpp index 2fad7a87925..a613c247f90 100644 --- a/dom/indexedDB/ipc/IndexedDBParent.cpp +++ b/dom/indexedDB/ipc/IndexedDBParent.cpp @@ -527,7 +527,7 @@ IndexedDBDatabaseParent::HandleDatabaseEvent(nsIDOMEvent* aEvent, nsresult rv; if (aType.EqualsLiteral(VERSIONCHANGE_EVT_STR)) { - JSContext* cx = nsContentUtils::GetSafeJSContext(); + AutoSafeJSContext cx; NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE); nsCOMPtr changeEvent = do_QueryInterface(aEvent); diff --git a/dom/network/src/TCPSocketChild.cpp b/dom/network/src/TCPSocketChild.cpp index 0f6483bc882..1e70561d587 100644 --- a/dom/network/src/TCPSocketChild.cpp +++ b/dom/network/src/TCPSocketChild.cpp @@ -22,7 +22,7 @@ DeserializeArrayBuffer(JS::Handle aObj, const InfallibleTArray& aBuffer, JS::MutableHandle aVal) { - JSContext* cx = nsContentUtils::GetSafeJSContext(); + mozilla::AutoSafeJSContext cx; JSAutoCompartment ac(cx, aObj); JS::Rooted obj(cx, JS_NewArrayBuffer(cx, aBuffer.Length())); diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 1bb6311d9fd..494834ef0e0 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -2260,7 +2260,7 @@ class XPCJSRuntimeStats : public JS::RuntimeStats virtual void initExtraZoneStats(JS::Zone *zone, JS::ZoneStats *zStats) MOZ_OVERRIDE { // Get the compartment's global. nsXPConnect *xpc = nsXPConnect::GetXPConnect(); - JSContext *cx = xpc->GetSafeJSContext(); + AutoSafeJSContext cx; JSCompartment *comp = js::GetAnyCompartmentInZone(zone); xpc::ZoneStatsExtras *extras = new xpc::ZoneStatsExtras; extras->pathPrefix.AssignLiteral("explicit/js-non-window/zones/"); @@ -2293,7 +2293,7 @@ class XPCJSRuntimeStats : public JS::RuntimeStats // Get the compartment's global. nsXPConnect *xpc = nsXPConnect::GetXPConnect(); - JSContext *cx = xpc->GetSafeJSContext(); + AutoSafeJSContext cx; bool needZone = true; RootedObject global(cx, JS_GetGlobalForCompartmentOrNull(cx, c)); if (global) { diff --git a/xpcom/tests/TestSettingsAPI.cpp b/xpcom/tests/TestSettingsAPI.cpp index 06c3f8094b5..c9d3fc53bb8 100644 --- a/xpcom/tests/TestSettingsAPI.cpp +++ b/xpcom/tests/TestSettingsAPI.cpp @@ -154,7 +154,7 @@ TestSettingsObserver::Observe(nsISupports *aSubject, // Get the safe JS context. nsCOMPtr xpc = do_GetService(nsIXPConnect::GetCID()); - JSContext *cx = xpc->GetSafeJSContext(); + AutoSafeJSContext cx; if (!cx) { CHECK_MSG(false, "Failed to GetSafeJSContext"); return NS_OK;