Bug 721452, crash writing to startup cache when empty handler is used, r=bz
authorNeil Deakin <neil@mozilla.com>
Mon, 13 Feb 2012 14:24:28 -0500
changeset 86737 862dec07105b34e7701b06dece9658bc1a019021
parent 86736 2986d2923fa92a0ef2de26f9797094ce22ceb757
child 86738 a98cf6ce2f0a09eebc150b49beedd18217e7ad9e
push idunknown
push userunknown
push dateunknown
reviewersbz
bugs721452
milestone13.0a1
Bug 721452, crash writing to startup cache when empty handler is used, r=bz
content/xbl/src/nsXBLPrototypeHandler.cpp
content/xbl/test/Makefile.in
content/xbl/test/test_bug721452.xul
--- a/content/xbl/src/nsXBLPrototypeHandler.cpp
+++ b/content/xbl/src/nsXBLPrototypeHandler.cpp
@@ -1069,17 +1069,17 @@ nsXBLPrototypeHandler::Read(nsIScriptCon
   return NS_OK;
 }
 
 nsresult
 nsXBLPrototypeHandler::Write(nsIScriptContext* aContext, nsIObjectOutputStream* aStream)
 {
   // Make sure we don't write out NS_HANDLER_TYPE_XUL types, as they are used
   // for <keyset> elements.
-  if (mType & NS_HANDLER_TYPE_XUL)
+  if ((mType & NS_HANDLER_TYPE_XUL) || !mEventName)
     return NS_OK;
 
   XBLBindingSerializeDetails type = XBLBinding_Serialize_Handler;
 
   nsresult rv = aStream->Write8(type);
   rv = aStream->Write8(mPhase);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = aStream->Write8(mKeyMask);
--- a/content/xbl/test/Makefile.in
+++ b/content/xbl/test/Makefile.in
@@ -74,16 +74,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug639338.xhtml \
 		$(NULL)
 
 _CHROME_FILES = \
 		test_bug296375.xul \
 		test_bug378518.xul \
 		test_bug398135.xul \
 		test_bug398492.xul \
+		test_bug721452.xul \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
 libs:: $(_CHROME_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
 
new file mode 100644
--- /dev/null
+++ b/content/xbl/test/test_bug721452.xul
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
+
+<script>
+ok(true, "Handler with empty action didn't crash")
+</script>
+
+<body xmlns="http://www.w3.org/1999/xhtml"/>
+
+<box style="-moz-binding: url(#binding)"/>
+
+<xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl">
+  <xbl:binding id="binding">
+    <xbl:content/>
+    <xbl:handlers>
+      <xbl:handler nt="action" action=""/>
+    </xbl:handlers>
+  </xbl:binding>
+</xbl:bindings>
+
+</window>