Bug 689285 - Make [[ThrowTypeError]] properly non-extensible. r=luke
authorJeff Walden <jwalden@mit.edu>
Mon, 26 Sep 2011 13:59:23 -0700
changeset 77635 ed95d68c0f85cceac8c667277e7578792f80aeb0
parent 77634 aac6292d29f9f362f7b353236310ad4666936373
child 77636 c4b5ba89b4b7ae9a7d765ebbdd24b5b9ed15a1a2
push id21221
push userbzbarsky@mozilla.com
push dateTue, 27 Sep 2011 07:08:27 +0000
treeherdermozilla-central@d305835a6726 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs689285
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 689285 - Make [[ThrowTypeError]] properly non-extensible. r=luke
js/src/tests/ecma_5/Function/function-caller.js
js/src/vm/GlobalObject.cpp
--- a/js/src/tests/ecma_5/Function/function-caller.js
+++ b/js/src/tests/ecma_5/Function/function-caller.js
@@ -63,14 +63,25 @@ assertEq(bazCaller.set, canonicalTTE);
 
 var bazArguments = Object.getOwnPropertyDescriptor(baz, "arguments");
 assertEq("get" in bazArguments, true);
 assertEq("set" in bazArguments, true);
 assertEq(bazArguments.get, canonicalTTE);
 assertEq(bazArguments.set, canonicalTTE);
 
 
+// [[ThrowTypeError]] characteristics
+
+assertEq(Object.prototype.toString.call(canonicalTTE), "[object Function]");
+assertEq(Object.getPrototypeOf(canonicalTTE), Function.prototype);
+assertEq(canonicalTTE.length, 0);
+assertEq(Object.isExtensible(canonicalTTE), false);
+canonicalTTE.lumpy = 17;
+assertEq(canonicalTTE.hasOwnProperty("lumpy"), false);
+assertEq("lumpy" in canonicalTTE, false);
+expectTypeError(function setTTEProp() { "use strict"; canonicalTTE.x = 42; });
+
 /******************************************************************************/
 
 if (typeof reportCompare === "function")
   reportCompare(true, true);
 
 print("All tests passed!");
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -220,16 +220,19 @@ GlobalObject::initFunctionAndObjectClass
     if (!evalobj)
         return NULL;
     setOriginalEval(evalobj);
 
     /* ES5 13.2.3: Construct the unique [[ThrowTypeError]] function object. */
     JSFunction *throwTypeError = js_NewFunction(cx, NULL, ThrowTypeError, 0, 0, this, NULL);
     if (!throwTypeError)
         return NULL;
+    AutoIdVector ids(cx);
+    if (!throwTypeError->preventExtensions(cx, &ids))
+        return NULL;
     setThrowTypeError(throwTypeError);
 
     /*
      * The global object should have |Object.prototype| as its [[Prototype]].
      * Eventually we'd like to have standard classes be there from the start,
      * and thus we would know we were always setting what had previously been a
      * null [[Prototype]], but right now some code assumes it can set the
      * [[Prototype]] before standard classes have been initialized.  For now,