Closed Bug 938304 Opened 6 years ago Closed 6 years ago

navigator.mozPay(): callbacks do not pass through result


(Firefox Graveyard :: Web Apps, defect)

Not set


(Not tracked)

Firefox 30


(Reporter: kumar, Assigned: marco)




(2 files, 5 obsolete files)

- Install Firefox Nightly on an Android device
- Install the in-app payment tester from (manifest:
- Open the tester app from the Android home screen
- Edit the JWT textarea to make a simulation. Add {"simulate": {"result": "postback"}} to the request object so it looks something like:

  "iss": "323d34dc-b5cf-4822-8e47-6a4515dc74db",
  "aud": "",
  "request": {
    "simulate": {"result": "postback"}

- Scroll out of the textarea and tap Pay
- When prompted to continue the simulation, tap the Cancel button

Expected: The payment page will call paymentFailed('USER_CANCELLED') and that error code is available in In the above STR you should see 'error: USER_CANCELLED' in the tester app.

Actual: because is not set, you see 'error: undefined'

Note that this is the behavior for paymentFailed(). In paymentSuccess(), the input variable should become the DOMRequest.result:

Here is the complete callback API:

Android callbacks originally added in bug 924693
Attached image expected.png (obsolete) —
expected screenshot from Firefox OS
Attached image actual.png (obsolete) —
actual screenshot from Android
Attached patch Patch (obsolete) — Splinter Review
I haven't tested this, but this matches b2g. The desktop winrt has this same bug though.
Attachment #832042 - Flags: review?(mark.finkle)
Attached patch desktop patch (obsolete) — Splinter Review
This looked good on try:

but I'm not sure if these tests are running there.
Attachment #832080 - Flags: review?(mar.castelluccio)
Comment on attachment 832042 [details] [diff] [review]

>diff --git a/mobile/android/components/PaymentsUI.js b/mobile/android/components/PaymentsUI.js

> function paymentSuccess(aRequestId) {
>-  return paymentCallback(aRequestId, "Payment:Success");
>+  return function(aResult) {
>+    closePaymentTab(aRequestId, function() {
>+      cpmm.sendAsyncMessage(aMsg, { result: aResult,

Where does aMsg come from?

> function paymentFailed(aRequestId) {
>-  return paymentCallback(aRequestId, "Payment:Failed");
>-function paymentCallback(aRequestId, aMsg) {
>-  return function(aResult) {
>+  return function(aErrorMsg) {
>     closePaymentTab(aRequestId, function() {
>-      cpmm.sendAsyncMessage(aMsg, { result: aResult,
>+      cpmm.sendAsyncMessage(aMsg, { errorMsg: aErrorMsg,

Attached patch PatchSplinter Review
Whoops. Thanks for catching this. Tested this and seems to work fine :)
Attachment #832042 - Attachment is obsolete: true
Attachment #832042 - Flags: review?(mark.finkle)
Attachment #833120 - Flags: review?(mark.finkle)
Attachment #833120 - Flags: review?(mark.finkle) → review+
Comment on attachment 832080 [details] [diff] [review]
desktop patch

Review of attachment 832080 [details] [diff] [review]:

The webapprt chrome tests work in a quite different way (see the other tests for example).
You should create an application manifest that specifies the launch path (that in this case would be "/webapprtChrome/webapprt/test/chrome/mozpay-failed.html").
There are a couple of syntax errors in browser_mozpay.js.
These tests aren't yet run on try, so you should run them manually.

You can run the tests with the webapprt-test-chrome command ("mach webapprt-test-chrome webapprt/test/chrome/browser_mozpay.js").
Attachment #832080 - Flags: review?(mar.castelluccio)

marking leave-open for the desktop + tests bit.
Whiteboard: [leave-open]
If its being left open for Desktop, moving over to that tracking bug.
Blocks: 969539
No longer blocks: 909896
I would prefer to track the desktop work in a separate bug, but in any case we should move this to the desktop product/component now that the only remaining work is for desktop.
OS: Android → All
Product: Firefox for Android → Firefox
QA Contact: aaron.train
Attached patch Patch (obsolete) — Splinter Review
Assignee: nobody → mar.castelluccio
Attachment #831741 - Attachment is obsolete: true
Attachment #831742 - Attachment is obsolete: true
Attachment #832080 - Attachment is obsolete: true
Attachment #8390001 - Flags: review?(ferjmoreno)
Attachment #833120 - Flags: checkin+
Comment on attachment 8390001 [details] [diff] [review]

Review of attachment 8390001 [details] [diff] [review]:

::: webapprt/PaymentUIGlue.js
@@ +25,5 @@
>  function paymentFailed(aRequestId) {
> +  return function(aErrorMsg) {
> +    closePaymentWindow(aRequestId, function() {
> +      cpmm.sendAsyncMessage("Payment:Failed", { requestId: aRequestId,
> +                                                 errorMsg: aErrorMsg });

nit: align errorMsg with requestId
Attachment #8390001 - Flags: review?(ferjmoreno) → review+
Attached patch PatchSplinter Review
Attachment #8390001 - Attachment is obsolete: true
Attachment #8392151 - Flags: review+
Keywords: checkin-needed
Whiteboard: [leave-open]
Flags: in-testsuite+
Keywords: checkin-needed
Whiteboard: [fixed-in-fx-team]
Closed: 6 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 30
QA Whiteboard: [qa-]
Product: Firefox → Firefox Graveyard
You need to log in before you can comment on or make changes to this bug.