Closed Bug 787370 Opened 8 years ago Closed 8 years ago

B2G SMS: 'sent' and 'delivered' events not triggered

Categories

(Core :: DOM: Device Interfaces, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla18
blocking-basecamp +

People

(Reporter: salva, Assigned: vicamo)

References

Details

(Whiteboard: [WebAPI:P0][LOE:S])

Attachments

(3 files, 3 obsolete files)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/12.04 Chromium/18.0.1025.168 Chrome/18.0.1025.168 Safari/535.19

Steps to reproduce:

In Gaia:
From APP1, attach callbacks to "onsent" and "ondelivered" members from mozSms.
From SMS application, send a message.
From APP1, send a message.


Actual results:

Any event received: nor from APP1, nor from SMS app.


Expected results:

An event should be sent to the callbacks "whenever an SMS is sent" as said in the documentation:
https://developer.mozilla.org/en-US/docs/DOM/SmsManager
Hsinyi, could you take a look at this bug and see if we can confirm it? Whether or not we can reproduce it, it would be good to have Marionette tests. :)
blocking-basecamp: --- → ?
Component: General → DOM: Device Interfaces
Product: Boot2Gecko → Core
Summary: In mozSms, onsent and ondelivered never trigger an event → B2G SMS: 'sent' and 'delivered' events not triggered
Assuming this gets confirmed, I think we should block on this.
Assignee: nobody → htsai
blocking-basecamp: ? → +
I would like to add that a handler when a SMS is deleted (ondeleted) would be convenient as well.
Assigned to Vicamo since he told me that he's going to test this.
Assignee: htsai → vyang
(In reply to Hsin-Yi Tsai [:hsinyi] from comment #4)
> Assigned to Vicamo since he told me that he's going to test this.

Confirmed, but note "ondelivered" events are not always emitted due to per-carrier operational policy.

(In reply to Salvador de la Puente González [:salva] from comment #3)
> I would like to add that a handler when a SMS is deleted (ondeleted) would
> be convenient as well.

Please have a discuss on mozilla-webapi mailing list and fire a bug ;)
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
(In reply to Vicamo Yang [:vicamo][:vyang] from comment #5)
> Confirmed, but note "ondelivered" events are not always emitted due to
> per-carrier operational policy.

To be more cleared, there is indeed a bug in onsent event but ondelivered works fine for me. I'll upload a patch for onsent bug and a patch for more descriptive debug messages for SMS-STATUS-REPORT PDU.
(In reply to Vicamo Yang [:vicamo][:vyang] from comment #5)
> (In reply to Hsin-Yi Tsai [:hsinyi] from comment #4)
> > Assigned to Vicamo since he told me that he's going to test this.
> 
> Confirmed, but note "ondelivered" events are not always emitted due to
> per-carrier operational policy.

Ok, thank you. I'll take in count.

>
> (In reply to Salvador de la Puente González [:salva] from comment #3)
> > I would like to add that a handler when a SMS is deleted (ondeleted) would
> > be convenient as well.
> 
> Please have a discuss on mozilla-webapi mailing list and fire a bug ;)

Ok, thank you. I'll start the discussion there.
Attachment #658032 - Flags: review?(marshall)
Attachment #658033 - Attachment description: Part 2: test scripts → Part 2: add debug messages for SMS-STATUS-REPORT
Attached patch Part 3: test scripts (obsolete) — Splinter Review
Attachment #658034 - Flags: review?(marshall)
Comment on attachment 658032 [details] [diff] [review]
Part 1: notify missed SmsManager.onsent event

Review of attachment 658032 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/system/gonk/RadioInterfaceLayer.js
@@ +962,5 @@
>      }
>  
>      gSmsRequestManager.notifySmsSent(options.requestId, sms);
> +
> +    Services.obs.notifyObservers(options.sms, kSmsSentObserverTopic, null);

Maybe a follow up for another bug, but it looks like a notifyObservers call for "sms-send-failed" is also missing around line 994:

http://dxr.mozilla.org/mozilla-central/dom/system/gonk/RadioInterfaceLayer.js.html#l994
Attachment #658032 - Flags: review?(marshall) → review+
Attachment #658033 - Flags: review?(marshall) → review+
Comment on attachment 658034 [details] [diff] [review]
Part 3: test scripts

Review of attachment 658034 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, check my follow up below

::: dom/sms/tests/marionette/manifest.ini
@@ +6,5 @@
>  [test_between_emulators.py]
>  [test_incoming.js]
> +
> +[test_outgoing.js]
> +b2g = false

Does marionette run non-b2g tests in the emulator? if not, this seems like a useless flag :)

If you intend for this test to run in non-b2g environments, would this test be better served as an xpcshell test or a mochitest instead?

::: dom/sms/tests/marionette/test_outgoing.js
@@ +10,5 @@
> +let receiver = "5555552368";
> +let body = "Hello SMS world!";
> +let now = Date.now();
> +
> +sms.onsent = function onsent(event) {

It's sad we didn't have any tests for onsent yet :(

I haven't seen any tests for ondelivered either, can you make sure to file a follow up so we can get more coverage?

@@ +30,5 @@
> +
> +  SpecialPowers.removePermission("sms", document);
> +  finish();
> +};
> +

If you end up fixing the notifyObserver call for sms-send-failed, is there a way for send-failed to bubble up to DOM? We might want to make sure an API for that exists in a follow up (probably outside the scope of this test though)
Attachment #658034 - Flags: review?(marshall) → review+
(In reply to Marshall Culpepper [:marshall_law] from comment #11)
> Maybe a follow up for another bug, but it looks like a notifyObservers call
> for "sms-send-failed" is also missing around line 994:
> 
> http://dxr.mozilla.org/mozilla-central/dom/system/gonk/RadioInterfaceLayer.
> js.html#l994

No, we don't have a onsendfailed event in nsIDOMSmsManager, neither ondeliverfailed. For `ondeliverfailed`, Mounir mentioned it once in bug 777251, but the latest update we may have during the San Paulo work week is having a discussion on what's missing and required for V2.
(In reply to Marshall Culpepper [:marshall_law] from comment #12)
> ::: dom/sms/tests/marionette/manifest.ini
> @@ +6,5 @@
> >  [test_between_emulators.py]
> >  [test_incoming.js]
> > +
> > +[test_outgoing.js]
> > +b2g = false
> 
> Does marionette run non-b2g tests in the emulator? if not, this seems like a
> useless flag :)
> If you intend for this test to run in non-b2g environments, would this test
> be better served as an xpcshell test or a mochitest instead?

I was considering about billing problem. I don't want to send SMS message out in physical device. After some research on ManifestParser, I think it's already safe enough with default tags (qemu=true) above. I'll remove the redundant flag.

> I haven't seen any tests for ondelivered either, can you make sure to file a
> follow up so we can get more coverage?

There is no `ondelivered` event support in emulator. ondelivered event depends on a PDU sent by SMSC, which doesn't exist in emulator. We can, and should, bring it in.
Blocks: 788928
(In reply to Vicamo Yang [:vicamo][:vyang] from comment #14)
> There is no `ondelivered` event support in emulator. ondelivered event
> depends on a PDU sent by SMSC, which doesn't exist in emulator. We can, and
> should, bring it in.

Open as bug 788928.
Whiteboard: [WebAPI:P0]
rebase only
Attachment #658032 - Attachment is obsolete: true
Attached patch Part 3: test scripts : v2 (obsolete) — Splinter Review
1. Address review comment #12 about useless flag in manifest.ini
2. Cover both SmsManager.onsent and SmsRequest.onsuccess, single and multiple receipients, and do more semantic tests as possible. Therefore another review is required IMO.

TODO: SmsManager.ondelivered(bug 788928) and SmsRequest.onerror.
Attachment #658034 - Attachment is obsolete: true
Attachment #659105 - Flags: review?(marshall)
(In reply to Vicamo Yang [:vicamo][:vyang] from comment #14)
> There is no `ondelivered` event support in emulator. ondelivered event
> depends on a PDU sent by SMSC, which doesn't exist in emulator. We can, and
> should, bring it in.

The emulator supports forwarding along arbitrary PDUs. I take advantage of this in my voicemail tests:

http://dxr.mozilla.org/mozilla-central/dom/telephony/test/marionette/pdu_builder.js.html
http://dxr.mozilla.org/mozilla-central/dom/telephony/test/marionette/test_voicemail_statuschanged.js.html#l10
Comment on attachment 659105 [details] [diff] [review]
Part 3: test scripts : v2

Review of attachment 659105 [details] [diff] [review]:
-----------------------------------------------------------------

Wow, this is great! Good work :) r+ with just a few comments below..

::: dom/sms/tests/marionette/test_outgoing.js
@@ +33,5 @@
> +function checkSameSentMessage(message, now) {
> +  checkSentMessage(message, now);
> +
> +  if (!sentMessages[message.id]) {
> +    sentMessages[message.id] = message;

nit: it would be probably be better to do:

let sentMessage = sentMessages[message.id];
if (!sentMessage) {
  sentMessages[message.id] = message;
} else {
  ...
  ok(sentMessage.timestamp..)
}

@@ +71,5 @@
> +  function onRequestSuccess(event) {
> +    log("SmsRequest.onsuccess event received.");
> +    event.target.removeEventListener("success", onRequestSuccess);
> +
> +    ok(event.target instanceof MozSmsRequest,

should this check happen before removing the event listener above?
Attachment #659105 - Flags: review?(marshall) → review+
(In reply to Marshall Culpepper [:marshall_law] from comment #19)

> nit: it would be probably be better to do:
> 
> let sentMessage = sentMessages[message.id];
> if (!sentMessage) {
>   sentMessages[message.id] = message;
> } else {
>   ...
>   ok(sentMessage.timestamp..)
> }

Or, even better still, remove the "else" and use early return semantics:

let sentMessage = sentMessages[message.id];
if (!sentMessage) {
  sentMessages[message.id] = message;
  return;
}

// Everything in "else" here..
bail out early <3
(In reply to Marshall Culpepper [:marshall_law] from comment #18)
> (In reply to Vicamo Yang [:vicamo][:vyang] from comment #14)
> > There is no `ondelivered` event support in emulator. ondelivered event
> > depends on a PDU sent by SMSC, which doesn't exist in emulator. We can, and
> > should, bring it in.
> 
> The emulator supports forwarding along arbitrary PDUs. I take advantage of
> this in my voicemail tests:
> 
> http://dxr.mozilla.org/mozilla-central/dom/telephony/test/marionette/
> pdu_builder.js.html
> http://dxr.mozilla.org/mozilla-central/dom/telephony/test/marionette/
> test_voicemail_statuschanged.js.html#l10

Well, SMS-STATUS-REPORT contains a `messageRef` field that must be identical with the one previously sent to ril_worker in the response of REQUEST_SEND_SMS. That's something hidden from DOM API or even RadioInterfaceLayer. I would like to leave ondelivered event untested in this issue and move following discussion to bug 788928.
Whiteboard: [WebAPI:P0] → [WebAPI:P0][LOE:S]
address review comment #19, #20
Attachment #659105 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.