Bug 772966 - force XBL parameter names to be non-zero, r=sicking
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 02 Aug 2012 09:12:34 +0300
changeset 101162 5884240242948d90aa0bfdc80803b4a4ad853e04
parent 101161 61d7f15ea6a760def8b09109848a6dd2e6481941
child 101169 688734575830713cdee907bf4f2c519edcf51d3c
child 101308 4e43536ac5c33074de0ba828956ca18d81b8161b
push id23218
push useropettay@mozilla.com
push dateThu, 02 Aug 2012 07:24:45 +0000
treeherdermozilla-central@588424024294 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs772966
milestone17.0a1
first release with
nightly linux32
588424024294 / 17.0a1 / 20120802030533 / files
nightly linux64
588424024294 / 17.0a1 / 20120802030533 / files
nightly mac
588424024294 / 17.0a1 / 20120802030533 / files
nightly win32
588424024294 / 17.0a1 / 20120802030533 / files
nightly win64
588424024294 / 17.0a1 / 20120802030533 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 772966 - force XBL parameter names to be non-zero, r=sicking
content/xbl/src/nsXBLProtoImplMethod.cpp
content/xbl/test/Makefile.in
content/xbl/test/test_bug772966.xul
--- a/content/xbl/src/nsXBLProtoImplMethod.cpp
+++ b/content/xbl/src/nsXBLProtoImplMethod.cpp
@@ -53,16 +53,21 @@ nsXBLProtoImplMethod::AppendBodyText(con
 }
 
 void 
 nsXBLProtoImplMethod::AddParameter(const nsAString& aText)
 {
   NS_PRECONDITION(!IsCompiled(),
                   "Must not be compiled when accessing uncompiled method");
 
+  if (aText.IsEmpty()) {
+    NS_WARNING("Empty name attribute in xbl:parameter!");
+    return;
+  }
+
   nsXBLUncompiledMethod* uncompiledMethod = GetUncompiledMethod();
   if (!uncompiledMethod) {
     uncompiledMethod = new nsXBLUncompiledMethod();
     if (!uncompiledMethod)
       return;
     SetUncompiledMethod(uncompiledMethod);
   }
 
--- a/content/xbl/test/Makefile.in
+++ b/content/xbl/test/Makefile.in
@@ -41,12 +41,13 @@ MOCHITEST_FILES =	\
 
 MOCHITEST_CHROME_FILES = \
 		test_bug296375.xul \
 		test_bug378518.xul \
 		test_bug398135.xul \
 		test_bug398492.xul \
 		test_bug721452.xul \
 		test_bug723676.xul \
+		test_bug772966.xul \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
new file mode 100644
--- /dev/null
+++ b/content/xbl/test/test_bug772966.xul
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=772966
+-->
+<window title="Mozilla Bug 772966"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        onload="runTest()">
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+  <!-- test results are displayed in the html:body -->
+  <body xmlns="http://www.w3.org/1999/xhtml">
+  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=772966"
+     target="_blank">Mozilla Bug 772966</a>
+  </body>
+
+  <script>
+    function runTest() {
+      is(document.getElementById('b').test(123, 123, 123), 2, "Should have 2 params.");
+    }
+  </script>
+  
+  <box id="b" style="-moz-binding: url(#binding)"/>
+  
+  <xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl">
+    <xbl:binding id="binding">
+      <xbl:implementation>
+        <xbl:method name="test">
+          <xbl:parameter name="p1"/>
+          <xbl:parameter name=""/>
+          <xbl:parameter name="p2"/>
+          <xbl:body><![CDATA[
+            return arguments.callee.length;
+          ]]></xbl:body>
+        </xbl:method>
+      </xbl:implementation>
+    </xbl:binding>
+  </xbl:bindings>
+  
+
+</window>