From 15e82a1af8e82c0e209116df3298b00d38ce9063 Mon Sep 17 00:00:00 2001 From: Rouslan Solomakhin Date: Mon, 2 Mar 2020 08:40:30 -0800 Subject: [PATCH] [Payment Handler] CanMakePaymentEvent.respondWithMinimalUI() #5 Patch #5: On desktop, pass currency to the CanMakePaymentEvent when minimal UI feature is enabled, so the updated WPTs can pass. Before this patch, the "currency" field of the CanMakePaymentEvent was never set. After this patch, the "currency" field of the CanMakePaymentEvent is set on desktop when the minimal UI feature is enabled, e.g., through chrome://flags/#enable-web-payments-minimal-ui flag, and the updated WPT passes on desktop when opened in a full browser. Bug: 1005076 Change-Id: Ib35ef8f808f57d7674a5712f12fbfe65918ce92a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078797 Reviewed-by: Danyao Wang Commit-Queue: Rouslan Solomakhin Cr-Commit-Position: refs/heads/master@{#745955} --- payment-handler/app-respond-with-minimal-ui.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/payment-handler/app-respond-with-minimal-ui.js b/payment-handler/app-respond-with-minimal-ui.js index 0e6b1b78b9197d..45ac57c2279b11 100644 --- a/payment-handler/app-respond-with-minimal-ui.js +++ b/payment-handler/app-respond-with-minimal-ui.js @@ -1,3 +1,18 @@ self.addEventListener('canmakepayment', event => { + if (!event.currency) { + event.respondWith(false); + return; + } + + if (event.currency !== 'USD') { + event.respondWith(false); + return; + } + + if (!event.respondWithMinimalUI) { + event.respondWith(false); + return; + } + event.respondWithMinimalUI(event.methodData[0].data.test); });