RESOLVED FIXED Bug 175730
[Payment Request] Add interface stubs
https://bugs.webkit.org/show_bug.cgi?id=175730
Summary [Payment Request] Add interface stubs
Andy Estes
Reported 2017-08-18 11:49:25 PDT
[Payment Request] Add interface stubs
Attachments
Patch (227.21 KB, patch)
2017-08-18 12:47 PDT, Andy Estes
no flags
Archive of layout-test-results from ews107 for mac-elcapitan-wk2 (1.99 MB, application/zip)
2017-08-18 14:59 PDT, Build Bot
no flags
Archive of layout-test-results from ews125 for ios-simulator-wk2 (27.62 MB, application/zip)
2017-08-18 15:03 PDT, Build Bot
no flags
Archive of layout-test-results from ews122 for ios-simulator-wk2 (19.11 MB, application/zip)
2017-08-18 16:54 PDT, Build Bot
no flags
Patch (230.00 KB, patch)
2017-08-18 17:26 PDT, Andy Estes
no flags
Patch (234.43 KB, patch)
2017-08-18 17:54 PDT, Andy Estes
no flags
Archive of layout-test-results from ews106 for mac-elcapitan-wk2 (1.26 MB, application/zip)
2017-08-18 19:28 PDT, Build Bot
no flags
Archive of layout-test-results from ews126 for ios-simulator-wk2 (6.46 MB, application/zip)
2017-08-18 20:54 PDT, Build Bot
no flags
Patch (235.00 KB, patch)
2017-08-19 13:03 PDT, Andy Estes
no flags
Patch (235.11 KB, patch)
2017-08-19 13:06 PDT, Andy Estes
no flags
Patch (235.10 KB, patch)
2017-08-19 13:23 PDT, Andy Estes
no flags
Patch (235.26 KB, patch)
2017-08-19 15:28 PDT, Andy Estes
no flags
Andy Estes
Comment 1 2017-08-18 12:47:46 PDT Comment hidden (obsolete)
youenn fablet
Comment 2 2017-08-18 13:26:02 PDT
Comment on attachment 318530 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=318530&action=review > Source/WebCore/Modules/paymentrequest/PaymentAddress.idl:28 > + EnabledBySetting=PaymentRequest, I never used EnabledBySetting. What is its purpose? Would a runtime flag be more or less suited? > Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:44 > + : ActiveDOMObject { &document } I haven't seen that syntax this way before. Are we not usually doing ActiveDOMObject()? > Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:55 > + promise->reject(); Maybe use NotSupportedError here and elsewhere. > Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:63 > +void PaymentRequest::canMakePayment(Ref<DeferredPromise>&& promise) You might want to look at DOMPromiseDeferred. You could replace Ref<DeferredPromise>&& by something like DOMPromiseDeferred<IDLBoolean>. If it is too long an alias can be used also. This is a way of typing what is resolved which usually helps the compiler figure out what to do with the resolve parameter. Usually useful with ref counted types. There is also the possibility to use DOMPromiseDeferred::settle which would take something like ExceptionOr<bool>&& in that specific case. > Source/WebCore/Modules/paymentrequest/PaymentRequest.h:37 > + I am not sure we need all these includes. wtf/Forward, WTFstring and maybe others are probably defined in EventTarget and or ActiveDOMOjbect. > Source/WebCore/Modules/paymentrequest/PaymentRequest.h:58 > + const RefPtr<PaymentAddress>& shippingAddress() const { return m_shippingAddress; } Why not PaymentAddress* without a const? > Source/WebCore/Modules/paymentrequest/PaymentRequest.h:60 > + const std::optional<PaymentShippingType> shippingType() const { return m_shippingType; } Why const? I guess there is no default shipping type, hence optional > Source/WebCore/Modules/paymentrequest/PaymentRequest.h:71 > + void stop() final { } I guess the plan is to implement these in the future. > Source/WebCore/Modules/paymentrequest/PaymentResponse.cpp:35 > +void PaymentResponse::complete(std::optional<PaymentComplete>, Ref<DeferredPromise>&& promise) optional&& > Source/WebCore/Modules/paymentrequest/PaymentResponse.h:38 > +#include <wtf/text/WTFString.h> Ditto here for the includes.
Andy Estes
Comment 3 2017-08-18 14:03:51 PDT
(In reply to youenn fablet from comment #2) > Comment on attachment 318530 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=318530&action=review > > > Source/WebCore/Modules/paymentrequest/PaymentAddress.idl:28 > > + EnabledBySetting=PaymentRequest, > > I never used EnabledBySetting. What is its purpose? > Would a runtime flag be more or less suited? It works like EnabledAtRuntime, but bases its decision on Settings rather than RuntimeEnabledFeatures. A runtime-enabled feature could work here too, and there are cases where only a runtime-enable feature would work, but this isn't one of those cases, so using a setting seemed simplest. > > > Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:44 > > + : ActiveDOMObject { &document } > > I haven't seen that syntax this way before. > Are we not usually doing ActiveDOMObject()? I've noticed that a lot of new code is using universal initialization for initializer lists. I don't think we have a style guideline about this, but I prefer it. > > > Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:55 > > + promise->reject(); > > Maybe use NotSupportedError here and elsewhere. Will do. > > > Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:63 > > +void PaymentRequest::canMakePayment(Ref<DeferredPromise>&& promise) > > You might want to look at DOMPromiseDeferred. > You could replace Ref<DeferredPromise>&& by something like > DOMPromiseDeferred<IDLBoolean>. > If it is too long an alias can be used also. > This is a way of typing what is resolved which usually helps the compiler > figure out what to do with the resolve parameter. > Usually useful with ref counted types. > There is also the possibility to use DOMPromiseDeferred::settle which would > take something like ExceptionOr<bool>&& in that specific case. Ok, I'll try this! > > > Source/WebCore/Modules/paymentrequest/PaymentRequest.h:37 > > + > > I am not sure we need all these includes. > wtf/Forward, WTFstring and maybe others are probably defined in EventTarget > and or ActiveDOMOjbect. Will remove what I can. > > > Source/WebCore/Modules/paymentrequest/PaymentRequest.h:58 > > + const RefPtr<PaymentAddress>& shippingAddress() const { return m_shippingAddress; } > > Why not PaymentAddress* without a const? That should probably work. > > > Source/WebCore/Modules/paymentrequest/PaymentRequest.h:60 > > + const std::optional<PaymentShippingType> shippingType() const { return m_shippingType; } > > Why const? Oops, typo. > I guess there is no default shipping type, hence optional Right. > > > Source/WebCore/Modules/paymentrequest/PaymentRequest.h:71 > > + void stop() final { } > > I guess the plan is to implement these in the future. Right. > > > Source/WebCore/Modules/paymentrequest/PaymentResponse.cpp:35 > > +void PaymentResponse::complete(std::optional<PaymentComplete>, Ref<DeferredPromise>&& promise) > > optional&& Ok. > > > Source/WebCore/Modules/paymentrequest/PaymentResponse.h:38 > > +#include <wtf/text/WTFString.h> > > Ditto here for the includes. Ok. Thanks for the review!
Build Bot
Comment 4 2017-08-18 14:59:45 PDT Comment hidden (obsolete)
Build Bot
Comment 5 2017-08-18 14:59:47 PDT Comment hidden (obsolete)
Build Bot
Comment 6 2017-08-18 15:03:50 PDT Comment hidden (obsolete)
Build Bot
Comment 7 2017-08-18 15:03:53 PDT Comment hidden (obsolete)
Sam Weinig
Comment 8 2017-08-18 15:50:09 PDT
(In reply to Andy Estes from comment #3) > (In reply to youenn fablet from comment #2) > > Comment on attachment 318530 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=318530&action=review > > > > > Source/WebCore/Modules/paymentrequest/PaymentAddress.idl:28 > > > + EnabledBySetting=PaymentRequest, > > > > I never used EnabledBySetting. What is its purpose? > > Would a runtime flag be more or less suited? > > It works like EnabledAtRuntime, but bases its decision on Settings rather > than RuntimeEnabledFeatures. A runtime-enabled feature could work here too, > and there are cases where only a runtime-enable feature would work, but this > isn't one of those cases, so using a setting seemed simplest. > Where possible, EnabledBySetting should be used, and little by little we should try and remove use of RuntimeEnabledFeatures. There isn't a compelling reason to have two settings concepts in WebCore (Settings and RuntimeEnabledFeatures).
Brady Eidson
Comment 9 2017-08-18 16:50:53 PDT
(In reply to Sam Weinig from comment #8) > (In reply to Andy Estes from comment #3) > > (In reply to youenn fablet from comment #2) > > > Comment on attachment 318530 [details] > > > Patch > > > > > > View in context: > > > https://bugs.webkit.org/attachment.cgi?id=318530&action=review > > > > > > > Source/WebCore/Modules/paymentrequest/PaymentAddress.idl:28 > > > > + EnabledBySetting=PaymentRequest, > > > > > > I never used EnabledBySetting. What is its purpose? > > > Would a runtime flag be more or less suited? > > > > It works like EnabledAtRuntime, but bases its decision on Settings rather > > than RuntimeEnabledFeatures. A runtime-enabled feature could work here too, > > and there are cases where only a runtime-enable feature would work, but this > > isn't one of those cases, so using a setting seemed simplest. > > > > Where possible, EnabledBySetting should be used, and little by little we > should try and remove use of RuntimeEnabledFeatures. There isn't a > compelling reason to have two settings concepts in WebCore (Settings and > RuntimeEnabledFeatures). I agree there's not a compelling reason to have both and we'd ideally only have one. That said, as long as the Settings objects is attached to a Page, we won't be able to move to it completely. (Not relevant to this patch, just logging a distinct difference between the two for future code historians needing to know.
Build Bot
Comment 10 2017-08-18 16:54:30 PDT Comment hidden (obsolete)
Build Bot
Comment 11 2017-08-18 16:54:32 PDT Comment hidden (obsolete)
Andy Estes
Comment 12 2017-08-18 17:26:44 PDT Comment hidden (obsolete)
Andy Estes
Comment 13 2017-08-18 17:54:28 PDT Comment hidden (obsolete)
Build Bot
Comment 14 2017-08-18 19:27:58 PDT Comment hidden (obsolete)
Build Bot
Comment 15 2017-08-18 19:28:00 PDT Comment hidden (obsolete)
Build Bot
Comment 16 2017-08-18 20:54:22 PDT Comment hidden (obsolete)
Build Bot
Comment 17 2017-08-18 20:54:24 PDT Comment hidden (obsolete)
Andy Estes
Comment 18 2017-08-19 13:03:42 PDT Comment hidden (obsolete)
Andy Estes
Comment 19 2017-08-19 13:06:57 PDT Comment hidden (obsolete)
youenn fablet
Comment 20 2017-08-19 13:13:14 PDT
Comment on attachment 318589 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=318589&action=review > Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:55 > + RunLoop::main().dispatch([promise = WTFMove(promise)]() mutable { You do not need this, promise rejection callback will be done asynchronously even if you call reject synchronously.
Andy Estes
Comment 21 2017-08-19 13:23:58 PDT Comment hidden (obsolete)
Andy Estes
Comment 22 2017-08-19 13:54:03 PDT
(In reply to youenn fablet from comment #20) > Comment on attachment 318589 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=318589&action=review > > > Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:55 > > + RunLoop::main().dispatch([promise = WTFMove(promise)]() mutable { > > You do not need this, promise rejection callback will be done asynchronously > even if you call reject synchronously. Maybe I'm missing something, but I don't think this is right. When I trace the call to reject(), I see JSC::Interpreter::executeCall() called immediately. I don't see where the asynchrony happens. Anyway, without this, two of the payment-request tests become flaky, so I'm going to keep it for now. This code is temporary, anyway.
Andy Estes
Comment 23 2017-08-19 14:22:22 PDT
(In reply to Andy Estes from comment #22) > Maybe I'm missing something Oh does the Promise code in builtins that handle the asynchrony?
Andy Estes
Comment 24 2017-08-19 14:52:15 PDT
(In reply to Andy Estes from comment #23) > (In reply to Andy Estes from comment #22) > > Maybe I'm missing something > > Oh does the Promise code in builtins that handle the asynchrony? Ok, I see how this works now. I missed the builtin code that enqueues a microtask. I agree I shouldn't need the RunLoop dispatching. I'll remove the RunLoop code and skip the flaky tests instead. These tests will likely stop being flaky once show() and abort() have real implementations.
Andy Estes
Comment 25 2017-08-19 15:28:55 PDT Comment hidden (obsolete)
WebKit Commit Bot
Comment 26 2017-08-19 19:11:37 PDT
Comment on attachment 318592 [details] Patch Clearing flags on attachment: 318592 Committed r220955: <http://trac.webkit.org/changeset/220955>
WebKit Commit Bot
Comment 27 2017-08-19 19:11:40 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 28 2017-08-19 19:18:18 PDT
Note You need to log in before you can comment on or make changes to this bug.