Bug 1445138 [wpt PR 9990] - show() must be triggered by user activation, a=testonly
authorMarcos Cáceres <marcos@marcosc.com>
Mon, 09 Apr 2018 16:51:12 +0000
changeset 467051 1b7272be53f8be2ac46211bbde940824c663fd07
parent 467050 0b82e92309115287b23f119a34d5f15b39425821
child 467052 9d110f970c48da96dd63ddb2076c0116b4423cfd
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1445138
milestone61.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 1445138 [wpt PR 9990] - show() must be triggered by user activation, a=testonly Automatic update from web-platform-testsshow() must be triggered by user activation (#9990) wpt-commits: 3686c5fe05978d9c7f62a5b66b6752a9f9aeaa75 wpt-pr: 9990 wpt-commits: 3686c5fe05978d9c7f62a5b66b6752a9f9aeaa75 wpt-pr: 9990
testing/web-platform/meta/MANIFEST.json
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
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -14870,16 +14870,22 @@
     ]
    ],
    "payment-request/payment-request-canmakepayment-method-manual.https.html": [
     [
      "/payment-request/payment-request-canmakepayment-method-manual.https.html",
      {}
     ]
    ],
+   "payment-request/payment-request-show-method-manual.https.html": [
+    [
+     "/payment-request/payment-request-show-method-manual.https.html",
+     {}
+    ]
+   ],
    "payment-request/payment-response/complete-method-manual.https.html": [
     [
      "/payment-request/payment-response/complete-method-manual.https.html",
      {}
     ]
    ],
    "payment-request/payment-response/methodName-attribute-manual.https.html": [
     [
@@ -581708,18 +581714,22 @@
   "payment-request/payment-request-shippingOption-attribute.https.html": [
    "4dbafc96c5effd3b697026aa9a29095e8f4a9296",
    "testharness"
   ],
   "payment-request/payment-request-shippingType-attribute.https.html": [
    "27ecc7e10e50bf2df07f84a15972c3b913ebf32f",
    "testharness"
   ],
+  "payment-request/payment-request-show-method-manual.https.html": [
+   "1df34a1d4ae403ef4853af6850a3f2e9521703f7",
+   "manual"
+  ],
   "payment-request/payment-request-show-method.https.html": [
-   "1e4c792de7013839c713555a0a295bcbb9597094",
+   "676d99be4ce55ab42061921255657c3ab4e458ac",
    "testharness"
   ],
   "payment-request/payment-response/complete-method-manual.https.html": [
    "dc083332294137bd562060c7bf13f0664e6e038f",
    "manual"
   ],
   "payment-request/payment-response/helpers.js": [
    "992e5ce9af876e7d3f76168f15691afd43b41791",
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/payment-request/payment-request-show-method-manual.https.html
@@ -0,0 +1,95 @@
+<!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">
+<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 defaultMethods = Object.freeze([basicCard]);
+const defaultDetails = Object.freeze({
+  total: {
+    label: "Total",
+    amount: {
+      currency: "USD",
+      value: "1.00",
+    },
+  },
+});
+
+test(() => {
+  try {
+    new PaymentRequest(defaultMethods, defaultDetails);
+  } catch (err) {
+    done();
+    throw err;
+  }
+}, "Must be possible to construct a payment request");
+
+function manualTest1(button){
+  button.disabled = true;
+  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);
+  }, button.textContent.trim());
+}
+
+function manualTest2(button){
+  button.disabled = true;
+  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);
+  }, button.textContent.trim());
+}
+
+function manualTest3(button){
+  button.disabled = true;
+  promise_test(async t => {
+    const request = new PaymentRequest(
+      [{ supportedMethods: "this-is-not-supported" }],
+      defaultDetails);
+    const acceptPromise = request.show();
+    await promise_rejects(t, "NotSupportedError", acceptPromise);
+  }, button.textContent.trim());
+  done();
+}
+</script>
+
+<h2>Test for PaymentRequest.show() method</h2>
+<p>
+  Click on each button in sequence from top to bottom without refreshing the page.
+</p>
+<ol>
+  <li>
+    <button onclick="manualTest1(this)">
+      Throws if the promise [[state]] is not "created"
+    </button>
+  </li>
+  <li>
+    <button onclick="manualTest2(this)">
+      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="manualTest3(this)">
+      If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException.
+    </button>
+  </li>
+</ol>
+<small>
+  If you find a buggy test, please <a href="https://github.com/w3c/web-platform-tests/issues">file a bug</a>
+  and tag one of the <a href="https://github.com/w3c/web-platform-tests/blob/master/payment-request/OWNERS">owners</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
@@ -2,56 +2,29 @@
 <!-- Copyright © 2017 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
 <meta charset="utf-8">
 <title>Test for PaymentRequest.show() method</title>
 <link rel="help" href="https://w3c.github.io/browser-payment-api/#show-method">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script>
 'use strict';
-const basicCard = Object.freeze({ supportedMethods: "basic-card" });
-const defaultMethods = Object.freeze([basicCard]);
+const defaultMethods = Object.freeze([
+  { supportedMethods: "basic-card" },
+  { supportedMethods: "https://apple.com/pay" }
+]);
+
 const defaultDetails = Object.freeze({
   total: {
     label: "Total",
     amount: {
       currency: "USD",
       value: "1.00",
     },
   },
 });
 
-test(() => {
-  try {
-    new PaymentRequest(defaultMethods, defaultDetails);
-  } catch (err) {
-    done();
-    throw err;
-  }
-}, "Must be possible to construct a payment request");
-
-
 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"`);
-
-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.`);
-
-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.`);
+  await promise_rejects(t, "SecurityError", acceptPromise);
+}, `Calling show() without being triggered by user interaction throws`);
 </script>