you can do something like this:

```javascript
function addNewAlarm() {
  var request = {};
  return {
    request: request,
    stub: sinon.stub().returns(request)
  };
}

function triggerSuccessfulAlarm(request, alarmId) {
  var result = { target: {result: alarmId }};
  request.onsuccess && request.onsuccess.call(result.target, result);
}

function triggerFailureAlarm(request) {
  var result = { target: { error: { name: 'error' } } };
  request.onerror && request.onerror.call(result.target, result);
}

// then, in test
  var alarmInfo = addNewAlarm();
  this.sinon.stub(navigator.mozAlarms, 'add', alarmInfo.stub);
  ...
  fakePort.postMessageToSms({ ... });
  triggerSuccessfulAlarm(alarmInfo.request, alarmId);
```

Does that make sense?