Fix bug 769938 - calDateTime returns invalid nativeTime property with dates before 1970 (testcase). r=philipp,a=philipp
authorStefan Sitter <ssiter@gmail.com>
Tue, 10 Jul 2012 14:42:30 +0200
changeset 11938 54af1cafd26ab26d052677693cf6c3f41e2f1bd7
parent 11937 0fd3cafc752085ee49452781a3e16e2c9d1c921f
child 11939 377dfc6ab29f6a385d903831c7300dbf47afb66c
push id587
push usermozilla@kewis.ch
push dateTue, 10 Jul 2012 12:44:16 +0000
treeherdercomm-beta@54af1cafd26a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp, philipp
bugs769938
Fix bug 769938 - calDateTime returns invalid nativeTime property with dates before 1970 (testcase). r=philipp,a=philipp
calendar/test/unit/test_datetime_before_1970.js
calendar/test/unit/xpcshell.ini
new file mode 100644
--- /dev/null
+++ b/calendar/test/unit/test_datetime_before_1970.js
@@ -0,0 +1,33 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+function run_test() {
+
+    // Bug 769938 - dates before 1970 are not handled correctly
+    // due to signed vs. unsigned mismatch in PRTime in xpconnect
+
+    let dateTime1950 = cal.createDateTime();
+    dateTime1950.year = 1950;
+    do_check_eq(dateTime1950.year, 1950);
+
+    let dateTime1955 = cal.createDateTime();
+    dateTime1955.jsDate = new Date(1955, 06, 15);
+    do_check_eq(dateTime1955.year, 1955);
+    
+    let dateTime1965 = cal.createDateTime();
+    dateTime1965.nativeTime = -150000000000000;
+    do_check_eq(dateTime1965.year, 1965);
+    do_check_eq(dateTime1965.nativeTime, -150000000000000);
+
+    let dateTime1990 = cal.createDateTime();
+    dateTime1990.year = 1990;
+
+    let dateTime2050 = cal.createDateTime();
+    dateTime2050.year = 2050;
+
+    do_check_true(dateTime1950.nativeTime < dateTime1955.nativeTime);
+    do_check_true(dateTime1955.nativeTime < dateTime1965.nativeTime);
+    do_check_true(dateTime1965.nativeTime < dateTime1990.nativeTime);
+    do_check_true(dateTime1990.nativeTime < dateTime2050.nativeTime);
+}
--- a/calendar/test/unit/xpcshell.ini
+++ b/calendar/test/unit/xpcshell.ini
@@ -11,16 +11,17 @@ tail =
 [test_bug356207.js]
 [test_bug485571.js]
 [test_bug486186.js]
 [test_bug494140.js]
 [test_bug523860.js]
 [test_bug653924.js]
 [test_bug668222.js]
 [test_datetime.js]
+[test_datetime_before_1970.js]
 [test_freebusy.js]
 [test_hashedarray.js]
 [test_ics.js]
 [test_providers.js]
 [test_recur.js]
 [test_relation.js]
 
 # Bug 680201 Skip this test because it doesn't work properly yet.