Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/payments/test/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 4 kB image not shown  

Quelle  test_requestShipping.html

  Sprache: HTML
 

 products/Sources/formale Sprachen/C/Firefox/dom/payments/test/test_requestShipping.html


<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1436903
-->

<head>
  <meta charset="utf-8">
  <title>Test for Bug 1436903</title>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript">

  "use strict";
  SimpleTest.waitForExplicitFinish();

  var gUrl = SimpleTest.getTestFileURL('RequestShippingChromeScript.js');
  var gScript = SpecialPowers.loadChromeScript(gUrl);

  function testFailHandler(message) {
    ok(false, message);
  }
  gScript.addMessageListener("test-fail", testFailHandler);

  const defaultMethods = [{
    supportedMethods: "basic-card",
    data: {
      supportedNetworks: ['unionpay''visa''mastercard''amex''discover',
                          'diners''jcb''mir',
      ],
    },
  }, {
    supportedMethods: "testing-payment-method",
  }];
  const defaultDetails = {
    id: "test payment",
    total: {
      label"Total",
      amount: {
        currency: "USD",
        value: "1.00"
      }
    },
    shippingOptions: [
      {
        id: "NormalShipping",
        label"NormalShipping",
        amount: {
          currency: "USD",
          value: "10.00"
        },
        selected: false,
      },
      {
        id: "FastShipping",
        label"FastShipping",
        amount: {
          currency: "USD",
          value: "30.00"
        },
        selected: false,
      },
    ],
  };

  const defaultOptions = {
    requestPayerName: true,
    requestPayerEmail: false,
    requestPayerPhone: false,
    requestShipping: false,
    shippingType: "shipping"
  };

  const updatedOptionDetails = {
    total: {
      label"Total",
      amount: {
        currency: "USD",
        value: "1.00"
      }
    },
    shippingOptions: [
      {
        id: "NormalShipping",
        label"NormalShipping",
        amount: {
          currency: "USD",
          value: "10.00"
        },
        selected: false,
      },
      {
        id: "FastShipping",
        label"FastShipping",
        amount: {
          currency: "USD",
          value: "30.00"
        },
        selected: true,
      },
    ],
  };

  const nonSupportedMethods = [{
    supportedMethods: "nonsupported-method",
  }];


  function updateWithShippingAddress() {
    return new Promise((resolve, reject) => {
      resolve(defaultDetails);
    });
  }

  function updateWithShippingOption() {
    return new Promise((resolve, reject) => {
      resolve(updatedOptionDetails);
    });
  }

  function testShow() {
    gScript.sendAsyncMessage("set-normal-ui-service");
    return new Promise((resolve, reject) => {
      const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);

      payRequest.addEventListener("shippingaddresschange", event => {
        event.updateWith(updateWithShippingAddress());
      });
      payRequest.addEventListener("shippingoptionchange", event => {
        event.updateWith(updateWithShippingOption());
      });

      const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
      payRequest.show().then(response => {
        response.complete("success").then(() =>{
          resolve();
        }).catch(e => {
          ok(false, "Unexpected error: " + e.name);
          resolve();
        });
      }).catch( e => {
        ok(false, "Unexpected error: " + e.name);
        resolve();
      }).finally(handler.destruct);
    });
  }

  function teardown() {
    ok(true, "Mandatory assert");
    gScript.addMessageListener("teardown-complete", function teardownCompleteHandler() {
      gScript.removeMessageListener("teardown-complete", teardownCompleteHandler);
      gScript.removeMessageListener("test-fail", testFailHandler)
      gScript.destroy();
      SimpleTest.finish();
    });
    gScript.sendAsyncMessage("teardown");
  }

  function runTests() {
    testShow()
    .then(teardown)
    .catch( e => {
      ok(false, "Unexpected error: " + e.name);
      SimpleTest.finish();
    });
  }

  window.addEventListener('load', function() {
    SpecialPowers.pushPrefEnv({
      'set': [
        ['dom.payments.request.enabled', true],
      ]
    }, runTests);
  });

  </script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1436903">Mozilla Bug 1436903</a>
</body>
</html>

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet am  2026-06-06) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.