Bug 818379. Make sure interface objects have a 'length' property even if they're not real function objects. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 14 Dec 2012 14:10:49 -0500
changeset 125207 53b604b60d25c9a2b22e8347df04bee704ab4366
parent 125206 c833cab38b083cdca0521eb057ed5bd5a19d6014
child 125208 a54055d75da754d4815c2712fb988dfa061adbd4
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs818379
milestone20.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 818379. Make sure interface objects have a 'length' property even if they're not real function objects. r=peterv
dom/bindings/BindingUtils.cpp
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -266,16 +266,21 @@ CreateInterfaceObject(JSContext* cx, JSO
                                   PRIVATE_TO_JSVAL(constructorClass));
 
     JSString *str = ::JS_InternString(cx, name);
     if (!str) {
       return NULL;
     }
     js::SetFunctionNativeReserved(toStringObj, TOSTRING_NAME_RESERVED_SLOT,
                                   STRING_TO_JSVAL(str));
+
+    if (!JS_DefineProperty(cx, constructor, "length", JS::Int32Value(ctorNargs),
+                           nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT)) {
+      return NULL;
+    }
   }
 
   if (properties) {
     if (properties->staticMethods &&
         !DefinePrefable(cx, constructor, properties->staticMethods)) {
       return nullptr;
     }