Closed
Bug 1474499
Opened 6 years ago
Closed 6 years ago
Add support for "onmerchantvalidation" and MerchantValidationEvent
Categories
(Core :: DOM: Web Payments, enhancement, P1)
Core
DOM: Web Payments
Tracking
()
RESOLVED
FIXED
mozilla64
Tracking | Status | |
---|---|---|
firefox64 | --- | fixed |
People
(Reporter: marcosc, Assigned: marcosc)
References
(Blocks 1 open bug, )
Details
(Keywords: dev-doc-complete, Whiteboard: [webpayments-reserve])
Attachments
(1 file, 6 obsolete files)
14.28 KB,
patch
|
marcosc
:
review+
|
Details | Diff | Splinter Review |
Adds: * interface MerchantValidationEvent * PaymentRequest.prototype.onmerchantvalidation Allowing for merchant validation to be supported. We won't fire this event - it's just there for web-compat with Safari's Apple Pay when using the payment request API.
Updated•6 years ago
|
Priority: -- → P2
Assignee | ||
Updated•6 years ago
|
Assignee: nobody → mcaceres
Assignee | ||
Updated•6 years ago
|
Whiteboard: [webpayments][triage]
Updated•6 years ago
|
Priority: P2 → --
Whiteboard: [webpayments][triage] → [webpayments] [triage]
Updated•6 years ago
|
Priority: -- → P3
Updated•6 years ago
|
Flags: qe-verify-
Whiteboard: [webpayments] [triage] → [webpayments-reserve]
Assignee | ||
Comment 1•6 years ago
|
||
Made a reference implementation as I was working on this part of the spec. Passes web platform tests 🎉👌 Thanks for feedback on GitHub, Eden! I decided that to use URLs proper instead of nsIURI.
Attachment #9005114 -
Flags: review?(echuang)
Assignee | ||
Updated•6 years ago
|
Priority: P3 → P1
Assignee | ||
Comment 2•6 years ago
|
||
Eden, should I do the UI testing service for this too? I don't mind doing it, but we don't plan on supporting these events yet in Basic Card. This is just for Web Platform Tests conformance.
Updated•6 years ago
|
Status: NEW → ASSIGNED
Comment 3•6 years ago
|
||
Comment on attachment 9005114 [details] [diff] [review] Initial implementation Review of attachment 9005114 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/payments/MerchantValidationEvent.cpp @@ +25,5 @@ > +NS_IMPL_ADDREF_INHERITED(MerchantValidationEvent, Event) > +NS_IMPL_RELEASE_INHERITED(MerchantValidationEvent, Event) > + > +class Promise; > +class EventTarget; Remove forward declarations, they can only be used in header file. class Promise; class EventTarget; @@ +76,5 @@ > + } > + > + nsString href; > + url->GetHref(href); > + event->SetValidationURL(href); Move code from line 55 to 80 into MerchantValidationEvent::Constructor(EventTarget* aOwner, const nsAString& aType, const MerchantValidationEventInit& aEventInitDict) Or PaymentRequest::DispatchMerchantValidationEvent In fact, you don't use this Constructor in PaymentRequest::DispatchMerchantValidationEvent That means the logic would not be run when calling PaymentRequest::DispatchMerchantValidationEvent; @@ +101,5 @@ > + } > + > + // TODO: If we eventually support merchant validation > + // we would verify `aValue` here. > + mRequest->AbortUpdate(NS_ERROR_DOM_NOT_SUPPORTED_ERR, false); Do we really want this? mRequest->AbortUpdate(NS_ERROR_DOM_NOT_SUPPORTED_ERR, false); would make the PaymentRequest be aborted. That means no matter what merchant passed into PaymentMerchantValidationEvent::complete(). PaymentRequest always is aborted with NotSupportedError. ::: dom/payments/moz.build @@ +10,4 @@ > > EXPORTS += [ > 'PaymentRequestData.h', > + 'PaymentRequestService.h',\ nit: remove "\"
Attachment #9005114 -
Flags: review?(echuang) → review-
Comment 4•6 years ago
|
||
(In reply to Eden Chuang[:edenchuang] from comment #3) > Comment on attachment 9005114 [details] [diff] [review] > Initial implementation > > Review of attachment 9005114 [details] [diff] [review]: > ----------------------------------------------------------------- > > @@ +76,5 @@ > > + } > > + > > + nsString href; > > + url->GetHref(href); > > + event->SetValidationURL(href); > > Move code from line 55 to 80 into > MerchantValidationEvent::Constructor(EventTarget* aOwner, const nsAString& > aType, const MerchantValidationEventInit& aEventInitDict) > Or > PaymentRequest::DispatchMerchantValidationEvent > > In fact, you don't use this Constructor in > PaymentRequest::DispatchMerchantValidationEvent > That means the logic would not be run when calling > PaymentRequest::DispatchMerchantValidationEvent; Or you might do it like you did in PaymentMethodChangeEvent https://searchfox.org/mozilla-central/source/dom/payments/PaymentMethodChangeEvent.cpp#47 Declare an init function for it and set up the validationURL.
Assignee | ||
Comment 5•6 years ago
|
||
(In reply to Eden Chuang[:edenchuang] from comment #4) > Or you might do it like you did in PaymentMethodChangeEvent > https://searchfox.org/mozilla-central/source/dom/payments/ > PaymentMethodChangeEvent.cpp#47 > Declare an init function for it and set up the validationURL. I'm having problems figuring out how to derive the `GlobalObject` when I refactor the code. I need a global object to be able to construct the URL. I also need `aRV` so I can set the exception in case the URL construction results in failure. Any suggestions?
Comment 6•6 years ago
|
||
(In reply to Marcos Caceres [:marcosc] from comment #5) > (In reply to Eden Chuang[:edenchuang] from comment #4) > > Or you might do it like you did in PaymentMethodChangeEvent > > https://searchfox.org/mozilla-central/source/dom/payments/ > > PaymentMethodChangeEvent.cpp#47 > > Declare an init function for it and set up the validationURL. > > I'm having problems figuring out how to derive the `GlobalObject` when I > refactor the code. I need a global object to be able to construct the URL. > > I also need `aRV` so I can set the exception in case the URL construction > results in failure. > > Any suggestions? Probably you needn't construct an URL, because the URL::GetHref() comes from URI::GetSpec() see https://searchfox.org/mozilla-central/source/dom/url/URL.cpp#148 I think the correct behavior is you need to create a new URI by the EventInitDict.mValidationURL, like this nsCOMPtr<nsIURI> validationUri; nsresult rv = NS_NewURI(getter_AddRefs(validationUri), aEventInitDict.mValidationURL, nullptr, nullptr, nsContentUtils::GetIOService()); Then you can get the href by calling validationUri.GetSpec() what we done in https://searchfox.org/mozilla-central/source/dom/url/URL.cpp#138 nsAutoCString utf8href; nsresult rv = validationUri->GetSpec(utf8href); if (NS_SUCCEEDED(rv)) { CopyUTF8toUTF16(utf8href, mValidationURL); } all above code should be in MerchantValidationEvent::Init(const MerchantValidationEventInit& init); But in current attached patch, the method is not declared, I expect to see it in the next patch. So we have two MerchantValidationEvent::Constructor(), one has the GlobalObject parameters, and one has not. These two constructors have different purposes. It is a little complicated, but basically we can think the one with GlobalObject is for calling from JS code which the event is generated by users code, and the other one is for C++ gecko code that means the event is generated by gecko internally. Usually, we reuse the implementation of the version which has no GlobalObject in the other one. PaymentRequestUpdateEvent is an good example. https://searchfox.org/mozilla-central/source/dom/payments/PaymentRequestUpdateEvent.cpp#37 Now what we want to implement is dispatching the MerchantValidationEvent when gecko need, and that is PaymentRequest::DispatchMerchantValidationEvent(). In PaymentRequest::DispatchMerchantValidationEvent(), we have followings to do 1. Create MerchantValidationEventInit and set up it. 2. Create MerchantValidationEvent with the MerchantValidationEventInit in step 1. 3. Dispatch the event. So in the step 1, we need set up the EventInit with a ValidationURL. How it comes? It should come from the window object, it is the thing in the patch line 55 to 64. Then in the step 2, we call the Constructor which has no GlobalObject one with the EventInit. Hope the explain make you more clear about the implementation part.
Assignee | ||
Comment 7•6 years ago
|
||
Baku, could you please check the Web IDL? 🙏
Attachment #9005114 -
Attachment is obsolete: true
Attachment #9008007 -
Flags: superreview?(amarchesini)
Attachment #9008007 -
Flags: review?(echuang)
Comment 8•6 years ago
|
||
Comment on attachment 9008007 [details] [diff] [review] Addressed Eden's feedback. Review of attachment 9008007 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/payments/MerchantValidationEvent.cpp @@ +64,5 @@ > +MerchantValidationEvent::init(const MerchantValidationEventInit& aEventInitDict, > + ErrorResult& aRv) > +{ > + nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(GetParentObject()); > + auto principal = window->GetExtantDoc()->NodePrincipal(); GetExtantDoc can be null. Add a check. @@ +93,5 @@ > + > +MerchantValidationEvent::MerchantValidationEvent(EventTarget* aOwner) > + : Event(aOwner, nullptr, nullptr) > + , mWaitForUpdate(false) > + , mRequest(nullptr) remove this line. It's not needed for smart pointers. @@ +109,5 @@ > + if (!mWaitForUpdate) { > + return; > + } > + > + // TODO: If we eventually support merchant validation Do we have a follow up for this TODO? Can you write the bug ID here? @@ +113,5 @@ > + // TODO: If we eventually support merchant validation > + // we would verify `aValue` here. > + mRequest->AbortUpdate(NS_ERROR_DOM_NOT_SUPPORTED_ERR, false); > + > + mWaitForUpdate = false; Move it immediately after if(!mWaitForUpdate) @@ +124,5 @@ > +{ > + MOZ_ASSERT(mRequest); > + > + mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR, false); > + mWaitForUpdate = false; same here. Don't we want to check mWaitForUpdate here? Probably yes. ::: dom/webidl/MerchantValidationEvent.webidl @@ +1,1 @@ > +[Constructor(DOMString type, optional MerchantValidationEventInit eventInitDict), Add an header here. CopyRight + a URL of the spec.
Attachment #9008007 -
Flags: superreview?(amarchesini)
Attachment #9008007 -
Flags: superreview+
Attachment #9008007 -
Flags: review?(echuang)
Attachment #9008007 -
Flags: review+
Assignee | ||
Comment 9•6 years ago
|
||
Attachment #9008007 -
Attachment is obsolete: true
Attachment #9008038 -
Flags: superreview+
Attachment #9008038 -
Flags: review?(echuang)
Assignee | ||
Comment 10•6 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=1cbeed58a4375d5288dd8882e54dc5fda09c8f83
Comment 11•6 years ago
|
||
Comment on attachment 9008038 [details] [diff] [review] Addressed Baku's feedback... Review of attachment 9008038 [details] [diff] [review]: ----------------------------------------------------------------- Excellent. Nothing I can comment.
Attachment #9008038 -
Flags: review?(echuang) → review+
Assignee | ||
Updated•6 years ago
|
Keywords: checkin-needed,
dev-doc-needed
Comment 12•6 years ago
|
||
Pushed by aiakab@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/ebe2c08a2454 Add support for onmerchantvalidation and MerchantValidationEvent. r=edenchuang,baku
Keywords: checkin-needed
Comment 13•6 years ago
|
||
Backed out changeset ebe2c08a2454 (bug 1474499) for failing web platform tests on ValidationEvent/constructor.https.html Backout revision https://hg.mozilla.org/integration/mozilla-inbound/rev/1c3aeb221660f703493fbd8cb4c2f7caabbb8a47 Failed push https://treeherder.mozilla.org/#/jobs?repo=mozilla-inbound&revision=ebe2c08a24548441f0682b8c048b21293d47aea3&filter-resultStatus=testfailed&filter-resultStatus=busted&filter-resultStatus=exception&filter-classifiedState=unclassified Link to the failure log https://treeherder.mozilla.org/logviewer.html#?job_id=198666122&repo=mozilla-inbound :marcosc could you please take a look?
Flags: needinfo?(mcaceres)
Assignee | ||
Comment 14•6 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=1ad036655190d7b240c444666f93920742829bc7
Assignee | ||
Comment 15•6 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=f0a2677ef868ad7a45624418c055e5d8a7d06c59
Assignee | ||
Comment 16•6 years ago
|
||
:sheppy, when you get to this, I can write the details of how merchant validations works (and provide an example) - but would appreciate help with documenting the MerchantValidationEvent interface.
Flags: needinfo?(mcaceres)
Assignee | ||
Comment 17•6 years ago
|
||
I'm going to try assuming FAIL on Linux 32 for now. Talked to Eden and we will investigate what's happening later.
Assignee | ||
Comment 18•6 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=4ed916e1576824757ece1361b587c544ae732d5a
Assignee | ||
Comment 19•6 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=33a5877fb5fd57a9495d75c287fb0768dddfd270
Assignee | ||
Comment 20•6 years ago
|
||
Talked to Eden about Linux 32 failures, and we are going to deal with that separately.
Attachment #9008038 -
Attachment is obsolete: true
Attachment #9008629 -
Flags: review+
Assignee | ||
Comment 21•6 years ago
|
||
Attachment #9008629 -
Attachment is obsolete: true
Attachment #9008631 -
Flags: review+
Assignee | ||
Comment 22•6 years ago
|
||
Attachment #9008631 -
Attachment is obsolete: true
Attachment #9008632 -
Flags: review+
Assignee | ||
Comment 23•6 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=05b0ad83e94142a5cd3fbfb8e34a5f1fc2727ffc
Assignee | ||
Updated•6 years ago
|
Keywords: checkin-needed
Comment 24•6 years ago
|
||
Pushed by apavel@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/72f155506bf6 Add support for onmerchantvalidation and MerchantValidationEvent. r=edenchuang,baku
Keywords: checkin-needed
Comment 25•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/72f155506bf6
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
status-firefox64:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Assignee | ||
Comment 26•6 years ago
|
||
Bug 1490599 - Implement MerchantValidationEvent.prototype.methodName attribute. r=baku
Updated•6 years ago
|
Attachment #9008983 -
Attachment is obsolete: true
Assignee | ||
Comment 27•6 years ago
|
||
Ignore the Phabricator attachment, just me experimenting.
Comment 28•6 years ago
|
||
Underway. Current status below; what's still left to do is to add this to the guide docs. Pages added: * https://developer.mozilla.org/en-US/docs/Web/API/MerchantValidationEvent/MerchantValidationEvent * https://developer.mozilla.org/en-US/docs/Web/API/MerchantValidationEvent/methodName * https://developer.mozilla.org/en-US/docs/Web/API/MerchantValidationEvent/validationURL * https://developer.mozilla.org/en-US/docs/Web/API/MerchantValidationEvent/complete Pages updated: * https://developer.mozilla.org/en-US/docs/Web/API/MerchantValidationEvent * https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequest/onmerchantvalidation
Assignee | ||
Comment 29•6 years ago
|
||
These are great, :sheppy! Thank you! I'm giving them a once over now.
Comment 30•6 years ago
|
||
Added merchant validation info to the guide content: https://developer.mozilla.org/en-US/docs/Web/API/Payment_Request_API/Concepts#Merchant_validation
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•