Bug 760076 - Make |construct| use Wrapper::CALL. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Thu, 31 May 2012 18:36:15 +0200
changeset 95378 d3d7c919fb500de1da3c9f6b2bbdb513572c05e9
parent 95377 cef3bda40d408055d940eff66fe6c96bdee6cf1d
child 95379 33e2ec97908178a9e06ec54a7bc170045fedfa9a
push id1116
push userlsblakk@mozilla.com
push dateMon, 16 Jul 2012 19:38:18 +0000
treeherdermozilla-esr52@26dcd1b1a208 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs760076
milestone15.0a1
Bug 760076 - Make |construct| use Wrapper::CALL. r=mrbkap
js/src/jswrapper.cpp
js/xpconnect/tests/chrome/Makefile.in
js/xpconnect/tests/chrome/test_bug760076.xul
--- a/js/src/jswrapper.cpp
+++ b/js/src/jswrapper.cpp
@@ -214,17 +214,17 @@ Wrapper::call(JSContext *cx, JSObject *w
     CHECKED(IndirectProxyHandler::call(cx, wrapper, argc, vp), CALL);
 }
 
 bool
 Wrapper::construct(JSContext *cx, JSObject *wrapper, unsigned argc, Value *argv, Value *vp)
 {
     vp->setUndefined(); // default result if we refuse to perform this action
     const jsid id = JSID_VOID;
-    GET(IndirectProxyHandler::construct(cx, wrapper, argc, argv, vp));
+    CHECKED(IndirectProxyHandler::construct(cx, wrapper, argc, argv, vp), CALL);
 }
 
 bool
 Wrapper::nativeCall(JSContext *cx, JSObject *wrapper, Class *clasp, Native native, CallArgs args)
 {
     const jsid id = JSID_VOID;
     CHECKED(IndirectProxyHandler::nativeCall(cx, wrapper, clasp, native, args), CALL);
 }
--- a/js/xpconnect/tests/chrome/Makefile.in
+++ b/js/xpconnect/tests/chrome/Makefile.in
@@ -43,16 +43,17 @@ include $(topsrcdir)/config/rules.mk
 		test_precisegc.xul \
 		test_nodelists.xul \
 		test_getweakmapkeys.xul \
 		test_weakmaps.xul \
 		test_exnstack.xul \
 		test_weakref.xul \
 		test_bug726949.xul \
 		test_bug758563.xul \
+		test_bug760076.xul \
 		$(NULL)
 
 # Disabled until this test gets updated to test the new proxy based
 # wrappers.
 #		test_wrappers-2.xul \
 
 # Disabled due to apparent conservative stack scanner false positives on Linux64 debug.
 #		test_watchpoints.xul \
new file mode 100644
--- /dev/null
+++ b/js/xpconnect/tests/chrome/test_bug760076.xul
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=760076
+-->
+<window title="Mozilla Bug 760076"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+  <!-- 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=760076"
+     target="_blank">Mozilla Bug 760076</a>
+  </body>
+
+  <!-- test code goes here -->
+  <script type="application/javascript">
+  <![CDATA[
+  /** Test for constructing COW-ed functions in content. **/
+
+  // This gets decompiled and run in the sandbox.
+  function sandboxCode() {
+    try {
+      is(chromeFunction(), 42, "Should call successfully");
+    } catch(e) { ok(false, "Shouldn't throw when calling"); }
+
+    try {
+      ok(typeof (new chromeFunction()) !== 'undefined',
+         "Should construct successfully");
+    } catch(e) { ok(false, "Shouldn't throw when constructing"); }
+  }
+
+  // Set up the sandbox.
+  const Cu = Components.utils;
+  var sb = new Cu.Sandbox('http://www.example.com');
+
+  // Import the functions it needs.
+  sb.ok = ok;
+  sb.is = is;
+  sb.chromeFunction = function() { ok(true, "Called chrome function"); return 42; }
+  Cu.evalInSandbox(sandboxCode.toSource(), sb);
+
+  // Do the test.
+  Cu.evalInSandbox("sandboxCode();", sb);
+
+  ]]>
+  </script>
+</window>