Bug 518155: closing the browser while an alert is displayed hang the application [r=mark.finkle]
--- 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>