Bug 518155: closing the browser while an alert is displayed hang the application [r=mark.finkle]
authorVivien Nicolas <21@vingtetun.org>
Tue, 22 Sep 2009 22:28:18 -0400
changeset 65598 97d6977708b305b33caa6469ae2f50d86a50874d
parent 65597 a63248f4e3ea6d288276da56dbffd39e5ea8dd8b
child 65599 3d229247ecda3ada45a123e6c77f1e39b18a877f
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmark
bugs518155
Bug 518155: closing the browser while an alert is displayed hang the application [r=mark.finkle]
mobile/chrome/content/bindings/dialog.xml
--- a/mobile/chrome/content/bindings/dialog.xml
+++ b/mobile/chrome/content/bindings/dialog.xml
@@ -10,17 +10,17 @@
         <xul:box xbl:inherits="orient" class="dialog-dark" align="center">
           <children/>
         </xul:box>
         <xul:image collapsed="true" top="-10" left="0" anonid="close" class="close-button"
           onclick="document.getBindingParent(this).close()"/>
       </xul:stack>
     </content>
     
-    <implementation>
+    <implementation implements="nsIDOMEventListener">
       <field name="arguments"/>
       
       <constructor><![CDATA[
         if (!this.hasAttribute("orient"))
           this.setAttribute("orient", "vertical");
         if (this.hasAttribute("closebutton") && (this.getAttribute("closebutton") == "true"))
           document.getAnonymousElementByAttribute(this, "anonid", "close").removeAttribute("collapsed");
         this._closed = false;
@@ -28,35 +28,44 @@
           try {
             let loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
                          .getService(Components.interfaces.mozIJSSubScriptLoader); 
             loader.loadSubScript(this.getAttribute("script"), this);
           } catch(e) {
             throw("Dialog : Unable to load script : " + this.getAttribute("script") + "\n");
           }
         }
+        window.addEventListener("unload", this, true);
         ]]>
       </constructor>
+
+      <method name="handleEvent">
+        <parameter name="aEvent"/>
+        <body>
+          if (aEvent.type == "unload")
+            this._closed = true;
+        </body>
+      </method>
       
       <method name="close">
         <body>
           if (this.hasAttribute("onclose")) {
             var f = new Function(this.getAttribute("onclose"));
             f.call(this);
           }
           this.parentNode.parentNode.removeChild(this.parentNode);
           this._closed = true;
         </body>
       </method>
       
       <method name="waitForClose">
         <body>
-        let thread = Components.classes["@mozilla.org/thread-manager;1"]
-                        .getService(Components.interfaces.nsIThreadManager)
-                        .currentThread;
-        while (!this._closed)
-          thread.processNextEvent(true);
+          let thread = Components.classes["@mozilla.org/thread-manager;1"]
+                          .getService(Components.interfaces.nsIThreadManager)
+                          .currentThread;
+          while (!this._closed)
+            thread.processNextEvent(true);
         </body>
       </method>
     </implementation>
   </binding>
   
 </bindings>