Bug 581769 - fix JS_ValueToId on xml object. remove spurious iterator assert (r=waldo)
authorLuke Wagner <lw@mozilla.com>
Mon, 26 Jul 2010 17:05:17 -0700
changeset 48591 7ff4f93bddaa2d19f603d0672c3fdbaec7f6157f
parent 48590 898b2067238343af56dcdd887dcc8a18d85183ec
child 48592 01fb7a9e1ae4f780e270c2a044cb22729319923a
push id14748
push userrsayre@mozilla.com
push dateSun, 01 Aug 2010 00:33:23 +0000
treeherdermozilla-central@f0df797bb2a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs581769
milestone2.0b2pre
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 581769 - fix JS_ValueToId on xml object. remove spurious iterator assert (r=waldo)
js/src/jsinterp.cpp
js/src/jsiter.cpp
js/src/jsobj.h
js/src/jsxml.h
js/src/trace-test/tests/basic/testXMLPropertyNames.js
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -1205,24 +1205,20 @@ ValueToId(JSContext *cx, const Value &v,
     if (ValueFitsInInt32(v, &i) && INT_FITS_IN_JSID(i)) {
         *idp = INT_TO_JSID(i);
         return true;
     }
 
 #if JS_HAS_XML_SUPPORT
     if (v.isObject()) {
         JSObject *obj = &v.toObject();
-        if (obj->isXML()) {
+        if (obj->isXMLId()) {
             *idp = OBJECT_TO_JSID(obj);
             return JS_TRUE;
         }
-        if (!js_IsFunctionQName(cx, obj, idp))
-            return JS_FALSE;
-        if (!JSID_IS_VOID(*idp))
-            return JS_TRUE;
     }
 #endif
 
     return js_ValueToStringId(cx, v, idp);
 }
 
 } /* namespace js */
 
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -198,18 +198,16 @@ struct ValueEnumeration
 };
 
 template <class EnumPolicy>
 static inline bool
 Enumerate(JSContext *cx, JSObject *obj, JSObject *pobj, jsid id,
           bool enumerable, bool sharedPermanent, uintN flags, IdSet& ht,
           typename EnumPolicy::ResultVector &props)
 {
-    JS_ASSERT(JSID_IS_INT(id) || JSID_IS_ATOM(id));
-
     IdSet::AddPtr p = ht.lookupForAdd(id);
     JS_ASSERT_IF(obj == pobj && !obj->isProxy(), !p);
 
     /* If we've already seen this, we definitely won't add it. */
     if (JS_UNLIKELY(!!p))
         return true;
 
     /*
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -729,16 +729,17 @@ struct JSObject {
     inline bool isNumber() const;
     inline bool isBoolean() const;
     inline bool isString() const;
     inline bool isPrimitive() const;
     inline bool isDate() const;
     inline bool isFunction() const;
     inline bool isRegExp() const;
     inline bool isXML() const;
+    inline bool isXMLId() const;
     inline bool isNamespace() const;
     inline bool isQName() const;
 
     inline bool isProxy() const;
     inline bool isObjectProxy() const;
     inline bool isFunctionProxy() const;
 
     JS_FRIEND_API(bool) isWrapper() const;
--- a/js/src/jsxml.h
+++ b/js/src/jsxml.h
@@ -228,16 +228,25 @@ extern js::Class                        
  * Methods to test whether an object or a value is of type "xml" (per typeof).
  */
 inline bool
 JSObject::isXML() const
 {
     return map->ops == &js_XMLObjectOps;
 }
 
+inline bool
+JSObject::isXMLId() const
+{
+    js::Class *clasp = getClass();
+    return clasp == &js_QNameClass.base ||
+           clasp == &js_AttributeNameClass ||
+           clasp == &js_AnyNameClass;
+}
+
 #define VALUE_IS_XML(v)      (!JSVAL_IS_PRIMITIVE(v) && JSVAL_TO_OBJECT(v)->isXML())
 
 inline bool
 JSObject::isNamespace() const
 {
     return getClass() == &js_NamespaceClass.base;
 }
 
new file mode 100644
--- /dev/null
+++ b/js/src/trace-test/tests/basic/testXMLPropertyNames.js
@@ -0,0 +1,11 @@
+var o = {};
+
+o.__defineGetter__(<x/>,function(){});
+<a b="2"/>.(o.__defineGetter__(new QName("foo"), function(){}));
+
+var i = 0;
+for (w in o) {
+    ++i;
+}
+
+assertEq(i, 2);