[Payment Request] Update web platform tests
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Nov 2018 19:53:53 +0000 (19:53 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Nov 2018 19:53:53 +0000 (19:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191426

Updated web-platform-tests/payment-request/ to match wpt as of commit 577284e.

Reviewed by Jiewen Tan.

* resources/import-expectations.json:
* web-platform-tests/payment-request/META.yml:
* web-platform-tests/payment-request/payment-request-abort-method.https.html:
* web-platform-tests/payment-request/payment-request-canmakepayment-method-protection.https-expected.txt: Added.
* web-platform-tests/payment-request/payment-request-canmakepayment-method-protection.https.html: Added.
* web-platform-tests/payment-request/payment-request-canmakepayment-method.https.html:
* web-platform-tests/payment-request/payment-request-constructor.https.html:
* web-platform-tests/payment-request/payment-request-id-attribute.https.html:
* web-platform-tests/payment-request/payment-response/retry-method-manual.https.html:
* web-platform-tests/payment-request/rejects_if_not_active.https.html:
* web-platform-tests/payment-request/w3c-import.log:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237995 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/resources/import-expectations.json
LayoutTests/imported/w3c/web-platform-tests/payment-request/META.yml
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-protection.https-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-protection.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-constructor.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-id-attribute.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/retry-method-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/w3c-import.log

index cbf93e3..dbfaae0 100644 (file)
@@ -1,3 +1,24 @@
+2018-11-08  Andy Estes  <aestes@apple.com>
+
+        [Payment Request] Update web platform tests
+        https://bugs.webkit.org/show_bug.cgi?id=191426
+
+        Updated web-platform-tests/payment-request/ to match wpt as of commit 577284e.
+
+        Reviewed by Jiewen Tan.
+
+        * resources/import-expectations.json:
+        * web-platform-tests/payment-request/META.yml:
+        * web-platform-tests/payment-request/payment-request-abort-method.https.html:
+        * web-platform-tests/payment-request/payment-request-canmakepayment-method-protection.https-expected.txt: Added.
+        * web-platform-tests/payment-request/payment-request-canmakepayment-method-protection.https.html: Added.
+        * web-platform-tests/payment-request/payment-request-canmakepayment-method.https.html:
+        * web-platform-tests/payment-request/payment-request-constructor.https.html:
+        * web-platform-tests/payment-request/payment-request-id-attribute.https.html:
+        * web-platform-tests/payment-request/payment-response/retry-method-manual.https.html:
+        * web-platform-tests/payment-request/rejects_if_not_active.https.html:
+        * web-platform-tests/payment-request/w3c-import.log:
+
 2018-11-07  Youenn Fablet  <youenn@apple.com>
 
         Allow setting RTCRtpTransceiver.direction
index 467593e..131bbdc 100644 (file)
     "web-platform-tests/worklets": "skip", 
     "web-platform-tests/x-frame-options": "skip", 
     "web-platform-tests/xhr": "import"
-}
+}
\ No newline at end of file
index f8460d4..e608c0e 100644 (file)
@@ -3,6 +3,7 @@ suggested_reviewers:
   - marcoscaceres
   - rsolomakhin
   - domenic
-  - MSFTkihans
+  - zouhir
   - mnoorenberghe
   - romandev
+  - edenchuang
index 522411b..8e561b2 100644 (file)
@@ -36,41 +36,41 @@ promise_test(async t => {
 }, `Throws if the promise [[state]] is not "interactive"`);
 
 promise_test(async t => {
-  return test_driver.bless("show payment request", async () => {
-    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());
-  });
-});
+  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 => {
-  return test_driver.bless("show payment request", async () => {
-    // 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);
-  });
-});
+  // 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);
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-protection.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-protection.https-expected.txt
new file mode 100644 (file)
index 0000000..87b3fe3
--- /dev/null
@@ -0,0 +1,4 @@
+If you find a buggy test, please file a bug and tag one of the suggested reviewers.
+
+PASS Optionally, at the user agent's discretion, return a promise rejected with a "NotAllowedError" DOMException. 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-protection.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-protection.https.html
new file mode 100644 (file)
index 0000000..b0582d5
--- /dev/null
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Tests for PaymentRequest.canMakePayment() 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 src='/resources/testdriver-vendor.js'></script>
+<script src="/resources/testdriver.js"></script>
+<script>
+const basicCard = Object.freeze({ supportedMethods: "basic-card" });
+const applePay = Object.freeze({ supportedMethods: "https://apple.com/apple-pay" });
+const defaultMethods = Object.freeze([basicCard, applePay]);
+const defaultDetails = Object.freeze({
+  total: {
+    label: "Total",
+    amount: {
+      currency: "USD",
+      value: "1.00",
+    },
+  },
+});
+
+promise_test(async t => {
+  // This test might never actually hit its assertion, but that's allowed.
+  const request = new PaymentRequest(defaultMethods, defaultDetails);
+  for (let i = 0; i < 1000; i++) {
+    try {
+      await request.canMakePayment();
+    } catch (err) {
+      assert_equals(
+        err.name,
+        "NotAllowedError",
+        "if it throws, then it must be a NotAllowedError."
+      );
+      break;
+    }
+  }
+  for (let i = 0; i < 1000; i++) {
+    try {
+      await new PaymentRequest(defaultMethods, defaultDetails).canMakePayment();
+    } catch (err) {
+      assert_equals(
+        err.name,
+        "NotAllowedError",
+        "if it throws, then it must be a NotAllowedError."
+      );
+      break;
+    }
+  }
+}, `Optionally, at the user agent's discretion, return a promise rejected with a "NotAllowedError" DOMException.`);
+</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>
index 617bd6e..f38caa0 100644 (file)
@@ -8,7 +8,10 @@
 <script src="/resources/testdriver.js"></script>
 <script>
 const basicCard = Object.freeze({ supportedMethods: "basic-card" });
-const defaultMethods = Object.freeze([basicCard]);
+const applePay = Object.freeze({
+  supportedMethods: "https://apple.com/apple-pay",
+});
+const defaultMethods = Object.freeze([basicCard, applePay]);
 const defaultDetails = Object.freeze({
   total: {
     label: "Total",
@@ -19,6 +22,64 @@ const defaultDetails = Object.freeze({
   },
 });
 
+const unsupportedMethods = [
+  { supportedMethods: "this-is-not-supported" },
+  { supportedMethods: "https://not.supported" },
+];
+
+promise_test(async t => {
+  const request = new PaymentRequest(defaultMethods, defaultDetails);
+  assert_true(
+    await request.canMakePayment(),
+    "one of the methods should be supported"
+  );
+}, `If payment method identifier are supported, resolve promise with true.`);
+
+promise_test(async t => {
+  const request = new PaymentRequest(defaultMethods, defaultDetails);
+  const acceptPromise = test_driver.bless("show payment request", () => {
+    request.show(); // Sets state to "interactive"
+  });
+  const canMakePaymentPromise = request.canMakePayment();
+  try {
+    const result = await canMakePaymentPromise;
+    assert_true(
+      false,
+      `canMakePaymentPromise should have thrown InvalidStateError`
+    );
+  } catch (err) {
+    await promise_rejects(t, "InvalidStateError", canMakePaymentPromise);
+  } finally {
+    await request.abort();
+    await promise_rejects(t, "AbortError", acceptPromise);
+  }
+  // The state should be "closed"
+  await promise_rejects(t, "InvalidStateError", request.canMakePayment());
+}, 'If request.[[state]] is "interactive", then return a promise rejected with an "InvalidStateError" DOMException.');
+
+promise_test(async t => {
+  const request = new PaymentRequest(defaultMethods, defaultDetails);
+  const acceptPromise = test_driver.bless("show payment request", () => {
+    request.show(); // Sets state to "interactive"
+  });
+  acceptPromise.catch(() => {}); // no-op, just to silence unhandled rejection in devtools.
+  await request.abort(); // The state is now "closed"
+  await promise_rejects(t, "InvalidStateError", request.canMakePayment());
+  try {
+    const result = await request.canMakePayment();
+    assert_true(
+      false,
+      `should have thrown InvalidStateError, but instead returned "${result}"`
+    );
+  } catch (err) {
+    assert_equals(
+      err.name,
+      "InvalidStateError",
+      "must be an InvalidStateError."
+    );
+  }
+}, 'If request.[[state]] is "closed", then return a promise rejected with an "InvalidStateError" DOMException.');
+
 promise_test(async t => {
   const request = new PaymentRequest(defaultMethods, defaultDetails);
   try {
@@ -40,144 +101,20 @@ promise_test(async t => {
 }, `If request.[[state]] is "created", then return a promise that resolves to true for known method.`);
 
 promise_test(async t => {
-  const request = new PaymentRequest(defaultMethods, defaultDetails);
-  assert_true(await request.canMakePayment(), "basic-card should be supported");
-}, `If payment method identifier and serialized parts are supported, resolve promise with true.`);
-
-promise_test(async t => {
-  const unsupportedMethods = [
-    "this-is-not-supported",
-    "https://not.supported",
-    "e",
-    "n6jzof05mk2g4lhxr-u-q-w1-c-i-pa-ty-bdvs9-ho-ae7-p-md8-s-wq3-h-qd-e-q-sa",
-    "a-b-q-n-s-pw0",
-    "m-u",
-    "s-l5",
-    "k9-f",
-    "m-l",
-    "u4-n-t",
-    "i488jh6-g18-fck-yb-v7-i",
-    "x-x-t-t-c34-o",
-    "https://wpt",
-    "https://wpt.fyi/",
-    "https://wpt.fyi/payment",
-    "https://wpt.fyi/payment-request",
-    "https://wpt.fyi/payment-request?",
-    "https://wpt.fyi/payment-request?this=is",
-    "https://wpt.fyi/payment-request?this=is&totally",
-    "https://wpt.fyi:443/payment-request?this=is&totally",
-    "https://wpt.fyi:443/payment-request?this=is&totally#fine",
-    "https://:@wpt.fyi:443/payment-request?this=is&totally#👍",
-    " \thttps://wpt\n ",
-    "https://xn--c1yn36f",
-    "https://點看",
-  ];
-  for (const method of unsupportedMethods) {
-    try {
-      const request = new PaymentRequest(
-        [{ supportedMethods: method }],
-        defaultDetails
-      );
-      assert_false(
-        await request.canMakePayment(),
-        `method "${method}" must not be supported`
-      );
-    } catch (err) {
-      assert_equals(
-        err.name,
-        "NotAllowedError",
-        "if it throws, then it must be a NotAllowedError."
-      );
-    }
-  }
-}, `If payment method identifier is unknown, resolve promise with false.`);
+  const noneSupported = new PaymentRequest(
+    unsupportedMethods,
+    defaultDetails
+  ).canMakePayment();
+  assert_false(await noneSupported, `methods must not be supported`);
+}, "All methods are unsupported");
 
 promise_test(async t => {
-  // This test might never actually hit its assertion, but that's allowed.
-  const request = new PaymentRequest(defaultMethods, defaultDetails);
-  for (let i = 0; i < 1000; i++) {
-    try {
-      await request.canMakePayment();
-    } catch (err) {
-      assert_equals(
-        err.name,
-        "NotAllowedError",
-        "if it throws, then it must be a NotAllowedError."
-      );
-      break;
-    }
-  }
-  for (let i = 0; i < 1000; i++) {
-    try {
-      await new PaymentRequest(defaultMethods, defaultDetails).canMakePayment();
-    } catch (err) {
-      assert_equals(
-        err.name,
-        "NotAllowedError",
-        "if it throws, then it must be a NotAllowedError."
-      );
-      break;
-    }
-  }
-}, `Optionally, at the user agent's discretion, return a promise rejected with a "NotAllowedError" DOMException.`);
-
-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"
-    const canMakePaymentPromise = request.canMakePayment();
-    try {
-      const result = await canMakePaymentPromise;
-      assert_true(
-        false,
-        `canMakePaymentPromise should have thrown InvalidStateError`
-      );
-    } catch (err) {
-      await promise_rejects(t, "InvalidStateError", canMakePaymentPromise);
-    } finally {
-      await request.abort();
-      await promise_rejects(t, "AbortError", acceptPromise);
-    }
-    // The state should be "closed"
-    await promise_rejects(t, "InvalidStateError", request.canMakePayment());
-  });
-}, 'If request.[[state]] is "interactive", then return a promise rejected with an "InvalidStateError" DOMException.');
-
-promise_test(t => {
-  return test_driver.bless("show payment request", async () => {
-    const request = new PaymentRequest(defaultMethods, defaultDetails);
-    const acceptPromise = request.show(); // The state is now "interactive"
-    acceptPromise.catch(() => {}); // no-op, just to silence unhandled rejection in devtools.
-    await request.abort(); // The state is now "closed"
-    await promise_rejects(t, "InvalidStateError", request.canMakePayment());
-    try {
-      const result = await request.canMakePayment();
-      assert_true(
-        false,
-        `should have thrown InvalidStateError, but instead returned "${result}"`
-      );
-    } catch (err) {
-      assert_equals(
-        err.name,
-        "InvalidStateError",
-        "must be an InvalidStateError."
-      );
-    }
-  });
-}, 'If request.[[state]] is "closed", then return a promise rejected with an "InvalidStateError" DOMException.');
-
-test(() => {
-  const request = new PaymentRequest(
-    [{ supportedMethods: "basic-card" }],
+  const someSupported = new PaymentRequest(
+    [...unsupportedMethods, ...defaultMethods],
     defaultDetails
-  );
-  const promises = new Set([
-    request.canMakePayment(),
-    request.canMakePayment(),
-    request.canMakePayment(),
-  ]);
-  assert_equals(promises.size, 3, "Must have three unique objects");
-}, "Calling canMakePayment() multiple times is always a new object.");
+  ).canMakePayment();
+  assert_true(await someSupported, `At least one method is expected to be supported.`);
+}, `Mix of supported and unsupported methods, at least one method is supported.`);
 </script>
 
 <small>
index b5997a0..99c25d1 100644 (file)
@@ -283,9 +283,6 @@ test(() => {
       [
         {
           supportedMethods: "https://wpt.fyi/payment-request",
-          data: {
-            supportedTypes: ["debit"],
-          },
         },
       ],
       {
index 455b65a..e5d0c7a 100644 (file)
@@ -20,7 +20,7 @@ test(() => {
 
 // Test for https://github.com/w3c/payment-request/pull/665
 test(() => {
-  const uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-4][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
+  const uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
   const request1 = new PaymentRequest(methods, {
     total,
   });
index 82821a9..16ed15e 100644 (file)
@@ -28,7 +28,7 @@ function checkCompletedCantRetry(button) {
     return promise_rejects(
       t,
       "InvalidStateError",
-      response.retry({}),
+      response.retry(),
       "response.[[complete]] is true, so rejects with InvalidStateError."
     );
   }, button.textContent.trim());
@@ -38,11 +38,11 @@ function repeatedCallsToRetry(button) {
   button.disabled = true;
   promise_test(async t => {
     const { response } = await getPaymentRequestResponse();
-    const retryPromise = response.retry({});
+    const retryPromise = response.retry();
     await promise_rejects(
       t,
       "InvalidStateError",
-      response.retry({}),
+      response.retry(),
       "Calling retry() again rejects with an InvalidStateError"
     );
     await retryPromise;
@@ -54,7 +54,7 @@ function callCompleteWhileRetrying(button) {
   button.disabled = true;
   promise_test(async t => {
     const { response } = await getPaymentRequestResponse();
-    const retryPromise = response.retry({});
+    const retryPromise = response.retry();
     await promise_rejects(
       t,
       "InvalidStateError",
@@ -70,7 +70,7 @@ function callingRequestAbortMustNotAbort(button) {
   button.disabled = true;
   promise_test(async t => {
     const { response, request } = await getPaymentRequestResponse();
-    const retryPromise = response.retry({});
+    const retryPromise = response.retry();
     await promise_rejects(
       t,
       "InvalidStateError",
@@ -87,12 +87,12 @@ function canRetryMultipleTimes(button) {
   promise_test(async t => {
     const { response } = await getPaymentRequestResponse();
     assert_equals(
-      await response.retry({}),
+      await response.retry(),
       undefined,
       "Expected undefined as the resolve value"
     );
     assert_equals(
-      await response.retry({}),
+      await response.retry(),
       undefined,
       "Expected undefined as the resolve value"
     );
@@ -100,7 +100,7 @@ function canRetryMultipleTimes(button) {
     await promise_rejects(
       t,
       "InvalidStateError",
-      response.retry({}),
+      response.retry(),
       "Calling retry() after complete() rejects with a InvalidStateError"
     );
   }, button.textContent.trim());
@@ -113,13 +113,13 @@ function userCanAbortARetry(button) {
     await promise_rejects(
       t,
       "AbortError",
-      response.retry({}),
+      response.retry(),
       "The user aborting a retry rejects with a AbortError"
     );
     await promise_rejects(
       t,
       "InvalidStateError",
-      response.retry({}),
+      response.retry(),
       "After the user aborts, response [[complete]] is true so retry() must reject with InvalidStateError"
     );
     await promise_rejects(
@@ -154,7 +154,7 @@ function abortTheUpdate(button) {
         resolve();
       };
     });
-    const retryPromise = response.retry({});
+    const retryPromise = response.retry();
     await shippingChangedPromise;
     await promise_rejects(
       t,
@@ -175,11 +175,11 @@ function callingRetryReturnsUniquePromise(button){
   button.disabled = true;
   promise_test(async t => {
     const { response } = await getPaymentRequestResponse();
-    const retryPromise = response.retry({});
+    const retryPromise = response.retry();
     const promises = new Set([
       retryPromise,
-      response.retry({}),
-      response.retry({}),
+      response.retry(),
+      response.retry(),
     ]);
     assert_equals(promises.size, 3, "Must have three unique objects");
     await retryPromise;
index 063d31b..f585e83 100644 (file)
@@ -4,6 +4,8 @@
 <title>PaymentRequest show() rejects if doc is not fully active</title>
 <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>
 <link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentrequest-show()">
 <body>
 <script>
@@ -39,50 +41,45 @@ function getLoadedPaymentRequest(iframe, url) {
 }
 
 promise_test(async t => {
-  // Check that PaymentRequests can be constructed.
-  new PaymentRequest(validMethods, validDetails);
   const iframe = document.createElement("iframe");
   iframe.allowPaymentRequest = true;
   document.body.appendChild(iframe);
-
   // We first got to page1.html, grab a PaymentRequest instance.
   const request1 = await getLoadedPaymentRequest(
     iframe,
     "/payment-request/resources/page1.html"
   );
-
   // We navigate the iframe again, putting request1's document into an inactive state.
   const request2 = await getLoadedPaymentRequest(
     iframe,
     "/payment-request/resources/page2.html"
   );
-
-  // Now, request1's relevant global object's document is no longer active.
-  // So, call .show(), and make sure it rejects appropriately.
-  await promise_rejects(
-    t,
-    "AbortError",
-    request1.show(),
-    "Inactive document, so must throw AbortError"
-  );
-
-  // request2 has an active document tho, so confirm it's working as expected:
-  request2.show();
-  await request2.abort();
-  await promise_rejects(
-    t,
-    "InvalidStateError",
-    request2.show(),
-    "Abort already called, so InvalidStateError"
-  );
-  // We are done, so clean up.
-  iframe.remove();
+  await test_driver.bless("show payment request", async () => {
+    // Now, request1's relevant global object's document is no longer active.
+    // So, call .show(), and make sure it rejects appropriately.
+    await promise_rejects(
+      t,
+      "AbortError",
+      request1.show(),
+      "Inactive document, so must throw AbortError"
+    );
+  });
+  await test_driver.bless("show payment request", async () => {
+    // request2 has an active document tho, so confirm it's working as expected:
+    request2.show();
+    await request2.abort();
+    await promise_rejects(
+      t,
+      "InvalidStateError",
+      request2.show(),
+      "Abort already called, so InvalidStateError"
+    );
+    // We are done, so clean up.
+    iframe.remove();
+  });
 }, "PaymentRequest.show() aborts if the document is not active");
 
 promise_test(async t => {
-  // check that PaymentRequests can be constructed (smoke test).
-  new PaymentRequest(validMethods, validDetails);
-
   // We nest two iframes and wait for them to load.
   const outerIframe = document.createElement("iframe");
   outerIframe.allowPaymentRequest = true;
@@ -112,6 +109,10 @@ promise_test(async t => {
     outerIframe.addEventListener("load", resolve);
     outerIframe.src = "/payment-request/resources/page2.html";
   });
+
+  const showPromise = await test_driver.bless("show payment request", () => {
+    return request.show();
+  });
   // Now, request's relevant global object's document is still active
   // (it is the active document of the inner iframe), but is not fully active
   // (since the parent of the inner iframe is itself no longer active).
@@ -119,16 +120,15 @@ promise_test(async t => {
   await promise_rejects(
     t,
     "AbortError",
-    request.show(),
+    showPromise,
     "Active, but not fully active, so must throw AbortError"
   );
   // We are done, so clean up.
+
   iframe.remove();
 }, "PaymentRequest.show() aborts if the document is active, but not fully active");
 
 promise_test(async t => {
-  // Check that PaymentRequests can be constructed.
-  new PaymentRequest(validMethods, validDetails);
   const iframe = document.createElement("iframe");
   iframe.allowPaymentRequest = true;
   document.body.appendChild(iframe);
@@ -137,8 +137,9 @@ promise_test(async t => {
     iframe,
     "/payment-request/resources/page1.html"
   );
-  // Present the payment sheet.
-  const showPromise = request.show();
+  const showPromise = await test_driver.bless("show payment request", () => {
+    return request.show();
+  });
   // Navigate the iframe to a new location. Wait for the load event to fire.
   await new Promise(resolve => {
     iframe.addEventListener("load", resolve);
index 17eab6b..7b522b5 100644 (file)
@@ -23,6 +23,7 @@ List of files:
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/onmerchantvalidation-attribute.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/onpaymentmenthodchange-attribute.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-protection.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-constructor-crash.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-constructor.https.html