tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

bug1478740.html (956B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <title>Payment Request Testing</title>
      4 <script>
      5 const methods = [
      6  {
      7    supportedMethods: "basic-card",
      8  },
      9 ];
     10 const details = {
     11  id: "simple details",
     12  total: {
     13    label: "Donation",
     14    amount: { currency: "USD", value: "55.00" },
     15  },
     16 };
     17 const updatedDetails = {
     18  id: "simple details",
     19  total: {
     20    label: "Donation",
     21    amount: { currency: "USD", value: "55.00" },
     22  },
     23  error: "",
     24 };
     25 
     26 window.onmessage = async ({ data: action }) => {
     27  let msg = "successful";
     28  switch (action) {
     29    case "Show Payment":
     30      try {
     31        let request = new PaymentRequest(methods, details);
     32        let responsePromise = await request.show();
     33      } catch (err) {
     34        msg = err.name;
     35      }
     36      window.parent.postMessage(msg, "*")
     37      break;
     38    default:
     39      window.parent.postMessage(`fail - unknown postmessage action: ${action}`, "*");
     40  }
     41 };
     42 
     43 window.parent.postMessage("successful", "*");
     44 </script>