Bug 614603 - RegExp.length and Error.length don't have their ES5-specified values. r=jwalden
authorJan de Mooij <jandemooij@gmail.com>
Wed, 24 Nov 2010 19:18:59 +0100
changeset 58297 91c193d27482d84d44a0d3a98fff7c2d58db8d98
parent 58296 1b24f8e54d1b9ea9d9f1b9a46e0b1eceafdfe649
child 58298 2000c21b7910d18da2319f63751ab7a6f73a12f9
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersjwalden
bugs614603
milestone2.0b8pre
Bug 614603 - RegExp.length and Error.length don't have their ES5-specified values. r=jwalden
js/src/jsexn.cpp
js/src/jsregexp.cpp
js/src/tests/ecma_5/RegExp/15.10.5-01.js
js/src/tests/ecma_5/RegExp/jstests.list
js/src/tests/js1_5/Exceptions/regress-123002.js
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -1031,17 +1031,17 @@ js_InitExceptionClasses(JSContext *cx, J
 
         /* So exn_finalize knows whether to destroy private data. */
         proto->setPrivate(NULL);
 
         /* Make a constructor function for the current name. */
         JSProtoKey protoKey = GetExceptionProtoKey(i);
         
         jsid id = ATOM_TO_JSID(cx->runtime->atomState.classAtoms[protoKey]);
-        JSFunction *fun = js_DefineFunction(cx, obj, id, Exception, 3, JSFUN_CONSTRUCTOR);
+        JSFunction *fun = js_DefineFunction(cx, obj, id, Exception, 1, JSFUN_CONSTRUCTOR);
         if (!fun)
             return NULL;
         roots[2] = OBJECT_TO_JSVAL(FUN_OBJECT(fun));
 
         /* Make this constructor make objects of class Exception. */
         FUN_CLASP(fun) = &js_ErrorClass;
 
         /* Make the prototype and constructor links. */
--- a/js/src/jsregexp.cpp
+++ b/js/src/jsregexp.cpp
@@ -880,17 +880,17 @@ InitRegExpClassCompile(JSContext *cx, JS
         return false;
     SwapObjectRegExp(cx, obj, *re);
     return true;
 }
 
 JSObject *
 js_InitRegExpClass(JSContext *cx, JSObject *obj)
 {
-    JSObject *proto = js_InitClass(cx, obj, NULL, &js_RegExpClass, regexp_construct, 1,
+    JSObject *proto = js_InitClass(cx, obj, NULL, &js_RegExpClass, regexp_construct, 2,
                                    NULL, regexp_methods, regexp_static_props, NULL);
     if (!proto)
         return NULL;
 
     JSObject *ctor = JS_GetConstructor(cx, proto);
     if (!ctor)
         return NULL;
 
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_5/RegExp/15.10.5-01.js
@@ -0,0 +1,21 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+var BUGNUMBER = 614603;
+var summary = "RegExp.length";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+assertEq(RegExp.length, 2);
+assertEq(/a/.constructor.length, 2);
+
+if (typeof reportCompare === "function")
+  reportCompare(true, true);
+
+print("All tests passed!");
--- a/js/src/tests/ecma_5/RegExp/jstests.list
+++ b/js/src/tests/ecma_5/RegExp/jstests.list
@@ -1,2 +1,3 @@
 url-prefix ../../jsreftest.html?test=ecma_5/RegExp/
+script 15.10.5-01.js
 script 15.10.7.5-01.js
--- a/js/src/tests/js1_5/Exceptions/regress-123002.js
+++ b/js/src/tests/js1_5/Exceptions/regress-123002.js
@@ -53,34 +53,29 @@
  * SpiderMonkey: new Error (message, fileName, lineNumber)
  *
  * NOTE: since we have hard-coded the length expectations, this testcase will
  * have to be changed if the Error FormalParameterList is ever changed again.
  *
  * To do this, just change the two LENGTH constants below -
  */
 //-----------------------------------------------------------------------------
-var LENGTH_RHINO = 1;
-var LENGTH_SPIDERMONKEY = 3;
 var UBound = 0;
 var BUGNUMBER = 123002;
 var summary = 'Testing Error.length';
 var QUOTE = '"';
 var status = '';
 var statusitems = [];
 var actual = '';
 var actualvalues = [];
 var expect= '';
 var expectedvalues = [];
 
 
-/*
- * Are we in Rhino or SpiderMonkey?
- */
-var LENGTH_EXPECTED = inRhino()? LENGTH_RHINO : LENGTH_SPIDERMONKEY;
+var LENGTH_EXPECTED = 1;
 
 /*
  * The various NativeError objects; see ECMA-262 Edition 3, Section 15.11.6
  */
 var errObjects = [new Error(), new EvalError(), new RangeError(),
 		  new ReferenceError(), new SyntaxError(), new TypeError(), new URIError()];