Backed out changesets e8d9ae8dbb72 and 58bbcf8b460a (bug 611553) for mochitest orange. a=backout
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 04 Feb 2013 22:04:38 -0500
changeset 127414 ed6e1f9f2243e7092682cd6dc2556b851d5a26ba
parent 127413 89432f14d306a42e192ab3e5f3accbbd5274bf8a
child 127415 ed165fe28804d02fef2f892c5f4fb9198454e440
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)
reviewersbackout
bugs611553
milestone20.0a2
backs oute8d9ae8dbb72c8c5f1bcbaef344abe950ba7b3bc
58bbcf8b460a78621a621945ed07574a0f07ebdf
Backed out changesets e8d9ae8dbb72 and 58bbcf8b460a (bug 611553) for mochitest orange. a=backout
embedding/components/windowwatcher/src/nsAutoWindowStateHelper.cpp
embedding/components/windowwatcher/src/nsAutoWindowStateHelper.h
mobile/android/components/PromptService.js
toolkit/components/prompts/src/nsPrompter.js
--- a/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.cpp
+++ b/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.cpp
@@ -5,25 +5,24 @@
 
 #include "nsAutoWindowStateHelper.h"
 
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMEvent.h"
 #include "nsString.h"
-#include "nsGUIEvent.h"
 
 /****************************************************************
  ****************** nsAutoWindowStateHelper *********************
  ****************************************************************/
 
 nsAutoWindowStateHelper::nsAutoWindowStateHelper(nsIDOMWindow *aWindow)
   : mWindow(aWindow),
-    mDefaultEnabled(DispatchEventToChrome("DOMWillOpenModalDialog"))
+    mDefaultEnabled(DispatchCustomEvent("DOMWillOpenModalDialog"))
 {
   nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(aWindow));
 
   if (window) {
     mCallerWindow = window->EnterModalState();
   }
 }
 
@@ -31,38 +30,23 @@ nsAutoWindowStateHelper::~nsAutoWindowSt
 {
   nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(mWindow));
 
   if (window) {
     window->LeaveModalState(mCallerWindow);
   }
 
   if (mDefaultEnabled) {
-    DispatchEventToChrome("DOMModalDialogClosed");
+    DispatchCustomEvent("DOMModalDialogClosed");
   }
 }
 
 bool
-nsAutoWindowStateHelper::DispatchEventToChrome(const char *aEventName)
+nsAutoWindowStateHelper::DispatchCustomEvent(const char *aEventName)
 {
   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mWindow);
   if (!window) {
     return true;
   }
 
-  // The functions of nsContentUtils do not provide the required behavior,
-  // so the following is inlined.
-  nsIDOMDocument* doc = window->GetExtantDocument();
-  if (!doc) {
-    return true;
-  }
+  return window->DispatchCustomEvent(aEventName);
+}
 
-  nsCOMPtr<nsIDOMEvent> event;
-  doc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
-  NS_ENSURE_TRUE(NS_SUCCEEDED(event->InitEvent(NS_ConvertASCIItoUTF16(aEventName), true, true)), false);
-  event->SetTrusted(true);
-  event->GetInternalNSEvent()->mFlags.mOnlyChromeDispatch = true;
-
-  nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(window));
-  bool defaultActionEnabled;
-  target->DispatchEvent(event, &defaultActionEnabled);
-  return defaultActionEnabled;
-}
--- a/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.h
+++ b/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.h
@@ -22,17 +22,17 @@ public:
   ~nsAutoWindowStateHelper();
 
   bool DefaultEnabled()
   {
     return mDefaultEnabled;
   }
 
 protected:
-  bool DispatchEventToChrome(const char *aEventName);
+  bool DispatchCustomEvent(const char *aEventName);
 
   nsIDOMWindow *mWindow;
   nsCOMPtr<nsIDOMWindow> mCallerWindow;
   bool mDefaultEnabled;
 };
 
 
 #endif
--- a/mobile/android/components/PromptService.js
+++ b/mobile/android/components/PromptService.js
@@ -756,19 +756,17 @@ let PromptUtils = {
 
   fireDialogEvent: function(aDomWin, aEventName) {
     // accessing the document object can throw if this window no longer exists. See bug 789888.
     try {
       if (!aDomWin.document)
         return;
       let event = aDomWin.document.createEvent("Events");
       event.initEvent(aEventName, true, true);
-      let winUtils = aDomWin.QueryInterface(Ci.nsIInterfaceRequestor)
-                           .getInterface(Ci.nsIDOMWindowUtils);
-      winUtils.dispatchEventToChromeOnly(aDomWin, event);
+      aDomWin.dispatchEvent(event);
     } catch(ex) {
     }
   }
 };
 
 XPCOMUtils.defineLazyGetter(PromptUtils, "passwdBundle", function () {
   return Services.strings.createBundle("chrome://passwordmgr/locale/passwordmgr.properties");
 });
--- a/toolkit/components/prompts/src/nsPrompter.js
+++ b/toolkit/components/prompts/src/nsPrompter.js
@@ -167,22 +167,22 @@ let PromptUtils = {
             flags >>= 8;
         }
 
         return [buttonLabels[0], buttonLabels[1], buttonLabels[2], defaultButtonNum, isDelayEnabled];
     },
 
     // Fire a dialog open/close event. Used by tabbrowser to focus the
     // tab which is triggering a prompt.
+    //
+    // Bug 611553 - should make these notifications instead of events.
     fireDialogEvent : function (domWin, eventName) {
         let event = domWin.document.createEvent("Events");
         event.initEvent(eventName, true, true);
-        let winUtils = domWin.QueryInterface(Ci.nsIInterfaceRequestor)
-                             .getInterface(Ci.nsIDOMWindowUtils);
-        winUtils.dispatchEventToChromeOnly(domWin, event);
+        domWin.dispatchEvent(event);
     },
 
     getAuthInfo : function (authInfo) {
         let username, password;
 
         let flags = authInfo.flags;
         if (flags & Ci.nsIAuthInformation.NEED_DOMAIN && authInfo.domain)
             username = authInfo.domain + "\\" + authInfo.username;