Bug 1523562 [wpt PR 14255] - Test PaymentOptions.requestBillingAddress, a=testonly
authorMarcos Cáceres <marcos@marcosc.com>
Thu, 31 Jan 2019 15:44:41 +0000
changeset 456853 a100beb9ad422d4ca2018f178b4f5d9a61a57533
parent 456852 2509717eb74258c2f2e9b0b105dd1d53543b369b
child 456854 8dd89e26973f0b3ff790a7c2a51a2c56c184851f
push id111705
push userjames@hoppipolla.co.uk
push dateTue, 05 Feb 2019 18:07:20 +0000
treeherdermozilla-inbound@9592b19c9b09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1523562, 14255
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1523562 [wpt PR 14255] - Test PaymentOptions.requestBillingAddress, a=testonly Automatic update from web-platform-tests Test PaymentOptions.requestBillingAddress (#14255) -- wpt-commits: f984a4b333d16a2bd1468b6cae231f5f4ea8df2b wpt-pr: 14255
testing/web-platform/tests/payment-request/billing-address-changed-manual.https.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/payment-request/billing-address-changed-manual.https.html
@@ -0,0 +1,106 @@
+<!DOCTYPE html> <meta charset="utf-8" />
+<title>Test for requesting billing address</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+  setup({
+    explicit_done: true,
+    explicit_timeout: true,
+  });
+
+  const methods = [
+    { supportedMethods: "basic-card" },
+    { supportedMethods: "https://apple.com/apple-pay" },
+  ];
+
+  const details = {
+    total: {
+      label: "label",
+      amount: { currency: "USD", value: "5.00" },
+    },
+  };
+  test(() => {
+    assert_true(
+      "onpaymentmethodchange" in PaymentRequest.prototype,
+      "The paymentmethodchange is not supported"
+    );
+  }, "onpaymentmethodchange is in prototype");
+
+  function dontRequestBillingAddress() {
+    promise_test(async t => {
+      const request = new PaymentRequest(methods, details, {});
+      const showPromise = request.show();
+
+      // Let's check the method data from event.
+      const { methodDetails } = await new Promise(resolve =>
+        request.addEventListener("paymentmethodchange", resolve)
+      );
+
+      assert_true("billingAddress" in methodDetails);
+      assert_equals(
+        methodDetails.billingAddress,
+        null,
+        "Expected methodDetails.billingAddress to be null"
+      );
+      await request.abort();
+    });
+  }
+
+  function requestBillingAddress() {
+    promise_test(async t => {
+      const request = new PaymentRequest(methods, details, {
+        requestBillingAddress: true,
+      });
+      const showPromise = request.show();
+
+      // Let's check the method data from event.
+      const { methodDetails } = await new Promise(resolve =>
+        request.addEventListener("paymentmethodchange", resolve)
+      );
+
+      assert_true("billingAddress" in methodDetails);
+
+      const { billingAddress } = methodDetails;
+      assert_true(
+        billingAddress instanceof PaymentAddress,
+        "Expected instance of PaymentAddress"
+      );
+      await request.abort();
+    });
+  }
+</script>
+
+<h2>Request billing address</h2>
+<p>
+  Click on each button in sequence from top to bottom without refreshing the
+  page. Each button will bring up the Payment Request UI window.
+</p>
+<p>
+  When the payment sheet is presented, select a payment method (e.g., a credit
+  card).
+</p>
+<ol>
+  <li>
+    <button onclick="dontRequestBillingAddress()">
+      When no billing address is requested,
+      `PaymentMethodChangeEvent.methodDetails.billingAddress` is null.
+    </button>
+  </li>
+  <li>
+    <button onclick="requestBillingAddress()">
+      When billing address is
+      requested,`PaymentMethodChangeEvent.methodDetails.billingAddress` is a
+      `PaymentAddress`.
+    </button>
+  </li>
+  <li><button onclick="done()">Done!</button></li>
+</ol>
+<small>
+  If you find a buggy test, please
+  <a href="https://github.com/web-platform-tests/wpt/issues">file a bug</a> and
+  tag one of the
+  <a
+    href="https://github.com/web-platform-tests/wpt/blob/master/payment-request/META.yml"
+    >suggested reviewers</a
+  >.
+</small>