author | Sankha Narayan Guria <sankha93@gmail.com> |
Tue, 02 Jul 2013 23:59:58 +0530 | |
changeset 149535 | 23b2e4f985914b8b74797c210e56be5222ebb2ea |
parent 149534 | 796773a10db13eec7601a23c73fb30c98c9adee5 |
child 149536 | 099ffd0d0d3787f9affb65b01ad2e5f3410b6b7e |
push id | 2859 |
push user | akeybl@mozilla.com |
push date | Mon, 16 Sep 2013 19:14:59 +0000 |
treeherder | mozilla-beta@87d3c51cd2bf [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | nsm |
bugs | 877888 |
milestone | 25.0a1 |
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
|
dom/alarm/AlarmService.jsm | file | annotate | diff | comparison | revisions | |
hal/tests/browser_alarms.js | file | annotate | diff | comparison | revisions |
--- a/dom/alarm/AlarmService.jsm +++ b/dom/alarm/AlarmService.jsm @@ -326,26 +326,33 @@ this.AlarmService = { }.bind(this), function getAllErrorCb(aErrorMsg) { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; } ); }, _getAlarmTime: function _getAlarmTime(aAlarm) { - let alarmTime = (new Date(aAlarm.date)).getTime(); + // Avoid casting a Date object to a Date again to + // preserve milliseconds. See bug 810973. + let alarmTime; + if (aAlarm.date instanceof Date) { + alarmTime = aAlarm.date.getTime(); + } else { + alarmTime = (new Date(aAlarm.date)).getTime(); + } // For an alarm specified with "ignoreTimezone", it must be fired respect // to the user's timezone. Supposing an alarm was set at 7:00pm at Tokyo, // it must be gone off at 7:00pm respect to Paris' local time when the user // is located at Paris. We can adjust the alarm UTC time by calculating // the difference of the orginal timezone and the current timezone. - if (aAlarm.ignoreTimezone) + if (aAlarm.ignoreTimezone) { alarmTime += (this._currentTimezoneOffset - aAlarm.timezoneOffset) * 60000; - + } return alarmTime; }, _sortAlarmByTimeStamps: function _sortAlarmByTimeStamps(aAlarm1, aAlarm2) { return this._getAlarmTime(aAlarm1) - this._getAlarmTime(aAlarm2); }, _debugCurrentAlarm: function _debugCurrentAlarm() {
--- a/hal/tests/browser_alarms.js +++ b/hal/tests/browser_alarms.js @@ -9,17 +9,17 @@ XPCOMUtils.defineLazyModuleGetter(this, * not officially allow a integer, but nor does it disallow it. Of course this * test will break if AlarmService adds a type check, hence this note. * FIXME: when bug 810973 is fixed. */ function add_alarm_future(cb) { let alarmId = undefined; AlarmService.add({ - date: Date.now() + 143, + date: new Date(Date.now() + 143), ignoreTimezone: true }, function onAlarmFired(aAlarm) { ok(alarmId === aAlarm.id, "Future alarm fired successfully."); cb(); }, function onSuccess(aAlarmId) { alarmId = aAlarmId; @@ -29,17 +29,17 @@ function add_alarm_future(cb) { cb(); }); } function add_alarm_present(cb) { let self = this; let alarmId = undefined; AlarmService.add({ - date: Date.now(), + date: new Date(), ignoreTimezone: true }, function onAlarmFired(aAlarm) { ok(alarmId === aAlarm.id, "Present alarm fired successfully."); cb(); }, function onSuccess(aAlarmId) { alarmId = aAlarmId; @@ -48,17 +48,17 @@ function add_alarm_present(cb) { cb(); }); } function add_alarm_past(cb) { let self = this; let alarmId = undefined; AlarmService.add({ - date: Date.now() - 5, + date: new Date(Date.now() - 5), ignoreTimezone: true }, function onAlarmFired(aAlarm) { ok(alarmId === aAlarm.id, "Past alarm fired successfully."); cb(); }, function onSuccess(aAlarmId) { alarmId = aAlarmId; @@ -67,17 +67,17 @@ function add_alarm_past(cb) { ok(false, "Unexpected error adding alarm for time in the past " + error); cb(); }); } function trigger_all_alarms(cb) { let n = 10; let counter = 0; - let date = Date.now() + 57; + let date = new Date(Date.now() + 57); function onAlarmFired() { counter++; info("trigger_all_alarms count " + counter); if (counter == n) { ok(true, "All " + n + " alarms set to a particular time fired."); cb(); } } @@ -89,17 +89,17 @@ function trigger_all_alarms(cb) { ignoreTimezone: true }, onAlarmFired ); } } function multiple_handlers(cb) { - let d = Date.now() + 100; + let d = new Date(Date.now() + 100); let called = 0; function done() { if (called == 2) { ok(true, "Two alarms for the same time fired."); cb(); } } @@ -127,17 +127,17 @@ function multiple_handlers(cb) { ignoreTimezone: true }, handler2 ); } function same_time_alarms(cb) { var fired = 0; - var delay = Date.now() + 100; + var delay = new Date(Date.now() + 100); function check() { fired++; if (fired == 4) { ok(true, "All alarms set for the same time fired."); cb(); } }