Backed out changeset 96974bd168a5 (bug 920831). Test mentioning MozInputMethod failed.
authorWes Kocher <wkocher@mozilla.com>
Thu, 26 Sep 2013 13:53:54 -0700
changeset 163645 0c156ee959d0d74641e81429a6dcfbd08715fd7d
parent 163644 1c110c20e21456e660f39e660982d2f14651e8bf
child 163646 af156cfb281f109e0cd76d2ed543556f4de8b7c5
child 163695 c20394dc5004726f22a4b2fc6b36ca8d1bc7c830
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs920831
milestone27.0a1
backs out96974bd168a57c29dec5d6856c4610b7b0242ea1
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
Backed out changeset 96974bd168a5 (bug 920831). Test mentioning MozInputMethod failed.
b2g/components/MozKeyboard.js
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/webidl/InputMethod.webidl
--- a/b2g/components/MozKeyboard.js
+++ b/b2g/components/MozKeyboard.js
@@ -194,16 +194,18 @@ MozKeyboard.prototype = {
 
   observe: function mozKeyboardObserve(subject, topic, data) {
     let wId = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
     if (wId == this.innerWindowID)
       this.uninit();
   }
 };
 
+const TESTING_ENABLED_PREF = "dom.mozInputMethod.testing";
+
 /*
  * A WeakMap to map input method iframe window to its active status.
  */
 let WindowMap = {
   // WeakMap of <window, boolean> pairs.
   _map: null,
 
   /*
@@ -310,16 +312,34 @@ MozInputMethod.prototype = {
     "classID": Components.ID("{4607330d-e7d2-40a4-9eb8-43967eae0142}"),
     "contractID": "@mozilla.org/b2g-inputmethod;1",
     "interfaces": [Ci.nsIInputMethod],
     "flags": Ci.nsIClassInfo.DOM_OBJECT,
     "classDescription": "B2G Input Method"
   }),
 
   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)
                             .getInterface(Ci.nsIDOMWindowUtils)
                             .currentInnerWindowID;
 
     Services.obs.addObserver(this, "inner-window-destroyed", false);
     cpmm.addMessageListener('Keyboard:FocusChange', this);
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1781,27 +1781,16 @@ bool Navigator::HasUserMediaSupport(JSCo
 /* static */
 bool Navigator::HasPushNotificationsSupport(JSContext* /* unused */,
                                             JSObject* aGlobal)
 {
   nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
   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)
 {
   nsCOMPtr<nsPIDOMWindow> win =
     do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(aGlobal));
   MOZ_ASSERT(!win || win->IsInnerWindow());
   return win.forget();
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -295,20 +295,16 @@ public:
 #ifdef MOZ_MEDIA_NAVIGATOR
   static bool HasUserMediaSupport(JSContext* /* unused */,
                                   JSObject* /* unused */);
 #endif // MOZ_MEDIA_NAVIGATOR
 
   static bool HasPushNotificationsSupport(JSContext* /* unused */,
                                           JSObject* aGlobal);
 
-#ifdef MOZ_B2G
-  static bool HasInputMethodSupport(JSContext* /* unused */, JSObject* aGlobal);
-#endif
-
   nsPIDOMWindow* GetParentObject() const
   {
     return GetWindow();
   }
 
   virtual JSObject* WrapObject(JSContext* cx,
                                JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
--- a/dom/webidl/InputMethod.webidl
+++ b/dom/webidl/InputMethod.webidl
@@ -1,16 +1,16 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/.
  */
 
 [JSImplementation="@mozilla.org/b2g-inputmethod;1",
- NavigatorProperty="mozInputMethod", Func="Navigator::HasInputMethodSupport"]
+ NavigatorProperty="mozInputMethod"]
 interface MozInputMethod : EventTarget {
   // Input Method Manager contain a few global methods expose to apps
   readonly attribute MozInputMethodManager mgmt;
 
   // Fired when the input context changes, include changes from and to null.
   // The new InputContext instance will be available in the event
   // object under |inputcontext| property.  When it changes to null it
   // means the app (the user of this API) no longer has the control of