mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 920831 - MozInputMethod's init should only return undefined. r=bz
This commit is contained in:
parent
a68780803a
commit
7759b3fe3a
@ -199,8 +199,6 @@ MozKeyboard.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
const TESTING_ENABLED_PREF = "dom.mozInputMethod.testing";
|
||||
|
||||
/*
|
||||
* A WeakMap to map input method iframe window to its active status.
|
||||
*/
|
||||
@ -317,24 +315,6 @@ MozInputMethod.prototype = {
|
||||
}),
|
||||
|
||||
init: function mozInputMethodInit(win) {
|
||||
// Check if we're in testing mode.
|
||||
let isTesting = false;
|
||||
try {
|
||||
isTesting = Services.prefs.getBoolPref(TESTING_ENABLED_PREF);
|
||||
} catch (e) {}
|
||||
|
||||
// Don't bypass the permission check if not in testing mode.
|
||||
if (!isTesting) {
|
||||
let principal = win.document.nodePrincipal;
|
||||
let perm = Services.perms
|
||||
.testExactPermissionFromPrincipal(principal, "keyboard");
|
||||
if (perm != Ci.nsIPermissionManager.ALLOW_ACTION) {
|
||||
dump("No permission to use the keyboard API for " +
|
||||
principal.origin + "\n");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
this._window = win;
|
||||
this._mgmt = new MozInputMethodManager(win);
|
||||
this.innerWindowID = win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
|
@ -1786,6 +1786,17 @@ bool Navigator::HasPushNotificationsSupport(JSContext* /* unused */,
|
||||
return win && Preferences::GetBool("services.push.enabled", false) && CheckPermission(win, "push");
|
||||
}
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
/* static */
|
||||
bool Navigator::HasInputMethodSupport(JSContext* /* unused */,
|
||||
JSObject* aGlobal)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
|
||||
return Preferences::GetBool("dom.mozInputMethod.testing", false) ||
|
||||
(win && CheckPermission(win, "keyboard"));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsPIDOMWindow>
|
||||
Navigator::GetWindowFromGlobal(JSObject* aGlobal)
|
||||
|
@ -300,6 +300,10 @@ public:
|
||||
static bool HasPushNotificationsSupport(JSContext* /* unused */,
|
||||
JSObject* aGlobal);
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
static bool HasInputMethodSupport(JSContext* /* unused */, JSObject* aGlobal);
|
||||
#endif
|
||||
|
||||
nsPIDOMWindow* GetParentObject() const
|
||||
{
|
||||
return GetWindow();
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
[JSImplementation="@mozilla.org/b2g-inputmethod;1",
|
||||
NavigatorProperty="mozInputMethod"]
|
||||
NavigatorProperty="mozInputMethod", Func="Navigator::HasInputMethodSupport"]
|
||||
interface MozInputMethod : EventTarget {
|
||||
// Input Method Manager contain a few global methods expose to apps
|
||||
readonly attribute MozInputMethodManager mgmt;
|
||||
|
Loading…
Reference in New Issue
Block a user