Bug 564330 - Throw an exception for real when an E4X object is passed to a variant through a quickstub. r=peterv
authorBlake Kaplan <mrbkap@gmail.com>
Thu, 13 May 2010 14:35:01 -0700
changeset 43642 916d5f32ee8ecf8c8cedf9a3846f5f07608e26bc
parent 43641 33bd3f2338e3e87cb7aeee7dca3248e22dc10b68
child 43643 a04f9b84746fcf35f8e5515a71c71e7b6a28c525
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerspeterv
bugs564330
milestone1.9.3a6pre
Bug 564330 - Throw an exception for real when an E4X object is passed to a variant through a quickstub. r=peterv
js/src/xpconnect/src/qsgen.py
js/src/xpconnect/tests/mochitest/Makefile.in
js/src/xpconnect/tests/mochitest/test_bug564330.html
--- a/js/src/xpconnect/src/qsgen.py
+++ b/js/src/xpconnect/src/qsgen.py
@@ -531,18 +531,20 @@ def writeArgumentUnboxing(f, i, name, ty
         # else fall through; the type isn't supported yet.
     elif isInterfaceType(type):
         if type.name == 'nsIVariant':
             # Totally custom.
             assert haveCcx
             template = (
                 "    nsCOMPtr<nsIVariant> ${name}(already_AddRefed<nsIVariant>("
                 "XPCVariant::newVariant(ccx, ${argVal})));\n"
-                "    if (!${name})\n"
-                "        return JS_FALSE;\n")
+                "    if (!${name}) {\n"
+                "        xpc_qsThrowBadArgWithCcx(ccx, NS_ERROR_XPC_BAD_CONVERT_JS, %d);\n"
+                "        return JS_FALSE;\n"
+                "    }") % i
             f.write(substitute(template, params))
             return rvdeclared
         elif type.name == 'nsIAtom':
             # Should have special atomizing behavior.  Fall through.
             pass
         else:
             if not rvdeclared:
                 f.write("    nsresult rv;\n");
--- a/js/src/xpconnect/tests/mochitest/Makefile.in
+++ b/js/src/xpconnect/tests/mochitest/Makefile.in
@@ -67,14 +67,15 @@ include $(topsrcdir)/config/rules.mk
 		test_bug500691.html \
 		test_bug502959.html \
 		test_bug503926.html \
 		test_bug504877.html \
 		test_bug505915.html \
 		test_bug517163.html \
 		test_bug553407.html \
 		test_bug560351.html \
+		test_bug564330.html \
 		test_cows.html \
 		test_frameWrapping.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/js/src/xpconnect/tests/mochitest/test_bug564330.html
@@ -0,0 +1,38 @@
+
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=564330
+-->
+<head>
+  <title>Test for Bug 560351</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=564330">Mozilla Bug 564330</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 564330 **/
+var pass = false;
+try {
+    document.createElement("span").setUserData("x", <y/>, null);
+} catch (e) {
+    pass = true;
+}
+
+</script>
+<script>
+
+ok(pass, "pass was set to true");
+
+</script>
+</pre>
+</body>
+</html>