Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/LayoutTests/payments/resources/payment-request-mock.js

Issue 2250793003: Separate PaymentRequest initialization and display. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update payment-request-mock.js Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * payment-request-mock contains a mock implementation of PaymentRequest. 2 * payment-request-mock contains a mock implementation of PaymentRequest.
3 */ 3 */
4 4
5 "use strict"; 5 "use strict";
6 6
7 let paymentRequestMock = loadMojoModules( 7 let paymentRequestMock = loadMojoModules(
8 'paymentRequestMock', 8 'paymentRequestMock',
9 ['third_party/WebKit/public/platform/modules/payments/payment_request.mojom' , 9 ['third_party/WebKit/public/platform/modules/payments/payment_request.mojom' ,
10 'mojo/public/js/router', 10 'mojo/public/js/router',
11 ]).then(mojo => { 11 ]).then(mojo => {
12 let [paymentRequest, router] = mojo.modules; 12 let [paymentRequest, router] = mojo.modules;
13 13
14 class PaymentRequestMock { 14 class PaymentRequestMock {
15 constructor(interfaceProvider) { 15 constructor(interfaceProvider) {
16 interfaceProvider.addInterfaceOverrideForTesting( 16 interfaceProvider.addInterfaceOverrideForTesting(
17 paymentRequest.PaymentRequest.name, 17 paymentRequest.PaymentRequest.name,
18 handle => this.connectPaymentRequest_(handle)); 18 handle => this.connectPaymentRequest_(handle));
19 19
20 this.interfaceProvider_ = interfaceProvider; 20 this.interfaceProvider_ = interfaceProvider;
21 this.pendingResponse_ = null; 21 this.pendingResponse_ = null;
22 } 22 }
23 23
24 connectPaymentRequest_(handle) { 24 connectPaymentRequest_(handle) {
25 this.paymentRequestStub_ = new paymentRequest.PaymentRequest.stubClass(thi s); 25 this.paymentRequestStub_ = new paymentRequest.PaymentRequest.stubClass(thi s);
26 this.paymentRequestRouter_ = new router.Router(handle); 26 this.paymentRequestRouter_ = new router.Router(handle);
27 this.paymentRequestRouter_.setIncomingReceiver(this.paymentRequestStub_); 27 this.paymentRequestRouter_.setIncomingReceiver(this.paymentRequestStub_);
28 } 28 }
29 29
30 setClient(client) { 30 init(client, supportedMethods, details, options) {
31 this.client_ = client; 31 this.client_ = client;
32 if (this.pendingResponse_) { 32 if (this.pendingResponse_) {
33 let response = this.pendingResponse_; 33 let response = this.pendingResponse_;
34 this.pendingResponse_ = null; 34 this.pendingResponse_ = null;
35 this.onPaymentResponse(response); 35 this.onPaymentResponse(response);
36 } 36 }
37 } 37 }
38 38
39 show(supportedMethods, details, options, stringifiedData) { 39 show() {
40 } 40 }
41 41
42 updateWith(details) { 42 updateWith(details) {
43 } 43 }
44 44
45 complete(success) { 45 complete(success) {
46 } 46 }
47 47
48 onPaymentResponse(data) { 48 onPaymentResponse(data) {
49 if (!this.client_) { 49 if (!this.client_) {
50 this.pendingResponse_ = data; 50 this.pendingResponse_ = data;
51 return; 51 return;
52 } 52 }
53 this.client_.onPaymentResponse(new paymentRequest.PaymentResponse(data)); 53 this.client_.onPaymentResponse(new paymentRequest.PaymentResponse(data));
54 } 54 }
55 55
56 onComplete() { 56 onComplete() {
57 this.client_.onComplete(); 57 this.client_.onComplete();
58 } 58 }
59 } 59 }
60 return new PaymentRequestMock(mojo.frameInterfaces); 60 return new PaymentRequestMock(mojo.frameInterfaces);
61 }); 61 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698