From 41c9799518e68da8fd4c7af63db8f4ca914ff59d Mon Sep 17 00:00:00 2001 From: Steve Fink Date: Wed, 11 Dec 2013 12:15:16 -0800 Subject: [PATCH] Bug 940765 - Root before preference checking, r=bz --- dom/base/Navigator.cpp | 12 ++++++++---- dom/base/Navigator.h | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 908f1f936649..443deca78c45 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -1703,14 +1703,16 @@ Navigator::HasMobileMessageSupport(JSContext* /* unused */, JSObject* aGlobal) /* static */ bool -Navigator::HasTelephonySupport(JSContext* /* unused */, JSObject* aGlobal) +Navigator::HasTelephonySupport(JSContext* cx, JSObject* aGlobal) { + JS::Rooted global(cx, aGlobal); + // First of all, the general pref has to be turned on. bool enabled = false; Preferences::GetBool("dom.telephony.enabled", &enabled); NS_ENSURE_TRUE(enabled, false); - nsCOMPtr win = GetWindowFromGlobal(aGlobal); + nsCOMPtr win = GetWindowFromGlobal(global); return win && CheckPermission(win, "telephony"); } @@ -1854,8 +1856,10 @@ bool Navigator::HasInputMethodSupport(JSContext* /* unused */, /* static */ bool -Navigator::HasDataStoreSupport(JSContext* /* unused */, JSObject* aGlobal) +Navigator::HasDataStoreSupport(JSContext* cx, JSObject* aGlobal) { + JS::Rooted global(cx, aGlobal); + // First of all, the general pref has to be turned on. bool enabled = false; Preferences::GetBool("dom.datastore.enabled", &enabled); @@ -1866,7 +1870,7 @@ Navigator::HasDataStoreSupport(JSContext* /* unused */, JSObject* aGlobal) return true; } - nsCOMPtr win = GetWindowFromGlobal(aGlobal); + nsCOMPtr win = GetWindowFromGlobal(global); if (!win) { return false; } diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 607b7086a960..282b3c51bd60 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -250,7 +250,7 @@ public: } static bool HasMobileMessageSupport(JSContext* /* unused */, JSObject* aGlobal); - static bool HasTelephonySupport(JSContext* /* unused */, + static bool HasTelephonySupport(JSContext* cx, JSObject* aGlobal); static bool HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal); @@ -286,7 +286,7 @@ public: static bool HasInputMethodSupport(JSContext* /* unused */, JSObject* aGlobal); - static bool HasDataStoreSupport(JSContext* /* unused */, JSObject* aGlobal); + static bool HasDataStoreSupport(JSContext* cx, JSObject* aGlobal); nsPIDOMWindow* GetParentObject() const {