<!DOCTYPE html>
<!--
Copyright 2021 The Chromium Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Payment request delegation top frame</title>
</head>
<script>
let resolve_promise = null;
window.addEventListener("message", e => resolve_promise(e.data));
async function sendRequestToSubframe(delegate, paymentMethod, targetOrigin) {
const promise = new Promise(resolve => { resolve_promise = resolve; });
let post_message_options = {};
if (delegate) {
post_message_options["delegate"] = "payment";
}
post_message_options["targetOrigin"] = targetOrigin;
try {
frames[0].postMessage(paymentMethod, post_message_options);
} catch (exception) {
resolve_promise(exception.name);
}
return promise;
}
</script>
<iframe src="about:blank" id="iframe" allow="payment"></iframe>
</html>