diff --git a/dom/bindings/test/Makefile.in b/dom/bindings/test/Makefile.in index cb3c7ddb9f7..db9e997a867 100644 --- a/dom/bindings/test/Makefile.in +++ b/dom/bindings/test/Makefile.in @@ -58,6 +58,7 @@ $(CPPSRCS): ../%Binding.cpp: $(bindinggen_dependencies) \ _TEST_FILES = \ test_enums.html \ + test_integers.html \ test_interfaceToString.html \ test_lookupGetter.html \ test_InstanceOf.html \ diff --git a/dom/bindings/test/test_integers.html b/dom/bindings/test/test_integers.html new file mode 100644 index 00000000000..1db0867ac2a --- /dev/null +++ b/dom/bindings/test/test_integers.html @@ -0,0 +1,39 @@ + + + + + + + + +

+ +
+
+
+ + diff --git a/js/xpconnect/src/xpcpublic.h b/js/xpconnect/src/xpcpublic.h index 22d271ed6ee..3868963e16b 100644 --- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -22,6 +22,7 @@ #include "nsStringGlue.h" #include "nsTArray.h" #include "mozilla/dom/DOMJSClass.h" +#include "nsMathUtils.h" class nsIPrincipal; class nsIXPConnectWrappedJS; @@ -284,7 +285,12 @@ ValueToInt64(JSContext *cx, JS::Value v, int64_t *result) double doubleval; if (!JS_ValueToNumber(cx, v, &doubleval)) return false; - *result = static_cast(doubleval); + // Be careful with non-finite doubles + if (NS_finite(doubleval)) + // XXXbz this isn't quite right either; need to do the mod thing + *result = static_cast(doubleval); + else + *result = 0; } return true; } @@ -304,7 +310,12 @@ ValueToUint64(JSContext *cx, JS::Value v, uint64_t *result) double doubleval; if (!JS_ValueToNumber(cx, v, &doubleval)) return false; - *result = static_cast(doubleval); + // Be careful with non-finite doubles + if (NS_finite(doubleval)) + // XXXbz this isn't quite right either; need to do the mod thing + *result = static_cast(doubleval); + else + *result = 0; } return true; }