summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/payment-request/show-method-postmessage-iframe.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/payment-request/show-method-postmessage-iframe.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/payment-request/show-method-postmessage-iframe.html')
-rw-r--r--testing/web-platform/tests/payment-request/show-method-postmessage-iframe.html49
1 files changed, 49 insertions, 0 deletions
diff --git a/testing/web-platform/tests/payment-request/show-method-postmessage-iframe.html b/testing/web-platform/tests/payment-request/show-method-postmessage-iframe.html
new file mode 100644
index 0000000000..b50f18ecce
--- /dev/null
+++ b/testing/web-platform/tests/payment-request/show-method-postmessage-iframe.html
@@ -0,0 +1,49 @@
+<h1>This iframe calls shows() via postMessage()</h1>
+<script>
+"use strict";
+const defaultMethods = Object.freeze([
+ { supportedMethods: "basic-card" },
+ {
+ supportedMethods: "https://apple.com/apple-pay",
+ data: {
+ version: 3,
+ merchantIdentifier: "merchant.com.example",
+ countryCode: "US",
+ merchantCapabilities: ["supports3DS"],
+ supportedNetworks: ["visa"],
+ }
+ },
+]);
+
+const defaultDetails = Object.freeze({
+ id: "fail",
+ total: {
+ label: "Total",
+ amount: {
+ currency: "USD",
+ value: "1.00",
+ },
+ },
+});
+
+// We are going to use the id to prove that this works
+// which we will pass back to the caller
+window.onmessage = async event => {
+ const { source, data: { id, request } } = event;
+ switch (request) {
+ case "show-payment-request": {
+ const details = Object.assign({}, defaultDetails, { id });
+ const request = new PaymentRequest(defaultMethods, details);
+ try {
+ const response = await request.show();
+ source.postMessage(response.toJSON(), window.location.origin);
+ await response.complete();
+ } catch (err) {
+ source.postMessage({ requestId: "fail" }, window.location.origin);
+ await request.abort();
+ }
+ }
+ }
+};
+
+</script>