Back out bug 844630 (7cdeee48963c) for being completely busted (and causing bug 848302). r=me
authorJustin Lebar <justin.lebar@gmail.com>
Wed, 06 Mar 2013 12:40:23 -0500
changeset 135204 fdc942a65143f54fafb00381ac9302065b5626b4
parent 135203 d5e45282bdcda52c3353f1f970842e45fcde0b4b
child 135205 a9533266197d4106fd70e628a2139dc984824146
push id336
push userakeybl@mozilla.com
push dateMon, 17 Jun 2013 22:53:19 +0000
treeherdermozilla-release@574a39cdf657 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs844630, 848302
milestone22.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
Back out bug 844630 (7cdeee48963c) for being completely busted (and causing bug 848302). r=me
dom/browser-element/BrowserElementPromptService.jsm
--- a/dom/browser-element/BrowserElementPromptService.jsm
+++ b/dom/browser-element/BrowserElementPromptService.jsm
@@ -452,26 +452,34 @@ AuthPromptWrapper.prototype = {
       return true;
     } catch (e) {
       return false;
     }
   }
 };
 
 function BrowserElementPromptFactory(toWrap) {
-  // this._wrapped may be null.
   this._wrapped = toWrap;
 }
 
 BrowserElementPromptFactory.prototype = {
   classID: Components.ID("{24f3d0cf-e417-4b85-9017-c9ecf8bb1299}"),
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIPromptFactory]),
 
+  _mayUseNativePrompt: function() {
+    try {
+      return Services.prefs.getBoolPref("browser.prompt.allowNative");
+    } catch (e) {
+      // This properity is default to true.
+      return true;
+    }
+  },
+
   _getNativePromptIfAllowed: function(win, iid, err) {
-    if (this._wrapped)
+    if (this._mayUseNativePrompt())
       return this._wrapped.getPrompt(win, iid);
     else {
       // Not allowed, throw an exception.
       throw err;
     }
   },
 
   getPrompt: function(win, iid) {
@@ -504,17 +512,17 @@ BrowserElementPromptFactory.prototype = 
         return new BrowserElementAuthPrompt().QueryInterface(iid);
       }
 
       // Because nsIAuthPrompt2 is called in parent process. If caller
       // wants nsIAuthPrompt2 and we cannot get BrowserElementchild,
       // it doesn't mean that we should fallback. It is possible that we can
       // get the BrowserElementParent from nsIChannel that passed to
       // functions of nsIAuthPrompt2.
-      if (this._wrapped) {
+      if (this._mayUseNativePrompt()) {
         return new AuthPromptWrapper(
             this._wrapped.getPrompt(win, iid),
             new BrowserElementAuthPrompt().QueryInterface(iid))
           .QueryInterface(iid);
       } else {
         // Falling back is not allowed, so we don't need wrap the
         // BrowserElementPrompt.
         return new BrowserElementAuthPrompt().QueryInterface(iid);
@@ -534,25 +542,16 @@ BrowserElementPromptFactory.prototype = 
 };
 
 this.BrowserElementPromptService = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
                                          Ci.nsISupportsWeakReference]),
 
   _initialized: false,
 
-  _mayUseNativePrompt: function() {
-    try {
-      return Services.prefs.getBoolPref("browser.prompt.allowNative");
-    } catch (e) {
-      // This properity defaults to true.
-      return true;
-    }
-  },
-
   _init: function() {
     if (this._initialized) {
       return;
     }
 
     // If the pref is disabled, do nothing except wait for the pref to change.
     if (!this._browserFramesPrefEnabled()) {
       var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
@@ -561,37 +560,31 @@ this.BrowserElementPromptService = {
     }
 
     this._initialized = true;
     this._browserElementParentMap = new WeakMap();
 
     var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
     os.addObserver(this, "outer-window-destroyed", /* ownsWeak = */ true);
 
-    var oldPromptFactory = null;
+    // Wrap the existing @mozilla.org/prompter;1 implementation.
+    var contractID = "@mozilla.org/prompter;1";
+    var oldCID = Cm.contractIDToCID(contractID);
     var newCID = BrowserElementPromptFactory.prototype.classID;
-    if (this._mayUseNativePrompt()) {
-      // Wrap the existing @mozilla.org/prompter;1 implementation.  (Don't even
-      // try to get the prompter;1 if we may not use the native prompter.  We
-      // won't need it, and merely getting it is causing bug 844530.)
-      var contractID = "@mozilla.org/prompter;1";
-      var oldCID = Cm.contractIDToCID(contractID);
-      var oldFactory = Cm.getClassObject(Cc[contractID], Ci.nsIFactory);
+    var oldFactory = Cm.getClassObject(Cc[contractID], Ci.nsIFactory);
 
-      if (oldCID == newCID) {
-        debug("WARNING: Wrapped prompt factory is already installed!");
-        return;
-      }
-
-      Cm.unregisterFactory(oldCID, oldFactory);
-
-      oldPromptFactory = oldFactory.createInstance(null, Ci.nsIPromptFactory);
+    if (oldCID == newCID) {
+      debug("WARNING: Wrapped prompt factory is already installed!");
+      return;
     }
 
-    var newInstance = new BrowserElementPromptFactory(oldPromptFactory);
+    Cm.unregisterFactory(oldCID, oldFactory);
+
+    var oldInstance = oldFactory.createInstance(null, Ci.nsIPromptFactory);
+    var newInstance = new BrowserElementPromptFactory(oldInstance);
 
     var newFactory = {
       createInstance: function(outer, iid) {
         if (outer != null) {
           throw Cr.NS_ERROR_NO_AGGREGATION;
         }
         return newInstance.QueryInterface(iid);
       }