Bug 1526619 [wpt PR 15283] - [Payment Request][WPT] Fix abort() tests., a=testonly
authorBlink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Mon, 18 Feb 2019 19:26:15 +0000
changeset 519198 98162bdbcabb98fef59d7ab296f7da91d858772b
parent 519197 9b289784c5d145e99e046607fe11ad61903bd4d6
child 519199 3c869fae6ed4abd5c6b608634167f33c0ab5da7e
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
bugs1526619, 15283, 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 1526619 [wpt PR 15283] - [Payment Request][WPT] Fix abort() tests., a=testonly Automatic update from web-platform-tests [Payment Request][WPT] Fix abort() tests. (#15283) Before this patch, the WPT tests for PaymentRequest.abort() were expected to fail due to including the vendor testdriver JavaScript file before the generic testdriver file. The vendor file was attempting to use the objects defined in the generic file, but the incorrect include order caused a JS error. This patch reorders the vendor JS file to be after the generic JS file and splits out the manual tests that require a user gesture for PaymentRequest.show(). After this patch, the PaymentRequest.abort() tests are passing. Bug: 929773 Change-Id: Ic0f8ff84b478116821e98775d1cec31cfad32d9f -- wpt-commits: ba78e657cbc2648e1540216e5a7973bc91f221f0 wpt-pr: 15283
testing/web-platform/tests/payment-request/payment-request-abort-method-manual.https.html
testing/web-platform/tests/payment-request/payment-request-abort-method.https.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/payment-request/payment-request-abort-method-manual.https.html
@@ -0,0 +1,95 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Manual tests for PaymentRequest.abort() method</title>
+<link rel="help" href="https://w3c.github.io/payment-request/#abort-method">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+"use strict";
+setup({
+  explicit_done: true,
+  explicit_timeout: true,
+});
+const basicCard = Object.freeze({ supportedMethods: "basic-card" });
+const applePay = Object.freeze({
+  supportedMethods: "https://apple.com/apple-pay",
+  data: {
+    version: 3,
+    merchantIdentifier: "merchant.com.example",
+    countryCode: "US",
+    merchantCapabilities: ["supports3DS"],
+    supportedNetworks: ["visa"],
+  }
+});
+const defaultMethods = Object.freeze([basicCard, applePay]);
+const defaultDetails = Object.freeze({
+  total: {
+    label: "Total",
+    amount: {
+      currency: "USD",
+      value: "1.00",
+    },
+  },
+});
+
+function testShowSameRequestMultipleTimes() {
+  promise_test(async t => {
+    const request = new PaymentRequest(defaultMethods, defaultDetails);
+    const acceptPromise = request.show()
+    try {
+      await request.abort();
+    } catch (err) {
+      assert_unreached("Unexpected promise rejection: " + err.message);
+    }
+    await promise_rejects(t, "AbortError", acceptPromise);
+    // As request is now "closed", trying to show it will fail
+    await promise_rejects(t, "InvalidStateError", request.show());
+  }, "The same request cannot be shown multiple times.");
+}
+
+function testAbortBeforeShow() {
+  promise_test(async t => {
+    // request is in "created" state.
+    const request = new PaymentRequest(defaultMethods, defaultDetails);
+    await promise_rejects(t, "InvalidStateError", request.abort());
+    // Call it again, for good measure.
+    await promise_rejects(t, "InvalidStateError", request.abort());
+    // The request's state is "created", so let's show it
+    // which changes the state to "interactive.".
+    const acceptPromise = request.show()
+    // Let's set request the state to "closed" by calling .abort()
+    try {
+      await request.abort();
+    } catch (err) {
+      assert_unreached("Unexpected promise rejection: " + err.message);
+    }
+    // The request is now "closed", so...
+    await promise_rejects(t, "InvalidStateError", request.abort());
+    await promise_rejects(t, "AbortError", acceptPromise);
+  }, "Aborting a request before it is shown doesn't prevent it from being shown later.");
+}
+</script>
+<h2>Manual tests for PaymentRequest.abort() 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="testShowSameRequestMultipleTimes()">
+      The same request cannot be shown multiple times.
+    </button>
+  </li>
+  <li>
+    <button onclick="testAbortBeforeShow()">
+      Aborting a request before it is shown doesn't prevent it from being shown
+      later.
+    </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-abort-method.https.html
+++ b/testing/web-platform/tests/payment-request/payment-request-abort-method.https.html
@@ -1,16 +1,16 @@
 <!DOCTYPE html>
 <meta charset="utf-8">
 <title>Test for PaymentRequest.abort() method</title>
-<link rel="help" href="https://w3c.github.io/browser-payment-api/#abort-method">
+<link rel="help" href="https://w3c.github.io/payment-request/#abort-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 src="/resources/testdriver.js"></script>
 <script>
 "use strict";
 setup({
   // Ignore unhandled rejections resulting from .show()'s acceptPromise
   // not being explicitly handled.
   allow_uncaught_exception: true,
   explicit_timeout: true,
 });
@@ -39,50 +39,16 @@ const defaultDetails = Object.freeze({
 promise_test(async t => {
   // request is in "created" state
   const request = new PaymentRequest(defaultMethods, defaultDetails);
   await promise_rejects(t, "InvalidStateError", request.abort());
 }, `Throws if the promise [[state]] is not "interactive"`);
 
 promise_test(async t => {
   const request = new PaymentRequest(defaultMethods, defaultDetails);
-  const acceptPromise = test_driver.bless("show payment request", () =>
-    request.show()
-  );
-  try {
-    await request.abort();
-  } catch (err) {
-    assert_unreached("Unexpected promise rejection: " + err.message);
-  }
-  await promise_rejects(t, "AbortError", acceptPromise);
-  // As request is now "closed", trying to show it will fail
-  await promise_rejects(t, "InvalidStateError", request.show());
-}, "The same request cannot be shown multiple times.");
-
-promise_test(async t => {
-  // request is in "created" state.
-  const request = new PaymentRequest(defaultMethods, defaultDetails);
-  await promise_rejects(t, "InvalidStateError", request.abort());
-  // Call it again, for good measure.
-  await promise_rejects(t, "InvalidStateError", request.abort());
-  // The request's state is "created", so let's show it
-  // which changes the state to "interactive.".
-  const acceptPromise = test_driver.bless("show payment request", () =>
-    request.show()
-  );
-  // Let's set request the state to "closed" by calling .abort()
-  try {
-    await request.abort();
-  } catch (err) {
-    assert_unreached("Unexpected promise rejection: " + err.message);
-  }
-  // The request is now "closed", so...
-  await promise_rejects(t, "InvalidStateError", request.abort());
-  await promise_rejects(t, "AbortError", acceptPromise);
-}, "Aborting a request before it is shown doesn't prevent it from being shown later.");
-
-promise_test(async t => {
-  const request = new PaymentRequest(defaultMethods, defaultDetails);
   const promises = new Set([request.abort(), request.abort(), request.abort()]);
   assert_equals(promises.size, 3, "Must have three unique objects");
 }, "Calling abort() 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>