Bug 635068 - WebGL test array-unit-tests.html fails - r=dmandelin+vlad, a=blocking2.0
authorBenoit Jacob <bjacob@mozilla.com>
Thu, 03 Mar 2011 11:02:35 -0500
changeset 63318 fb4921333812
parent 63317 195a7aceb72b
child 63319 646c6004d9d6
push idunknown
push userunknown
push dateunknown
reviewersdmandelin, blocking2
bugs635068
milestone2.0b13pre
Bug 635068 - WebGL test array-unit-tests.html fails - r=dmandelin+vlad, a=blocking2.0
js/src/jstypedarray.cpp
--- a/js/src/jstypedarray.cpp
+++ b/js/src/jstypedarray.cpp
@@ -1116,17 +1116,21 @@ class TypedArrayTemplate
     {
         if (v.isInt32())
             return NativeType(v.toInt32());
 
         if (v.isDouble()) {
             double d = v.toDouble();
             if (!ArrayTypeIsFloatingPoint() && JS_UNLIKELY(JSDOUBLE_IS_NaN(d)))
                 return NativeType(int32(0));
-            return NativeType(d);
+            if (TypeIsFloatingPoint<NativeType>())
+                return NativeType(d);
+            if (TypeIsUnsigned<NativeType>())
+                return NativeType(js_DoubleToECMAUint32(d));
+            return NativeType(js_DoubleToECMAInt32(d));
         }
 
         if (v.isPrimitive() && !v.isMagic()) {
             jsdouble dval;
             ValueToNumber(cx, v, &dval);
             return NativeType(dval);
         }