Backed out changeset 0cd289fcea16 (bug 876936) for failing in test_alarm_add_date.html
authorEd Morley <emorley@mozilla.com>
Tue, 04 Jun 2013 09:37:38 +0100
changeset 145358 e460f5af43115a487fb3b2c220e51626c9833b85
parent 145357 83b67d255bf35784893f6e114a51403ddf96e86f
child 145359 911c71b4f301cbc92c4a2da9382c21fff0afa59c
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs876936
milestone24.0a1
backs out0cd289fcea166731e947883d303dae45778bc88e
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
Backed out changeset 0cd289fcea16 (bug 876936) for failing in test_alarm_add_date.html
dom/alarm/AlarmService.jsm
dom/alarm/test/test_alarm_add_date.html
--- a/dom/alarm/AlarmService.jsm
+++ b/dom/alarm/AlarmService.jsm
@@ -389,16 +389,23 @@ this.AlarmService = {
     aErrorCb = aErrorCb || function() {};
 
     if (!aNewAlarm) {
       aErrorCb("alarm is null");
       return;
     }
 
     aNewAlarm['timezoneOffset'] = this._currentTimezoneOffset;
+    let aNewAlarmTime = this._getAlarmTime(aNewAlarm);
+    if (aNewAlarmTime <= Date.now()) {
+      debug("Adding a alarm that has past time.");
+      this._debugCurrentAlarm();
+      aErrorCb("InvalidStateError");
+      return;
+    }
 
     this._db.add(
       aNewAlarm,
       function addSuccessCb(aNewId) {
         debug("Callback after adding alarm in database.");
 
         aNewAlarm['id'] = aNewId;
 
@@ -412,17 +419,16 @@ this.AlarmService = {
           this._debugCurrentAlarm();
           aSuccessCb(aNewId);
           return;
         }
 
         // If the new alarm is earlier than the current alarm, swap them and
         // push the previous alarm back to queue.
         let alarmQueue = this._alarmQueue;
-        let aNewAlarmTime = this._getAlarmTime(aNewAlarm);
         let currentAlarmTime = this._getAlarmTime(this._currentAlarm);
         if (aNewAlarmTime < currentAlarmTime) {
           alarmQueue.unshift(this._currentAlarm);
           this._currentAlarm = aNewAlarm;
           this._debugCurrentAlarm();
           aSuccessCb(aNewId);
           return;
         }
--- a/dom/alarm/test/test_alarm_add_date.html
+++ b/dom/alarm/test/test_alarm_add_date.html
@@ -52,21 +52,21 @@
     } catch (e) {
       ok(false,
          "Unexpected exception trying to add alarm for yesterday.");
       return testNull();
     }
     domRequest.onsuccess = function(e) {
       navigator.mozAlarms.remove(e.target.result);
 
-      ok(true, "Should be able to add alarm for already past date, which should fire immediately.");
+      ok(false, "Should not be able to add alarm for already past date.");
       testNull();
     };
     domRequest.onerror = function(e) {
-      ok(false, "Unable to add alarm for yesterday.");
+      ok(true, "Can't use past date when adding new alarm.");
 
       // Errors as it should, on to the next test
       testNull();
     }
   }
 
   // Verify passing null does indeed fail
   function testNull() {