Bug 822450 - Create a syntheticEventsOk pref for marionette identity tests. r=benadida
authorJed Parsons <jparsons@mozilla.com>
Mon, 17 Dec 2012 16:51:33 -0500
changeset 125555 1114846b3791800431b5720815142438d9dcc7cc
parent 125554 ce816b018b0a383e693c541342cd4cd3153f9d99
child 125556 e2e42afb0b86428d233c250983d17976291342c2
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbenadida
bugs822450
milestone20.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 822450 - Create a syntheticEventsOk pref for marionette identity tests. r=benadida
dom/identity/nsDOMIdentity.js
--- a/dom/identity/nsDOMIdentity.js
+++ b/dom/identity/nsDOMIdentity.js
@@ -4,16 +4,21 @@
 
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 const PREF_DEBUG = "toolkit.identity.debug";
 const PREF_ENABLED = "dom.identity.enabled";
 
+// Bug 822450: Workaround for Bug 821740.  When testing with marionette,
+// relax navigator.id.request's requirement that it be handling native
+// events.  Synthetic marionette events are ok.
+const PREF_SYNTHETIC_EVENTS_OK = "dom.identity.syntheticEventsOk";
+
 // Maximum length of a string that will go through IPC
 const MAX_STRING_LENGTH = 2048;
 // Maximum number of times navigator.id.request can be called for a document
 const MAX_RP_CALLS = 100;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/identity/IdentityUtils.jsm");
@@ -42,17 +47,24 @@ nsDOMIdentity.prototype = {
     raiseProvisioningFailure: 'r',
 
     // Authentication
     beginAuthentication: 'r',
     completeAuthentication: 'r',
     raiseAuthenticationFailure: 'r',
   },
 
-  // nsIDOMIdentity
+  // require native events unless syntheticEventsOk is set
+  get nativeEventsRequired() {
+    if (Services.prefs.prefHasUserValue(PREF_SYNTHETIC_EVENTS_OK)) {
+      return !Services.prefs.getBoolPref(PREF_SYNTHETIC_EVENTS_OK);
+    }
+    return true;
+  },
+
   /**
    * Relying Party (RP) APIs
    */
 
   watch: function nsDOMIdentity_watch(aOptions) {
     if (this._rpWatcher) {
       throw new Error("navigator.id.watch was already called");
     }
@@ -110,17 +122,18 @@ nsDOMIdentity.prototype = {
   request: function nsDOMIdentity_request(aOptions) {
     let util = this._window.QueryInterface(Ci.nsIInterfaceRequestor)
                            .getInterface(Ci.nsIDOMWindowUtils);
 
     // The only time we permit calling of request() outside of a user
     // input handler is when we are handling the (deprecated) get() or
     // getVerifiedEmail() calls, which make use of an RP context
     // marked as _internal.
-    if (!util.isHandlingUserInput && !aOptions._internal) {
+    if (this.nativeEventsRequired && !util.isHandlingUserInput && !aOptions._internal) {
+      this._log("request: rejecting non-native event");
       return;
     }
 
     // Has the caller called watch() before this?
     if (!this._rpWatcher) {
       throw new Error("navigator.id.request called before navigator.id.watch");
     }
     if (this._rpCalls > MAX_RP_CALLS) {