Bug 1526620 [wpt PR 15285] - [Payment Request][WPT] Fix show() tests., a=testonly
authorBlink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Mon, 18 Feb 2019 19:26:18 +0000
changeset 519199 3c869fae6ed4abd5c6b608634167f33c0ab5da7e
parent 519198 98162bdbcabb98fef59d7ab296f7da91d858772b
child 519200 b3874f50c9fb17379335c08ce79eaf35d6a4a3ff
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1526620, 15285, 817807, 929773
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 1526620 [wpt PR 15285] - [Payment Request][WPT] Fix show() tests., a=testonly Automatic update from web-platform-tests [Payment Request][WPT] Fix show() tests. (#15285) Before this patch, the WPT tests for PaymentRequest.show() failed (and were expected to do so) because the tests run in a content shell, which does not have the Payment Request components sufficient for showing a browser payment sheet. This patch converts the show() test into a manual one, which should be run in a full browser. One test case remains automated, because its intent is to invoke show() without a user gesture. That test case is expected to fail because Chromium does not require a user gesture for show() at this time (https://crbug.com/817807). After this patch, the manual WPT tests for PaymentRequest.show() pass in the full Chromium browser. Bug: 929773 817807 Change-Id: I9cacb5447fb3ae43a8b50c53a74b7c58db8f4466 -- wpt-commits: 9cd1c2970839f44d1d2fb0f6e862d4b05a1065ce wpt-pr: 15285
testing/web-platform/tests/payment-request/payment-request-multiple-show-manual.https.html
testing/web-platform/tests/payment-request/payment-request-show-method-manual.https.html
testing/web-platform/tests/payment-request/payment-request-show-method.https.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/payment-request/payment-request-multiple-show-manual.https.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Manual test for multiple PaymentRequest.show()</title>
+<link rel="help" href="https://w3c.github.io/payment-request/#show-method">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+"use strict";
+setup({
+  allow_uncaught_exception: true,
+});
+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({
+  total: {
+    label: "Total",
+    amount: {
+      currency: "USD",
+      value: "1.00",
+    },
+  },
+});
+
+function testCallingShowMultipleTimes() {
+  promise_test(async t => {
+    const request = new PaymentRequest(defaultMethods, defaultDetails);
+    const p1 = request.show();
+    const p2 = request.show();
+    const p3 = request.show();
+    const promises = new Set([p1, p2, p3]);
+    await request.abort();
+    assert_equals(promises.size, 3, "Must have three unique objects");
+    await promise_rejects(t, "AbortError", p1);
+    await promise_rejects(t, "InvalidStateError", p2);
+    await promise_rejects(t, "InvalidStateError", p3);
+  }, "Calling show() multiple times is always a new object.");
+}
+</script>
+<h2>Manual test for multiple PaymentRequest.show()</h2>
+<p>
+  Click on the button to bring up the Payment Request UI window and then will
+  close it automatically. (If a payment sheet stays open, the test has failed.)
+</p>
+<ul>
+  <li>
+    <button onclick="testCallingShowMultipleTimes()">
+      Calling show() multiple times is always a new object.
+    </button>
+  </li>
+</ul>
+<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>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/payment-request/payment-request-show-method-manual.https.html
@@ -0,0 +1,97 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Manual tests for PaymentRequest.show() method</title>
+<link rel="help" href="https://w3c.github.io/payment-request/#show-method">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+"use strict";
+setup({
+  explicit_done: true,
+  explicit_timeout: true,
+});
+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({
+  total: {
+    label: "Total",
+    amount: {
+      currency: "USD",
+      value: "1.00",
+    },
+  },
+});
+
+function testThrowsIfStateIsNotCreated() {
+  promise_test(async t => {
+    const request = new PaymentRequest(defaultMethods, defaultDetails);
+    const acceptPromise = request.show(); // Sets state to "interactive"
+    await promise_rejects(t, "InvalidStateError", request.show());
+    await request.abort();
+    await promise_rejects(t, "AbortError", acceptPromise);
+  }, "Throws if the promise [[state]] is not 'created'.");
+}
+
+function testPaymentRequestIsShowingBoolean() {
+  promise_test(async t => {
+    const request1 = new PaymentRequest(defaultMethods, defaultDetails);
+    const request2 = new PaymentRequest(defaultMethods, defaultDetails);
+    const acceptPromise1 = request1.show();
+    const acceptPromise2 = request2.show();
+    await promise_rejects(t, "AbortError", acceptPromise2);
+    await request1.abort();
+    await promise_rejects(t, "AbortError", acceptPromise1);
+  }, `If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException.`);
+}
+
+function testNotSupportedError() {
+  promise_test(async t => {
+    const request = new PaymentRequest(
+      [{ supportedMethods: "this-is-not-supported" }],
+      defaultDetails
+    );
+    const acceptPromise = request.show();
+    await promise_rejects(t, "NotSupportedError", acceptPromise);
+  }, `If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException.`);
+}
+</script>
+<h2>Manual tests for PaymentRequest.show() method</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 and then will
+  close it automatically. (If a payment sheet stays open, the test has failed.)
+</p>
+<ol>
+  <li>
+    <button onclick="testThrowsIfStateIsNotCreated()">
+      Throws if the promise [[state]] is not 'created'.
+    </button>
+  </li>
+  <li>
+    <button onclick="testPaymentRequestIsShowingBoolean()">
+      If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException.
+    </button>
+  </li>
+  <li>
+    <button onclick="testNotSupportedError()">
+      If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException.
+    </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>
--- a/testing/web-platform/tests/payment-request/payment-request-show-method.https.html
+++ b/testing/web-platform/tests/payment-request/payment-request-show-method.https.html
@@ -1,16 +1,14 @@
 <!DOCTYPE html>
 <meta charset="utf-8">
 <title>Test for PaymentRequest.show() method</title>
-<link rel="help" href="https://w3c.github.io/browser-payment-api/#show-method">
+<link rel="help" href="https://w3c.github.io/payment-request/#show-method">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
-<script src="/resources/testdriver.js"></script>
-<script src="/resources/testdriver-vendor.js"></script>
 <script>
 "use strict";
 const defaultMethods = Object.freeze([
   { supportedMethods: "basic-card" },
   {
     supportedMethods: "https://apple.com/apple-pay",
     data: {
       version: 3,
@@ -32,58 +30,13 @@ const defaultDetails = Object.freeze({
   },
 });
 
 promise_test(async t => {
   const request = new PaymentRequest(defaultMethods, defaultDetails);
   const acceptPromise = request.show();
   await promise_rejects(t, "SecurityError", acceptPromise);
 }, `Calling show() without being triggered by user interaction throws`);
-
-promise_test(t => {
-  return test_driver.bless("show payment request", async () => {
-    const request = new PaymentRequest(defaultMethods, defaultDetails);
-    const acceptPromise = request.show(); // Sets state to "interactive"
-    await promise_rejects(t, "InvalidStateError", request.show());
-    await request.abort();
-    await promise_rejects(t, "AbortError", acceptPromise);
-  });
-}, "Throws if the promise [[state]] is not 'created'.");
-
-promise_test(t => {
-  return test_driver.bless("show payment request", async () => {
-    const request1 = new PaymentRequest(defaultMethods, defaultDetails);
-    const request2 = new PaymentRequest(defaultMethods, defaultDetails);
-    const acceptPromise1 = request1.show();
-    const acceptPromise2 = request2.show();
-    await promise_rejects(t, "AbortError", acceptPromise2);
-    await request1.abort();
-    await promise_rejects(t, "AbortError", acceptPromise1);
-  });
-}, `If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException.`);
-
-promise_test(t => {
-  return test_driver.bless("show payment request", async () => {
-    const request = new PaymentRequest(
-      [{ supportedMethods: "this-is-not-supported" }],
-      defaultDetails
-    );
-    const acceptPromise = request.show();
-    await promise_rejects(t, "NotSupportedError", acceptPromise);
-  });
-}, `If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException.`);
-
-promise_test(t => {
-  return test_driver.bless("show payment request", async () => {
-    const request = new PaymentRequest(
-      [{ supportedMethods: "basic-card" }],
-      defaultDetails
-    );
-    const promises = new Set([request.show(), request.show(), request.show()]);
-    await request.abort();
-    assert_equals(promises.size, 3, "Must have three unique objects");
-  });
-}, "Calling show() multiple times is always a new object.");
 </script>
 <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>