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

RESOLVED FIXED in Firefox 30

Status

Firefox Graveyard
Web Apps
RESOLVED FIXED
4 years ago
2 years ago

People

(Reporter: kumar, Assigned: marco)

Tracking

Trunk
Firefox 30
Bug Flags:
in-testsuite +

Details

Attachments

(2 attachments, 5 obsolete attachments)

STR:
- Install Firefox Nightly on an Android device
- Install the in-app payment tester from http://apploa.de/3b25a (manifest: http://inapp-pay-test.paas.allizom.org/manifest.webapp)
- 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": "marketplace.firefox.com",
  ...
  "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 DOMRequest.error.name. In the above STR you should see 'error: USER_CANCELLED' in the tester app.

Actual: because DOMRequest.error.name 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: https://developer.mozilla.org/en-US/docs/Web/API/DOMRequest.result

Here is the complete callback API: https://wiki.mozilla.org/WebAPI/WebPaymentProvider#API

Android callbacks originally added in bug 924693
Created attachment 831741 [details]
expected.png

expected screenshot from Firefox OS
Created attachment 831742 [details]
actual.png

actual screenshot from Android
Created attachment 832042 [details] [diff] [review]
Patch

I haven't tested this, but this matches b2g. The desktop winrt has this same bug though.
Attachment #832042 - Flags: review?(mark.finkle)
Created attachment 832080 [details] [diff] [review]
desktop patch

This looked good on try:
https://tbpl.mozilla.org/?tree=Try&rev=5f84b2f62815

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

>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,

Same
Created attachment 833120 [details] [diff] [review]
Patch

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+
(Assignee)

Comment 7

4 years ago
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)
https://hg.mozilla.org/integration/fx-team/rev/7f5e40e54c11

marking leave-open for the desktop + tests bit.
Whiteboard: [leave-open]

Comment 10

4 years ago
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.
Component: Web Apps → Web Apps
OS: Android → All
Product: Firefox for Android → Firefox
QA Contact: aaron.train
(Assignee)

Comment 12

4 years ago
Created attachment 8390001 [details] [diff] [review]
Patch
Assignee: nobody → mar.castelluccio
Attachment #831741 - Attachment is obsolete: true
Attachment #831742 - Attachment is obsolete: true
Attachment #832080 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #8390001 - Flags: review?(ferjmoreno)
(Assignee)

Updated

4 years ago
Attachment #833120 - Flags: checkin+
Comment on attachment 8390001 [details] [diff] [review]
Patch

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+
(Assignee)

Comment 14

4 years ago
Created attachment 8392151 [details] [diff] [review]
Patch
Attachment #8390001 - Attachment is obsolete: true
Attachment #8392151 - Flags: review+
(Assignee)

Updated

4 years ago
Keywords: checkin-needed
Whiteboard: [leave-open]
https://hg.mozilla.org/integration/fx-team/rev/9a2844261651
Flags: in-testsuite+
Keywords: checkin-needed
Whiteboard: [fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/9a2844261651
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 30

Updated

4 years ago
QA Whiteboard: [qa-]
Product: Firefox → Firefox Graveyard
You need to log in before you can comment on or make changes to this bug.