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 (2012-07-10)
changeset 11341 d310591a4249e2425ccc2f8c7870c1dcde36d0ae
parent 11340 33ab94f812758723b824cd6fedacdd87a4b70d68
child 11342 a398b69b5c9219bdac0e122671e9aef4423eb558
push id625
push usermozilla@kewis.ch
push dateTue, 10 Jul 2012 12:43:45 +0000 (2012-07-10)
treeherdercomm-aurora@d310591a4249 [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.