[Payment Request] Update payment-request web platform tests
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Aug 2018 19:30:35 +0000 (19:30 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Aug 2018 19:30:35 +0000 (19:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188985

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

* web-platform-tests/payment-request/META.yml: Added.
* web-platform-tests/payment-request/OWNERS: Removed.
* web-platform-tests/payment-request/PaymentAddress/attributes-and-toJSON-method-manual.https.html:
* web-platform-tests/payment-request/PaymentAddress/w3c-import.log:
* web-platform-tests/payment-request/PaymentItem/type_member.https-expected.txt: Added.
* web-platform-tests/payment-request/PaymentItem/type_member.https.html: Added.
* web-platform-tests/payment-request/PaymentItem/w3c-import.log: Copied from LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log.
* web-platform-tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https-expected.txt: Added.
* web-platform-tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https.html: Added.
* web-platform-tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https-expected.txt: Added.
* web-platform-tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https.html: Added.
* web-platform-tests/payment-request/PaymentMethodChangeEvent/w3c-import.log: Copied from LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log.
* web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-error-member-manual.https.html: Added.
* web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html: Added.
* web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html: Added.
* web-platform-tests/payment-request/PaymentValidationErrors/w3c-import.log: Copied from LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log.
* web-platform-tests/payment-request/algorithms-manual.https.html:
* web-platform-tests/payment-request/allowpaymentrequest/w3c-import.log:
* web-platform-tests/payment-request/change-shipping-option-manual.https.html:
* web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html: Added.
* web-platform-tests/payment-request/idlharness.https.window-expected.txt: Added.
* web-platform-tests/payment-request/idlharness.https.window.html: Added.
* web-platform-tests/payment-request/idlharness.https.window.js: Added.
(idlArray.catch):
* web-platform-tests/payment-request/interfaces.https-expected.txt: Removed.
* web-platform-tests/payment-request/interfaces.https.html: Removed.
* web-platform-tests/payment-request/onpaymentmenthodchange-attribute.https-expected.txt: Added.
* web-platform-tests/payment-request/onpaymentmenthodchange-attribute.https.html: Added.
* web-platform-tests/payment-request/payment-request-abort-method-manual.https-expected.txt: Removed.
* web-platform-tests/payment-request/payment-request-abort-method.https-expected.txt: Added.
* web-platform-tests/payment-request/payment-request-abort-method.https.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method-manual.https.html.
* web-platform-tests/payment-request/payment-request-canmakepayment-method.https-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-manual.https-expected.txt.
* web-platform-tests/payment-request/payment-request-canmakepayment-method.https.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-manual.https.html.
* web-platform-tests/payment-request/payment-request-insecure.http-expected.txt: Added.
* web-platform-tests/payment-request/payment-request-insecure.http.html: Added.
* web-platform-tests/payment-request/payment-request-not-exposed.https.worker-expected.txt: Added.
* web-platform-tests/payment-request/payment-request-not-exposed.https.worker.html: Added.
* web-platform-tests/payment-request/payment-request-not-exposed.https.worker.js: Added.
(test):
* web-platform-tests/payment-request/payment-request-show-method.https.html:
* web-platform-tests/payment-request/payment-response/complete-method-manual.https.html:
* web-platform-tests/payment-request/payment-response/helpers.js:
(async.getPaymentResponse):
* web-platform-tests/payment-request/payment-response/methodName-attribute-manual.https.html:
* web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https-expected.txt: Added.
* web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https.html: Added.
* web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html: Added.
* web-platform-tests/payment-request/payment-response/payerEmail-attribute-manual.https.html:
* web-platform-tests/payment-request/payment-response/payerName-attribute-manual.https.html:
* web-platform-tests/payment-request/payment-response/payerPhone-attribute-manual.https.html:
* web-platform-tests/payment-request/payment-response/rejects_if_not_active-manual.https.html: Added.
* web-platform-tests/payment-request/payment-response/requestId-attribute-manual.https.html:
* web-platform-tests/payment-request/payment-response/retry-method-manual.https.html: Added.
* web-platform-tests/payment-request/payment-response/shippingAddress-attribute-manual.https.html:
* web-platform-tests/payment-request/payment-response/shippingOption-attribute-manual.https.html:
* web-platform-tests/payment-request/payment-response/w3c-import.log:
* web-platform-tests/payment-request/resources/w3c-import.log:
* web-platform-tests/payment-request/shipping-address-changed-manual.https.html:
* web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html: Added.
* web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html: Added.
* web-platform-tests/payment-request/show-method-postmessage-iframe.html: Added.
* web-platform-tests/payment-request/show-method-postmessage-manual.https.html: Added.
* web-platform-tests/payment-request/updateWith-method-pmi-handling-manual.https.html:
* web-platform-tests/payment-request/user-abort-algorithm-manual.https.html:
* web-platform-tests/payment-request/user-accepts-payment-request-algo-manual.https.html:
* web-platform-tests/payment-request/w3c-import.log:

LayoutTests:

* platform/mac-wk2/TestExpectations:

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

66 files changed:
LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/payment-request/META.yml [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/OWNERS [deleted file]
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/attributes-and-toJSON-method-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/w3c-import.log [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/w3c-import.log [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-error-member-manual.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/w3c-import.log [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/algorithms-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/w3c-import.log
LayoutTests/imported/w3c/web-platform-tests/payment-request/change-shipping-option-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/idlharness.https.window-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/idlharness.https.window.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/idlharness.https.window.js [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/interfaces.https-expected.txt [deleted file]
LayoutTests/imported/w3c/web-platform-tests/payment-request/interfaces.https.html [deleted file]
LayoutTests/imported/w3c/web-platform-tests/payment-request/onpaymentmenthodchange-attribute.https-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/onpaymentmenthodchange-attribute.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method-manual.https-expected.txt [deleted file]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html [moved from LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method-manual.https.html with 67% similarity]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method.https-expected.txt [moved from LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-manual.https-expected.txt with 51% similarity]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method.https.html [moved from LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-manual.https.html with 82% similarity]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.js [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/complete-method-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/helpers.js
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/methodName-attribute-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/payerEmail-attribute-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/payerName-attribute-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/payerPhone-attribute-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/rejects_if_not_active-manual.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/requestId-attribute-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/retry-method-manual.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/shippingAddress-attribute-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/shippingOption-attribute-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/w3c-import.log
LayoutTests/imported/w3c/web-platform-tests/payment-request/resources/w3c-import.log
LayoutTests/imported/w3c/web-platform-tests/payment-request/shipping-address-changed-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-iframe.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-manual.https.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/payment-request/updateWith-method-pmi-handling-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/user-abort-algorithm-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/user-accepts-payment-request-algo-manual.https.html
LayoutTests/imported/w3c/web-platform-tests/payment-request/w3c-import.log
LayoutTests/platform/mac-wk2/TestExpectations

index 9ecf660..cc4adee 100644 (file)
@@ -1,3 +1,12 @@
+2018-08-27  Andy Estes  <aestes@apple.com>
+
+        [Payment Request] Update payment-request web platform tests
+        https://bugs.webkit.org/show_bug.cgi?id=188985
+
+        Reviewed by Youenn Fablet.
+
+        * platform/mac-wk2/TestExpectations:
+
 2018-08-27  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: provide autocompletion for event breakpoints
index 94ec65c..f36cec5 100644 (file)
@@ -1,3 +1,77 @@
+2018-08-27  Andy Estes  <aestes@apple.com>
+
+        [Payment Request] Update payment-request web platform tests
+        https://bugs.webkit.org/show_bug.cgi?id=188985
+
+        Reviewed by Youenn Fablet.
+
+        * web-platform-tests/payment-request/META.yml: Added.
+        * web-platform-tests/payment-request/OWNERS: Removed.
+        * web-platform-tests/payment-request/PaymentAddress/attributes-and-toJSON-method-manual.https.html:
+        * web-platform-tests/payment-request/PaymentAddress/w3c-import.log:
+        * web-platform-tests/payment-request/PaymentItem/type_member.https-expected.txt: Added.
+        * web-platform-tests/payment-request/PaymentItem/type_member.https.html: Added.
+        * web-platform-tests/payment-request/PaymentItem/w3c-import.log: Copied from LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log.
+        * web-platform-tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https-expected.txt: Added.
+        * web-platform-tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https.html: Added.
+        * web-platform-tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https-expected.txt: Added.
+        * web-platform-tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https.html: Added.
+        * web-platform-tests/payment-request/PaymentMethodChangeEvent/w3c-import.log: Copied from LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log.
+        * web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-error-member-manual.https.html: Added.
+        * web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html: Added.
+        * web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html: Added.
+        * web-platform-tests/payment-request/PaymentValidationErrors/w3c-import.log: Copied from LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log.
+        * web-platform-tests/payment-request/algorithms-manual.https.html:
+        * web-platform-tests/payment-request/allowpaymentrequest/w3c-import.log:
+        * web-platform-tests/payment-request/change-shipping-option-manual.https.html:
+        * web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html: Added.
+        * web-platform-tests/payment-request/idlharness.https.window-expected.txt: Added.
+        * web-platform-tests/payment-request/idlharness.https.window.html: Added.
+        * web-platform-tests/payment-request/idlharness.https.window.js: Added.
+        (idlArray.catch):
+        * web-platform-tests/payment-request/interfaces.https-expected.txt: Removed.
+        * web-platform-tests/payment-request/interfaces.https.html: Removed.
+        * web-platform-tests/payment-request/onpaymentmenthodchange-attribute.https-expected.txt: Added.
+        * web-platform-tests/payment-request/onpaymentmenthodchange-attribute.https.html: Added.
+        * web-platform-tests/payment-request/payment-request-abort-method-manual.https-expected.txt: Removed.
+        * web-platform-tests/payment-request/payment-request-abort-method.https-expected.txt: Added.
+        * web-platform-tests/payment-request/payment-request-abort-method.https.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method-manual.https.html.
+        * web-platform-tests/payment-request/payment-request-canmakepayment-method.https-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-manual.https-expected.txt.
+        * web-platform-tests/payment-request/payment-request-canmakepayment-method.https.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-manual.https.html.
+        * web-platform-tests/payment-request/payment-request-insecure.http-expected.txt: Added.
+        * web-platform-tests/payment-request/payment-request-insecure.http.html: Added.
+        * web-platform-tests/payment-request/payment-request-not-exposed.https.worker-expected.txt: Added.
+        * web-platform-tests/payment-request/payment-request-not-exposed.https.worker.html: Added.
+        * web-platform-tests/payment-request/payment-request-not-exposed.https.worker.js: Added.
+        (test):
+        * web-platform-tests/payment-request/payment-request-show-method.https.html:
+        * web-platform-tests/payment-request/payment-response/complete-method-manual.https.html:
+        * web-platform-tests/payment-request/payment-response/helpers.js:
+        (async.getPaymentResponse):
+        * web-platform-tests/payment-request/payment-response/methodName-attribute-manual.https.html:
+        * web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https-expected.txt: Added.
+        * web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https.html: Added.
+        * web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html: Added.
+        * web-platform-tests/payment-request/payment-response/payerEmail-attribute-manual.https.html:
+        * web-platform-tests/payment-request/payment-response/payerName-attribute-manual.https.html:
+        * web-platform-tests/payment-request/payment-response/payerPhone-attribute-manual.https.html:
+        * web-platform-tests/payment-request/payment-response/rejects_if_not_active-manual.https.html: Added.
+        * web-platform-tests/payment-request/payment-response/requestId-attribute-manual.https.html:
+        * web-platform-tests/payment-request/payment-response/retry-method-manual.https.html: Added.
+        * web-platform-tests/payment-request/payment-response/shippingAddress-attribute-manual.https.html:
+        * web-platform-tests/payment-request/payment-response/shippingOption-attribute-manual.https.html:
+        * web-platform-tests/payment-request/payment-response/w3c-import.log:
+        * web-platform-tests/payment-request/resources/w3c-import.log:
+        * web-platform-tests/payment-request/shipping-address-changed-manual.https.html:
+        * web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html: Added.
+        * web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html: Added.
+        * web-platform-tests/payment-request/show-method-postmessage-iframe.html: Added.
+        * web-platform-tests/payment-request/show-method-postmessage-manual.https.html: Added.
+        * web-platform-tests/payment-request/updateWith-method-pmi-handling-manual.https.html:
+        * web-platform-tests/payment-request/user-abort-algorithm-manual.https.html:
+        * web-platform-tests/payment-request/user-accepts-payment-request-algo-manual.https.html:
+        * web-platform-tests/payment-request/w3c-import.log:
+
 2018-08-27  Youenn Fablet  <youenn@apple.com>
 
         Update WPT tools to 87329a1
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/META.yml b/LayoutTests/imported/w3c/web-platform-tests/payment-request/META.yml
new file mode 100644 (file)
index 0000000..f8460d4
--- /dev/null
@@ -0,0 +1,8 @@
+spec: https://w3c.github.io/payment-request/
+suggested_reviewers:
+  - marcoscaceres
+  - rsolomakhin
+  - domenic
+  - MSFTkihans
+  - mnoorenberghe
+  - romandev
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/OWNERS b/LayoutTests/imported/w3c/web-platform-tests/payment-request/OWNERS
deleted file mode 100644 (file)
index 7f3eca7..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-@marcoscaceres
-@rsolomakhin
-@domenic
-@MSFTkihans
-@mnoorenberghe
-@edenchuang
index 3925cdd..65d56e7 100644 (file)
@@ -68,7 +68,7 @@ function runManualTest(button, expected = {}) {
     <button onclick="
     const expectedAddress = {
       country: 'AU',
-      regionCode: 'AU-QLD',
+      regionCode: 'QLD',
       addressLine: '55 test st',
       city: 'Chapel Hill',
       dependentLocality: '',
@@ -90,8 +90,10 @@ function runManualTest(button, expected = {}) {
       <dd>55 test st</dd>
       <dt>Country</dt>
       <dd>Australia</dd>
-      <dt>Suburb</dt>
+      <dt>City</dt>
       <dd>Chapel Hill</dd>
+      <dd>State/Region</dd>
+      <dd>Queensland</dd>
       <dt>postal code </dt>
       <dd>6095</dd>
       <dt>organization</dt>
@@ -102,6 +104,6 @@ function runManualTest(button, expected = {}) {
   </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>.
+  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 8ccdd39..4d9043c 100644 (file)
@@ -1,7 +1,7 @@
 The tests in this directory were imported from the W3C repository.
 Do NOT modify these tests directly in WebKit.
 Instead, create a pull request on the WPT github:
-       https://github.com/w3c/web-platform-tests
+       https://github.com/web-platform-tests/wpt
 
 Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
 
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https-expected.txt
new file mode 100644 (file)
index 0000000..e6b0201
--- /dev/null
@@ -0,0 +1,10 @@
+
+PASS Smoke test 
+FAIL An invalid enum value for PaymentDetailsInit.total's type throws TypeError assert_throws: function "() => {
+    new PaymentRequest(validMethods, invalidDetails);
+  }" did not throw
+FAIL Invalid enum value for PaymentItem.type member throws a TypeError assert_throws: function "() => {
+    new PaymentRequest(validMethods, invalidDetails);
+  }" did not throw
+PASS Valid enum values for PaymentItem.type member does not throw 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https.html
new file mode 100644 (file)
index 0000000..dc62a83
--- /dev/null
@@ -0,0 +1,77 @@
+<!doctype html>
+<meta charset="utf8">
+<link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentitem-type">
+<title>
+  PaymentItem type member
+</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+const validMethods = [
+  { supportedMethods: "basic-card" },
+  { supportedMethods: "https://apple.com/apple-pay" },
+];
+const validTotal = {
+  label: "Total",
+  amount: {
+    currency: "USD",
+    value: "5.00",
+  },
+};
+const validDisplayItem = {
+  label: "Item",
+  amount: {
+    currency: "USD",
+    value: "1.00",
+  },
+};
+const validDetails = {
+  total: validTotal,
+  displayItems: [validDisplayItem],
+};
+
+test(() => {
+  new PaymentRequest(validMethods, validDetails);
+}, "Smoke test");
+
+test(() => {
+  // Let's make an invalid DisplayItem for the total
+  const invalidTotal = Object.assign({}, validTotal, {
+    type: "this is not valid",
+  });
+  const invalidDetails = Object.assign({}, validDetails, {
+    total: invalidTotal,
+  });
+  assert_throws(new TypeError(), () => {
+    new PaymentRequest(validMethods, invalidDetails);
+  });
+}, "An invalid enum value for PaymentDetailsInit.total's type throws TypeError");
+
+test(() => {
+  // Let's make an invalid DisplayItem to add to displayItems
+  const invalidDisplayItem = Object.assign({}, validDisplayItem, {
+    type: "this is not valid",
+  });
+  const invalidDetails = Object.assign({}, validDetails, {
+    displayItems: [invalidDisplayItem, validDisplayItem],
+  });
+  assert_throws(new TypeError(), () => {
+    new PaymentRequest(validMethods, invalidDetails);
+  });
+}, "Invalid enum value for PaymentItem.type member throws a TypeError");
+
+test(() => {
+  // Let's make an invalid DisplayItem to add to displayItems
+  const taxDisplayItem = Object.assign({}, validDisplayItem, { type: "tax" });
+  const taxTotal = Object.assign({}, validTotal, { type: "tax" });
+  const validDetailsWithType = Object.assign({}, validDetails, {
+    total: taxTotal,
+    displayItems: [taxDisplayItem],
+  });
+  try {
+    new PaymentRequest(validMethods, validDetailsWithType);
+  } catch (err) {
+    assert_unexpected(err.message);
+  }
+}, "Valid enum values for PaymentItem.type member does not throw");
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/w3c-import.log
new file mode 100644 (file)
index 0000000..fc26959
--- /dev/null
@@ -0,0 +1,17 @@
+The tests in this directory were imported from the W3C repository.
+Do NOT modify these tests directly in WebKit.
+Instead, create a pull request on the WPT github:
+       https://github.com/web-platform-tests/wpt
+
+Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
+
+Do NOT modify or remove this file.
+
+------------------------------------------------------------------------
+Properties requiring vendor prefixes:
+None
+Property values requiring vendor prefixes:
+None
+------------------------------------------------------------------------
+List of files:
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https.html
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https-expected.txt
new file mode 100644 (file)
index 0000000..71d1b49
--- /dev/null
@@ -0,0 +1,3 @@
+
+FAIL Must have a methodDetails IDL attribute, which is initialized with to the methodName dictionary value Can't find variable: PaymentMethodChangeEvent
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https.html
new file mode 100644 (file)
index 0000000..a478c55
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Test for PaymentMethodChangeEvent.methodDetails attribute</title>
+<link rel="help" href="https://w3c.github.io/browser-payment-api/#dom-paymentmethodchangeevent-methoddetails">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+"use strict";
+test(() => {
+  const methodDetails = {
+    test: "pass"
+  }
+  const event = new PaymentMethodChangeEvent("test", {
+    methodName: "wpt-test",
+    methodDetails
+  });
+  assert_idl_attribute(event, "methodDetails");
+  const { test } = event.methodDetails;
+  assert_equals(test, "pass");
+  assert_equals(event.methodDetails, methodDetails);
+}, "Must have a methodDetails IDL attribute, which is initialized with to the methodName dictionary value");
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https-expected.txt
new file mode 100644 (file)
index 0000000..2dd6080
--- /dev/null
@@ -0,0 +1,3 @@
+
+FAIL Must have a methodName IDL attribute, which is initialized with to the methodName dictionary value Can't find variable: PaymentMethodChangeEvent
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https.html
new file mode 100644 (file)
index 0000000..e6e0bf9
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Test for PaymentMethodChangeEvent.methodName attribute</title>
+<link rel="help" href="https://w3c.github.io/browser-payment-api/#dom-paymentmethodchangeevent-src">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+"use strict";
+test(() => {
+  const event = new PaymentMethodChangeEvent("test", {
+    methodName: "wpt-test",
+  });
+  assert_idl_attribute(event, "methodName");
+  const { methodName } = event;
+  assert_equals(methodName, "wpt-test");
+}, "Must have a methodName IDL attribute, which is initialized with to the methodName dictionary value");
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/w3c-import.log
new file mode 100644 (file)
index 0000000..dd5f251
--- /dev/null
@@ -0,0 +1,18 @@
+The tests in this directory were imported from the W3C repository.
+Do NOT modify these tests directly in WebKit.
+Instead, create a pull request on the WPT github:
+       https://github.com/web-platform-tests/wpt
+
+Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
+
+Do NOT modify or remove this file.
+
+------------------------------------------------------------------------
+Properties requiring vendor prefixes:
+None
+Property values requiring vendor prefixes:
+None
+------------------------------------------------------------------------
+List of files:
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https.html
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-error-member-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-error-member-manual.https.html
new file mode 100644 (file)
index 0000000..b3a539e
--- /dev/null
@@ -0,0 +1,50 @@
+<!doctype html>
+<meta charset="utf8">
+<link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentvalidationerrors-error">
+<title>
+  PaymentValidationErrors' `error` member
+</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../payment-response/helpers.js"></script>
+<script>
+function retryShowsErrorMember(button) {
+  button.disabled = true;
+  promise_test(async t => {
+    const { response } = await getPaymentRequestResponse();
+    await response.retry({ error: "PASS" });
+    await response.complete("success");
+  }, button.textContent.trim());
+}
+</script>
+<h2>
+  Manual Test for PaymentValidationErrors's `error` member - Please run in order!
+</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 presented with the payment sheet, use any card and select to "Pay".
+  You will be asked to retry the payment and an error should be shown somewhere
+  in the UI. The expected error string is described in each individual test.
+  If you see the error, hit "Pay" again. If you don't see the error,
+  abort the payment request by hitting "esc" - which means that particular test
+  has failed.
+</p>
+<ol>
+  <li>
+    <button onclick="retryShowsErrorMember(this);">
+      The payment sheet shows the error "PASS" somewhere in the UI.
+    </button>
+  </li>
+  <li>
+    <button onclick="done();">
+      Done!
+    </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>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html
new file mode 100644 (file)
index 0000000..8dbc760
--- /dev/null
@@ -0,0 +1,65 @@
+<!doctype html>
+<meta charset="utf8">
+<link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentvalidationerrors-payer">
+<title>
+  PaymentValidationErrors' `payer` member
+</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../payment-response/helpers.js"></script>
+<script>
+function retryShowsPayerMember(button, error) {
+  button.disabled = true;
+  promise_test(async t => {
+    const options = {
+      requestPayerName: true,
+      requestPayerEmail: true,
+      requestPayerPhone: true,
+    }
+    const { response } = await getPaymentRequestResponse(options);
+    await response.retry({ payer: error });
+    await response.complete("success");
+  }, button.textContent.trim());
+}
+</script>
+<h2>
+  Manual Test for PaymentValidationErrors' `payer` member - Please run in order!
+</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 presented with the payment sheet, use any card and select to "Pay".
+  You will be asked to retry the payment and an error should be shown somewhere
+  in the UI. The expected error string is described in each individual test.
+  If you see the error, hit "Pay" again. If you don't see the error,
+  abort the payment request by hitting "esc" - which means that particular test
+  has failed.
+</p>
+<ol>
+  <li>
+    <button onclick="retryShowsPayerMember(this, { email: 'EMAIL ERROR' });">
+      The payment sheet shows "EMAIL ERROR" for the payer's email.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsPayerMember(this, { name: 'NAME ERROR' });">
+      The payment sheet shows "NAME ERROR" for the payer's name.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsPayerMember(this, { phone: 'PHONE ERROR' });">
+      The payment sheet shows "PHONE ERROR" for the payer's phone number.
+    </button>
+  </li>
+  <li>
+    <button onclick="done();">
+      Done!
+    </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>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html
new file mode 100644 (file)
index 0000000..cdc8d35
--- /dev/null
@@ -0,0 +1,108 @@
+<!doctype html>
+<meta charset="utf8">
+<link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentvalidationerrors-shippingaddress">
+<title>
+  PaymentValidationErrors' `shippingAddress` member (AddressErrors)
+</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../payment-response/helpers.js"></script>
+<script>
+function retryShowsShippingAddressMember(button, error) {
+  button.disabled = true;
+  promise_test(async t => {
+    const options = {
+      requestShipping: true,
+    }
+    const { response } = await getPaymentRequestResponse(options);
+    await response.retry({ shippingAddress: error });
+    await response.complete("success");
+  }, button.textContent.trim());
+}
+</script>
+<h2>
+  Manual Test for PaymentValidationErrors' `shippingAddress` member - Please run in order!
+</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 presented with the payment sheet, use any card and select to "Pay".
+  You will be asked to retry the payment and an error should be shown somewhere
+  in the UI. The expected error string is described in each individual test.
+  If you see the error, hit "Pay" again. If you don't see the error,
+  abort the payment request by hitting "esc" - which means that particular test
+  has failed.
+</p>
+<ol>
+  <li>
+    <button onclick="retryShowsShippingAddressMember(this, { addressLine: 'ADDRESSLINE ERROR' });">
+      The payment sheet shows "ADDRESSLINE ERROR" for the shipping address' addressLine.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsShippingAddressMember(this, { city: 'CITY ERROR' });">
+      The payment sheet shows "CITY ERROR" for the shipping address' city.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsShippingAddressMember(this, { country: 'COUNTRY ERROR' });">
+      The payment sheet shows "COUNTRY ERROR" for the shipping address' country.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsShippingAddressMember(this, { dependentLocality: 'DEPENDENTLOCALITY ERROR' });">
+      The payment sheet shows "DEPENDENTLOCALITY ERROR" for the shipping address' dependentLocality.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsShippingAddressMember(this, { languageCode: 'LANGUAGECODE ERROR' });">
+      The payment sheet shows "LANGUAGECODE ERROR" for the shipping address' languageCode.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsShippingAddressMember(this, { organization: 'ORGANIZATION ERROR' });">
+      The payment sheet shows "ORGANIZATION ERROR" for the shipping address' organization.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsShippingAddressMember(this, { phone: 'PHONE ERROR' });">
+      The payment sheet shows "PHONE ERROR" for the shipping address' phone.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsShippingAddressMember(this, { postalCode: 'POSTALCODE ERROR' });">
+      The payment sheet shows "POSTALCODE ERROR" for the shipping address' postal code.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsShippingAddressMember(this, { recipient: 'RECIPIENT ERROR' });">
+      The payment sheet shows "RECIPIENT ERROR" for the shipping address' recipient.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsShippingAddressMember(this, { region: 'REGION ERROR' });">
+      The payment sheet shows "REGION ERROR" for the shipping address' region.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsShippingAddressMember(this, { regionCode: 'REGIONCODE ERROR' });">
+      The payment sheet shows "REGIONCODE ERROR" for the shipping address' region code.
+    </button>
+  </li>
+  <li>
+    <button onclick="retryShowsShippingAddressMember(this, { sortingCode: 'SORTINGCODE ERROR' });">
+      The payment sheet shows "SORTINGCODE ERROR" for the shipping address' sorting code.
+    </button>
+  </li>
+  <li>
+    <button onclick="done();">
+      Done!
+    </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>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/w3c-import.log
new file mode 100644 (file)
index 0000000..948c4f5
--- /dev/null
@@ -0,0 +1,19 @@
+The tests in this directory were imported from the W3C repository.
+Do NOT modify these tests directly in WebKit.
+Instead, create a pull request on the WPT github:
+       https://github.com/web-platform-tests/wpt
+
+Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
+
+Do NOT modify or remove this file.
+
+------------------------------------------------------------------------
+Properties requiring vendor prefixes:
+None
+Property values requiring vendor prefixes:
+None
+------------------------------------------------------------------------
+List of files:
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-error-member-manual.https.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html
index 2e4140a..5494353 100644 (file)
@@ -161,6 +161,6 @@ async function runAbortTest(button) {
 </section>
 
 <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>.
+  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 4f0acc0..632f466 100644 (file)
@@ -1,7 +1,7 @@
 The tests in this directory were imported from the W3C repository.
 Do NOT modify these tests directly in WebKit.
 Instead, create a pull request on the WPT github:
-       https://github.com/w3c/web-platform-tests
+       https://github.com/web-platform-tests/wpt
 
 Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
 
index eefc45f..a33365b 100644 (file)
@@ -89,6 +89,6 @@ function testShippingOptionChanged() {
   </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>.
+  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>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html
new file mode 100644 (file)
index 0000000..f084911
--- /dev/null
@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Test for PaymentDetailsBase's shippingOptions member</title>
+<link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentdetailsbase-shippingoptions">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+setup({ explicit_done: true, explicit_timeout: true });
+const validMethods = Object.freeze([
+  { supportedMethods: "basic-card" },
+  { supportedMethods: "https://apple.com/apple-pay" },
+]);
+const validAmount = Object.freeze({ currency: "USD", value: "5.00" });
+const validTotal = Object.freeze({
+  label: "label",
+  amount: validAmount,
+});
+const validDetails = Object.freeze({ total: validTotal });
+
+const validShippingOption1 = Object.freeze({
+  id: "fail-if-selected-1",
+  label: "FAIL if selected 1",
+  amount: validAmount,
+  selected: true,
+});
+
+const validShippingOption2 = Object.freeze({
+  id: "fail-if-selected-2",
+  label: "FAIL if selected 2",
+  amount: validAmount,
+  selected: false,
+});
+
+const validShippingOption3 = Object.freeze({
+  id: "pass-if-selected",
+  label: "THIS MUST BE AUTOMATICALLY SELECTED",
+  amount: validAmount,
+  selected: true,
+});
+
+function testShippingOptionChanged(button) {
+  button.disabled = true;
+  promise_test(async t => {
+    const detailsWithShippingOptions = {
+      ...validDetails,
+      shippingOptions: [
+        validShippingOption1,
+        validShippingOption2,
+        validShippingOption3,
+      ],
+    };
+    const request = new PaymentRequest(
+      validMethods,
+      detailsWithShippingOptions,
+      { requestShipping: true }
+    );
+    assert_equals(
+      request.shippingOption,
+      "pass-if-selected",
+      "Must be 'pass-if-selected', as the selected member is true"
+    );
+    request.onshippingoptionchange = () => {
+      assert_unreached("onshippingoptionchange fired unexpectedly");
+    };
+    const response = await request.show();
+    assert_equals(response.shippingOption, "pass-if-selected");
+    response.complete();
+  }, button.textContent.trim());
+  done();
+}
+</script>
+
+<h2>PaymentRequest shippingOption attribute</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, hit pay.
+</p>
+<ol>
+  <li>
+    <button onclick="testShippingOptionChanged(this)">
+      When default shipping option is pre-selected, must not fire onshippingoptionchange
+      and PaymentResponse must reflect the pre-selected option.
+    </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>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/idlharness.https.window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/idlharness.https.window-expected.txt
new file mode 100644 (file)
index 0000000..0b7fee0
--- /dev/null
@@ -0,0 +1,4 @@
+CONSOLE MESSAGE: line 8: ReferenceError: Can't find variable: idl_test
+
+FAIL Untitled ReferenceError: Can't find variable: idl_test
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/idlharness.https.window.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/idlharness.https.window.html
new file mode 100644 (file)
index 0000000..2382913
--- /dev/null
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/idlharness.https.window.js b/LayoutTests/imported/w3c/web-platform-tests/payment-request/idlharness.https.window.js
new file mode 100644 (file)
index 0000000..9a068c6
--- /dev/null
@@ -0,0 +1,30 @@
+// META: script=/resources/WebIDLParser.js
+// META: script=/resources/idlharness.js
+
+'use strict';
+
+// https://w3c.github.io/payment-request/
+
+idl_test(
+  ['payment-request'],
+  ['dom', 'html'],
+  idlArray => {
+    try {
+      const methods = [
+        {supportedMethods: 'basic-card'},
+        {supportedMethods: 'https://apple.com/apple-pay'},
+      ];
+      const amount = {currency: 'USD', value: '0'};
+      const details = {total: {label: 'label', amount: amount} };
+      window.paymentRequest = new PaymentRequest(methods, details);
+    } catch (e) {
+      // Surfaced below when paymentRequest is undefined.
+    }
+
+    idlArray.add_objects({
+      PaymentRequest: ['paymentRequest'],
+      PaymentMethodChangeEvent: ['new PaymentMethodChangeEvent("paymentmethodchange")'],
+      PaymentRequestUpdateEvent: ['new PaymentRequestUpdateEvent("paymentrequestupdate")'],
+    });
+  }
+);
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/interfaces.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/interfaces.https-expected.txt
deleted file mode 100644 (file)
index 6aaf39d..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-CONSOLE MESSAGE: line 331: callback not yet supported
-CONSOLE MESSAGE: line 331: callback not yet supported
-
-PASS Setup for Payment Request API IDL tests. 
-PASS PaymentRequest interface: existence and properties of interface object 
-PASS PaymentRequest interface object length 
-PASS PaymentRequest interface object name 
-PASS PaymentRequest interface: existence and properties of interface prototype object 
-PASS PaymentRequest interface: existence and properties of interface prototype object's "constructor" property 
-PASS PaymentRequest interface: existence and properties of interface prototype object's @@unscopables property 
-PASS PaymentRequest interface: operation show() 
-PASS Unscopable handled correctly for show() on PaymentRequest 
-PASS PaymentRequest interface: operation abort() 
-PASS Unscopable handled correctly for abort() on PaymentRequest 
-PASS PaymentRequest interface: operation canMakePayment() 
-PASS Unscopable handled correctly for canMakePayment() on PaymentRequest 
-PASS PaymentRequest interface: attribute id 
-PASS Unscopable handled correctly for id property on PaymentRequest 
-PASS PaymentRequest interface: attribute shippingAddress 
-PASS Unscopable handled correctly for shippingAddress property on PaymentRequest 
-PASS PaymentRequest interface: attribute shippingOption 
-PASS Unscopable handled correctly for shippingOption property on PaymentRequest 
-PASS PaymentRequest interface: attribute shippingType 
-PASS Unscopable handled correctly for shippingType property on PaymentRequest 
-PASS PaymentRequest interface: attribute onshippingaddresschange 
-PASS Unscopable handled correctly for onshippingaddresschange property on PaymentRequest 
-PASS PaymentRequest interface: attribute onshippingoptionchange 
-PASS Unscopable handled correctly for onshippingoptionchange property on PaymentRequest 
-PASS PaymentRequest must be primary interface of new PaymentRequest([{supportedMethods: 'foo'}], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} }) 
-PASS Stringification of new PaymentRequest([{supportedMethods: 'foo'}], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} }) 
-PASS PaymentRequest interface: new PaymentRequest([{supportedMethods: 'foo'}], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} }) must inherit property "show()" with the proper type 
-PASS PaymentRequest interface: new PaymentRequest([{supportedMethods: 'foo'}], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} }) must inherit property "abort()" with the proper type 
-PASS PaymentRequest interface: new PaymentRequest([{supportedMethods: 'foo'}], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} }) must inherit property "canMakePayment()" with the proper type 
-PASS PaymentRequest interface: new PaymentRequest([{supportedMethods: 'foo'}], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} }) must inherit property "id" with the proper type 
-PASS PaymentRequest interface: new PaymentRequest([{supportedMethods: 'foo'}], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} }) must inherit property "shippingAddress" with the proper type 
-PASS PaymentRequest interface: new PaymentRequest([{supportedMethods: 'foo'}], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} }) must inherit property "shippingOption" with the proper type 
-PASS PaymentRequest interface: new PaymentRequest([{supportedMethods: 'foo'}], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} }) must inherit property "shippingType" with the proper type 
-PASS PaymentRequest interface: new PaymentRequest([{supportedMethods: 'foo'}], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} }) must inherit property "onshippingaddresschange" with the proper type 
-PASS PaymentRequest interface: new PaymentRequest([{supportedMethods: 'foo'}], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} }) must inherit property "onshippingoptionchange" with the proper type 
-PASS PaymentAddress interface: existence and properties of interface object 
-PASS PaymentAddress interface object length 
-PASS PaymentAddress interface object name 
-PASS PaymentAddress interface: existence and properties of interface prototype object 
-PASS PaymentAddress interface: existence and properties of interface prototype object's "constructor" property 
-PASS PaymentAddress interface: existence and properties of interface prototype object's @@unscopables property 
-PASS PaymentAddress interface: operation toJSON() 
-PASS Unscopable handled correctly for toJSON() on PaymentAddress 
-PASS PaymentAddress interface: attribute country 
-PASS Unscopable handled correctly for country property on PaymentAddress 
-PASS PaymentAddress interface: attribute addressLine 
-PASS Unscopable handled correctly for addressLine property on PaymentAddress 
-PASS PaymentAddress interface: attribute region 
-PASS Unscopable handled correctly for region property on PaymentAddress 
-FAIL PaymentAddress interface: attribute regionCode assert_true: The prototype object must have a property "regionCode" expected true got false
-PASS Unscopable handled correctly for regionCode property on PaymentAddress 
-PASS PaymentAddress interface: attribute city 
-PASS Unscopable handled correctly for city property on PaymentAddress 
-PASS PaymentAddress interface: attribute dependentLocality 
-PASS Unscopable handled correctly for dependentLocality property on PaymentAddress 
-PASS PaymentAddress interface: attribute postalCode 
-PASS Unscopable handled correctly for postalCode property on PaymentAddress 
-PASS PaymentAddress interface: attribute sortingCode 
-PASS Unscopable handled correctly for sortingCode property on PaymentAddress 
-PASS PaymentAddress interface: attribute languageCode 
-PASS Unscopable handled correctly for languageCode property on PaymentAddress 
-PASS PaymentAddress interface: attribute organization 
-PASS Unscopable handled correctly for organization property on PaymentAddress 
-PASS PaymentAddress interface: attribute recipient 
-PASS Unscopable handled correctly for recipient property on PaymentAddress 
-PASS PaymentAddress interface: attribute phone 
-PASS Unscopable handled correctly for phone property on PaymentAddress 
-PASS PaymentResponse interface: existence and properties of interface object 
-PASS PaymentResponse interface object length 
-PASS PaymentResponse interface object name 
-PASS PaymentResponse interface: existence and properties of interface prototype object 
-PASS PaymentResponse interface: existence and properties of interface prototype object's "constructor" property 
-PASS PaymentResponse interface: existence and properties of interface prototype object's @@unscopables property 
-PASS PaymentResponse interface: operation toJSON() 
-PASS Unscopable handled correctly for toJSON() on PaymentResponse 
-PASS PaymentResponse interface: attribute requestId 
-PASS Unscopable handled correctly for requestId property on PaymentResponse 
-PASS PaymentResponse interface: attribute methodName 
-PASS Unscopable handled correctly for methodName property on PaymentResponse 
-PASS PaymentResponse interface: attribute details 
-PASS Unscopable handled correctly for details property on PaymentResponse 
-PASS PaymentResponse interface: attribute shippingAddress 
-PASS Unscopable handled correctly for shippingAddress property on PaymentResponse 
-PASS PaymentResponse interface: attribute shippingOption 
-PASS Unscopable handled correctly for shippingOption property on PaymentResponse 
-PASS PaymentResponse interface: attribute payerName 
-PASS Unscopable handled correctly for payerName property on PaymentResponse 
-PASS PaymentResponse interface: attribute payerEmail 
-PASS Unscopable handled correctly for payerEmail property on PaymentResponse 
-PASS PaymentResponse interface: attribute payerPhone 
-PASS Unscopable handled correctly for payerPhone property on PaymentResponse 
-PASS PaymentResponse interface: operation complete(PaymentComplete) 
-PASS Unscopable handled correctly for complete(PaymentComplete) on PaymentResponse 
-PASS PaymentRequestUpdateEvent interface: existence and properties of interface object 
-PASS PaymentRequestUpdateEvent interface object length 
-PASS PaymentRequestUpdateEvent interface object name 
-PASS PaymentRequestUpdateEvent interface: existence and properties of interface prototype object 
-PASS PaymentRequestUpdateEvent interface: existence and properties of interface prototype object's "constructor" property 
-PASS PaymentRequestUpdateEvent interface: existence and properties of interface prototype object's @@unscopables property 
-PASS PaymentRequestUpdateEvent interface: operation updateWith([object Object]) 
-PASS Unscopable handled correctly for updateWith([object Object]) on PaymentRequestUpdateEvent 
-
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/interfaces.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/interfaces.https.html
deleted file mode 100644 (file)
index a7ec323..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<!doctype html>
-<meta charset=utf-8>
-<title>Payment Request interface IDL tests</title>
-<script src=/resources/testharness.js></script>
-<script src=/resources/testharnessreport.js></script>
-<script src=/resources/WebIDLParser.js></script>
-<script src=/resources/idlharness.js></script>
-<script>
-promise_test(async () => {
-  const urls =  ["/interfaces/dom.idl", "/interfaces/payment-request.idl"];
-  const [dom, payment_request] = await Promise.all(
-    urls.map(url => fetch(url).then(r => r.text())));
-  const idlArray = new IdlArray();
-  idlArray.add_untested_idls(dom);
-  idlArray.add_idls(payment_request);
-
-  // typedef EventHandler from HTML
-  // https://html.spec.whatwg.org/#eventhandler
-  idlArray.add_idls(`
-    [TreatNonObjectAsNull]
-    callback EventHandlerNonNull = any (Event event);
-    typedef EventHandlerNonNull? EventHandler;
-  `);
-  const methods = "[{supportedMethods: 'foo'}]";
-  const amount = "{currency: 'USD', value: '0'}";
-  const details = `{total: {label: 'bar', amount: ${amount}} }`;
-  idlArray.add_objects({
-    PaymentRequest: [`new PaymentRequest(${methods}, ${details})`],
-  });
-  idlArray.test();
-}, "Setup for Payment Request API IDL tests.");
-</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/onpaymentmenthodchange-attribute.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/onpaymentmenthodchange-attribute.https-expected.txt
new file mode 100644 (file)
index 0000000..f310050
--- /dev/null
@@ -0,0 +1,6 @@
+
+FAIL Must have a onpaymentmethodchange IDL attribute assert_idl_attribute: property "onpaymentmethodchange" not found in prototype chain
+FAIL onpaymentmethodchange attribute is a generic handler for "paymentmethodchange" assert_true: event did not fire expected true got false
+FAIL onpaymentmethodchange attribute is a handler for PaymentMethodChangeEvent Can't find variable: PaymentMethodChangeEvent
+FAIL onpaymentmethodchange attribute and listeners both work Can't find variable: PaymentMethodChangeEvent
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/onpaymentmenthodchange-attribute.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/onpaymentmenthodchange-attribute.https.html
new file mode 100644 (file)
index 0000000..0484eb8
--- /dev/null
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Test for onpaymentmethodchange attribute</title>
+<link rel="help" href="https://w3c.github.io/browser-payment-api/#onpaymentmethodchange-attribute">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+"use strict";
+const testMethod = Object.freeze({ supportedMethods: "not-a-real-method" });
+const applePay = Object.freeze({ supportedMethods: "https://apple.com/apple-pay" });
+const defaultMethods = Object.freeze([testMethod, applePay]);
+const defaultDetails = Object.freeze({
+  total: {
+    label: "Total",
+    amount: {
+      currency: "USD",
+      value: "1.00",
+    },
+  },
+});
+
+test(() => {
+  const request = new PaymentRequest(defaultMethods, defaultDetails);
+  assert_idl_attribute(request, "onpaymentmethodchange");
+}, "Must have a onpaymentmethodchange IDL attribute");
+
+test(() => {
+  const request = new PaymentRequest(defaultMethods, defaultDetails);
+  const ev = new Event("paymentmethodchange");
+  let didHandle = false;
+  request.onpaymentmethodchange = evt => {
+    assert_equals(ev, evt, "must be same event");
+    didHandle = true;
+  };
+  request.dispatchEvent(ev);
+  assert_true(didHandle, "event did not fire");
+}, `onpaymentmethodchange attribute is a generic handler for "paymentmethodchange"`);
+
+test(() => {
+  const request = new PaymentRequest(defaultMethods, defaultDetails);
+  const ev = new PaymentMethodChangeEvent("paymentmethodchange");
+  let didHandle = false;
+  request.onpaymentmethodchange = evt => {
+    assert_equals(ev, evt, "must be same event");
+    didHandle = true;
+  };
+  request.dispatchEvent(ev);
+  assert_true(didHandle, "event did not fire");
+}, `onpaymentmethodchange attribute is a handler for PaymentMethodChangeEvent`);
+
+test(() => {
+  const request = new PaymentRequest(defaultMethods, defaultDetails);
+  const ev = new PaymentMethodChangeEvent("paymentmethodchange", {
+    methodName: "test"
+  });
+  let didHandle = false;
+  let didListen = false;
+  request.onpaymentmethodchange = evt => {
+    assert_equals(ev, evt, "must be same event");
+    didHandle = true;
+  };
+  request.addEventListener("paymentmethodchange", evt => {
+    assert_equals(ev, evt, "must be same event");
+    didListen = true;
+  });
+  request.dispatchEvent(ev);
+  assert_true(didHandle, "onpaymentmethodchange did not receive the event");
+  assert_true(didListen, "addEventListener did not receive the event");
+}, `onpaymentmethodchange attribute and listeners both work`);
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method-manual.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method-manual.https-expected.txt
deleted file mode 100644 (file)
index b0f6b29..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-Test for PaymentRequest.abort() method
-
-Click on each button in sequence from top to bottom without refreshing the page. No payment sheet will be shown, but the tests will run in the background.
-
-Calling abort must not change the [[state]] until after "interactive".
-Calling .abort() causes acceptPromise to reject and closes the request.
-If you find a buggy test, please file a bug and tag one of the owners.
-
-Harness Error (TIMEOUT), message = null
-
-PASS Throws if the promise [[state]] is not "interactive" 
-
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https-expected.txt
new file mode 100644 (file)
index 0000000..3a5f0f9
--- /dev/null
@@ -0,0 +1,9 @@
+CONSOLE MESSAGE: Unhandled Promise Rejection: InvalidStateError: The object is in an invalid state.
+CONSOLE MESSAGE: Unhandled Promise Rejection: InvalidStateError: The object is in an invalid state.
+CONSOLE MESSAGE: Unhandled Promise Rejection: InvalidStateError: The object is in an invalid state.
+
+PASS Throws if the promise [[state]] is not "interactive" 
+FAIL Test for PaymentRequest.abort() method promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: test_driver"
+FAIL Test for PaymentRequest.abort() method 1 promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: test_driver"
+PASS Calling abort() multiple times is always a new object. 
+
@@ -4,17 +4,21 @@
 <link rel="help" href="https://w3c.github.io/browser-payment-api/#abort-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>
 "use strict";
 setup({
   // Ignore unhandled rejections resulting from .show()'s acceptPromise
   // not being explicitly handled.
   allow_uncaught_exception: true,
-  explicit_done: true,
   explicit_timeout: true,
 });
 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",
@@ -31,9 +35,23 @@ promise_test(async t => {
   await promise_rejects(t, "InvalidStateError", request.abort());
 }, `Throws if the promise [[state]] is not "interactive"`);
 
-function manualTest1(elem){
-  elem.disabled = true;
-  promise_test(async t => {
+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());
+  });
+});
+
+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());
@@ -51,45 +69,13 @@ function manualTest1(elem){
     // The request is now "closed", so...
     await promise_rejects(t, "InvalidStateError", request.abort());
     await promise_rejects(t, "AbortError", acceptPromise);
-  }, elem.textContent.trim());
-}
+  });
+});
 
-function manualTest2(elem){
-  elem.disabled = true;
-  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());
-  }, elem.textContent.trim());
-  done();
-}
+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>
 
-<h2>Test for PaymentRequest.abort() method</h2>
-<p>
-  Click on each button in sequence from top to bottom without refreshing the page.
-  No payment sheet will be shown, but the tests will run in the background.
-</p>
-<ol>
-  <li>
-    <button onclick="manualTest1(this)">
-      Calling abort must not change the [[state]] until after "interactive".
-    </button>
-  </li>
-  <li>
-    <button onclick="manualTest2(this)">
-      Calling .abort() causes acceptPromise to reject and closes the request.
-    </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>
@@ -1,15 +1,10 @@
-Tests for PaymentRequest.canMakePayment() method
-
-Click on each button in sequence from top to bottom without refreshing the page. No payment sheet will be shown, but the tests will run in the background.
-
-If request.[[state]] is "interactive", then return a promise rejected with an "InvalidStateError" DOMException.
-If request.[[state]] is "closed", then return a promise rejected with an "InvalidStateError" DOMException.
-If you find a buggy test, please file a bug and tag one of the owners.
-
-Harness Error (TIMEOUT), message = null
+If you find a buggy test, please file a bug and tag one of the suggested reviewers.
 
 FAIL If request.[[state]] is "created", then return a promise that resolves to true for known method. assert_equals: if it throws, then it must be a NotAllowedError. expected "NotAllowedError" but got "Error"
 FAIL If payment method identifier and serialized parts are supported, resolve promise with true. assert_true: basic-card should be supported expected true got false
 PASS If payment method identifier is unknown, resolve promise with false. 
 PASS Optionally, at the user agent's discretion, return a promise rejected with a "NotAllowedError" DOMException. 
+FAIL If request.[[state]] is "interactive", then return a promise rejected with an "InvalidStateError" DOMException. Can't find variable: test_driver
+FAIL If request.[[state]] is "closed", then return a promise rejected with an "InvalidStateError" DOMException. Can't find variable: test_driver
+PASS Calling canMakePayment() multiple times is always a new object. 
 
@@ -4,12 +4,9 @@
 <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>
-setup({
-  explicit_done: true,
-  explicit_timeout: true,
-});
-
 const basicCard = Object.freeze({ supportedMethods: "basic-card" });
 const defaultMethods = Object.freeze([basicCard]);
 const defaultDetails = Object.freeze({
@@ -124,9 +121,8 @@ promise_test(async t => {
   }
 }, `Optionally, at the user agent's discretion, return a promise rejected with a "NotAllowedError" DOMException.`);
 
-function manualTest1(elem){
-  elem.disabled = true;
-  promise_test(async t => {
+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();
@@ -144,12 +140,11 @@ function manualTest1(elem){
     }
     // The state should be "closed"
     await promise_rejects(t, "InvalidStateError", request.canMakePayment());
-  }, elem.textContent.trim());
-}
+  });
+}, 'If request.[[state]] is "interactive", then return a promise rejected with an "InvalidStateError" DOMException.');
 
-function manualTest2(elem){
- elem.disabled = true;
-  promise_test(async t => {
+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.
@@ -168,29 +163,24 @@ function manualTest2(elem){
         "must be an InvalidStateError."
       );
     }
-  }, elem.textContent.trim());
-  done();
-}
+  });
+}, 'If request.[[state]] is "closed", then return a promise rejected with an "InvalidStateError" DOMException.');
+
+test(() => {
+  const request = new PaymentRequest(
+    [{ supportedMethods: "basic-card" }],
+    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.");
 </script>
 
-<h2>Tests for PaymentRequest.canMakePayment() method</h2>
-<p>
-  Click on each button in sequence from top to bottom without refreshing the page.
-  No payment sheet will be shown, but the tests will run in the background.
-</p>
-<ol>
-  <li>
-    <button onclick="manualTest1(this)">
-      If request.[[state]] is "interactive", then return a promise rejected with an "InvalidStateError" DOMException.
-    </button>
-  </li>
-  <li>
-    <button onclick="manualTest2(this)">
-      If request.[[state]] is "closed", then return a promise rejected with an "InvalidStateError" 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>.
+  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>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http-expected.txt
new file mode 100644 (file)
index 0000000..9c35c87
--- /dev/null
@@ -0,0 +1,3 @@
+
+FAIL PaymentRequest constructor must not be exposed in insecure context assert_false: expected false got true
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http.html
new file mode 100644 (file)
index 0000000..0212220
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<!-- 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 Constructor (insecure)</title>
+<link rel="help" href="https://w3c.github.io/payment-request/#paymentrequest-interface">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(() => {
+  assert_false(isSecureContext);
+  assert_false("PaymentRequest" in window);
+}, "PaymentRequest constructor must not be exposed in insecure context");
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker-expected.txt
new file mode 100644 (file)
index 0000000..ef2fdc3
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS PaymentRequest constructor must not be exposed in worker global scope 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.html
new file mode 100644 (file)
index 0000000..2382913
--- /dev/null
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.js b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.js
new file mode 100644 (file)
index 0000000..e5576e6
--- /dev/null
@@ -0,0 +1,7 @@
+importScripts("/resources/testharness.js");
+
+test(() => {
+  assert_true(isSecureContext);
+  assert_false('PaymentRequest' in self);
+}, "PaymentRequest constructor must not be exposed in worker global scope");
+done();
index 32b5668..c6e69d4 100644 (file)
@@ -1,15 +1,16 @@
 <!DOCTYPE html>
-<!-- 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 src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
 <script>
-'use strict';
+"use strict";
 const defaultMethods = Object.freeze([
   { supportedMethods: "basic-card" },
-  { supportedMethods: "https://apple.com/pay" }
+  { supportedMethods: "https://apple.com/apple-pay" },
 ]);
 
 const defaultDetails = Object.freeze({
@@ -27,4 +28,53 @@ promise_test(async t => {
   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>
index 509fa4d..a9da9ee 100644 (file)
 async function runManualTest({ completeWith: result }, button) {
   button.disabled = true;
   const { response, request } = await getPaymentRequestResponse();
-  promise_test(async () => {
+  promise_test(async t => {
     try {
       // We .complete() as normal, using the passed test value
-      const promise = response.complete(result);
-      assert_true(promise instanceof Promise, "returns a promise");
-      const returnedValue = await promise;
+      const completePromise = response.complete(result);
+      assert_true(completePromise instanceof Promise, "returns a promise");
+      // Immediately calling complete() again yields a rejected promise.
+      const invalidComplete = response.complete(result);
+      await promise_rejects(t, "InvalidStateError", invalidComplete);
+      // but the original promise is unaffected
+      const returnedValue = await completePromise;
       assert_equals(
         returnedValue,
         undefined,
         "Returned value must always be undefined"
       );
       // We now call .complete() again, to force an exception
-      // because [[completeCalled]] is true.
-      try {
-        await response.complete(result);
-        assert_unreached("Expected InvalidStateError to be thrown");
-      } catch (err) {
-        assert_equals(
-          err.code,
-          DOMException.INVALID_STATE_ERR,
-          "Must throw an InvalidStateError"
-        );
-      }
+      // because [[complete]] is true.
+      const afterComplete = response.complete(result);
+      await promise_rejects(t, "InvalidStateError", afterComplete);
       button.innerHTML = `✅  ${button.textContent}`;
     } catch (err) {
       button.innerHTML = `❌  ${button.textContent}`;
       assert_unreached("Unexpected exception: " + err.message);
     }
+    const allPromises = new Set([
+      completePromise,
+      invalidComplete,
+      afterComplete,
+    ]);
+    assert_equals(
+      allPromises.length,
+      3,
+      "Calling complete() multiple times is always a new object."
+    );
   }, button.textContent.trim());
 }
 </script>
@@ -79,6 +85,6 @@ async function runManualTest({ completeWith: result }, 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>.
+  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 bf938c5..807f794 100644 (file)
@@ -35,7 +35,7 @@ test(() => {
  * @param PaymentOptions options
  */
 async function getPaymentResponse(options, id) {
-  const { response } = getPaymentRequestResponse(options, id);
+  const { response } = await getPaymentRequestResponse(options, id);
   return response;
 }
 
index cd25e94..0a8ef6c 100644 (file)
@@ -23,6 +23,6 @@
   </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>.
+  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>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https-expected.txt
new file mode 100644 (file)
index 0000000..aa66532
--- /dev/null
@@ -0,0 +1,8 @@
+
+FAIL PaymentResponse inherits from EventTarget assert_equals: expected function "function EventTarget() {
+    [native code]
+}" but got function "function () {
+    [native code]
+}"
+FAIL PaymentResponse has an onpayerdetailchange in the prototype chain assert_true: expected true got false
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https.html
new file mode 100644 (file)
index 0000000..ed9e6e8
--- /dev/null
@@ -0,0 +1,14 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>PaymentResponse.prototype.onpayerdetailschange attribute</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script>
+test(() => {
+  assert_equals(Object.getPrototypeOf(PaymentResponse), window.EventTarget);
+}, "PaymentResponse inherits from EventTarget");
+
+test(() => {
+  assert_true("onpayerdetailchange" in PaymentResponse.prototype);
+}, "PaymentResponse has an onpayerdetailchange in the prototype chain");
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html
new file mode 100644 (file)
index 0000000..9f92d28
--- /dev/null
@@ -0,0 +1,66 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>PaymentResponse.prototype.onpayerdetailchange attribute</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="helpers.js"></script>
+<script>
+function runTest(button, options, expected){
+  button.disabled = true;
+  promise_test(async () => {
+    const response = await getPaymentResponse(options);
+    const eventPromise = new Promise(resolve => {
+      response.addEventListener("payerdetailchange", resolve);
+    });
+    const error = button.previousElementSibling.textContent.trim();
+    const retryPromise = response.retry({ error });
+    const event = await eventPromise;
+    assert_true(event instanceof PaymentRequestUpdateEvent);
+    for(const [prop, value] of Object.entries(expected)){
+      assert_equals(response[prop], value);
+    }
+    await response.complete("success");
+  }, button.textContent.trim());
+}
+</script>
+<h2>Handling PaymentResponse.prototype.onpayerdetailchange events</h2>
+<p>
+  Each button will bring up the Payment Request UI window.
+  When shown the payment sheet, use any details and hit pay.
+</p>
+<p>
+  When asked to retry the payment:
+</p>
+<ol>
+  <li>
+    <p>
+      Change payer's name to "pass".
+    </p>
+    <button onclick="runTest(this, { requestPayerName: true }, { payerName: 'pass' });">
+      PaymentRequestUpdateEvent is dispatched when payer name changes.
+    </button>
+  </li>
+  <li>
+    <p>
+      Change payer's email to "pass@pass.pass".
+    </p>
+    <button onclick="runTest(this, {requestPayerEmail: true}, { payerEmail: 'pass@pass.pass' });">
+      PaymentRequestUpdateEvent is dispatched when payer email changes.
+    </button>
+  </li>
+  <li>
+    <p>
+      Change payer's phone to "+1-800-000-0000".
+    </p>
+    <button onclick="runTest(this, {requestPayerPhone: true}, { payerPhone: '+1-800-000-0000' })">
+      PaymentRequestUpdateEvent is dispatched when payer phone changes.
+    </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/OWNERS">owners</a>.
+</small>
index c7eaf65..28ce4c2 100644 (file)
@@ -43,6 +43,6 @@
   </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>.
+  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 b2636e3..44d741a 100644 (file)
@@ -43,6 +43,6 @@
   </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>.
+  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 c74f45e..85a44a8 100644 (file)
@@ -43,6 +43,6 @@
   </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>.
+  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>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/rejects_if_not_active-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/rejects_if_not_active-manual.https.html
new file mode 100644 (file)
index 0000000..60dd965
--- /dev/null
@@ -0,0 +1,150 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<link rel="help" href="https://w3c.github.io/payment-request/#retry-method">
+<title>PaymentResponse retry() rejects if doc is not fully active</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentresponse-retry">
+<body>
+<script>
+setup({ explicit_done: true, explicit_timeout: true });
+const validMethod = Object.freeze({
+  supportedMethods: "basic-card",
+});
+const validMethods = Object.freeze([validMethod]);
+const validAmount = Object.freeze({
+  currency: "USD",
+  value: "5.00",
+});
+const validTotal = Object.freeze({
+  label: "Total due",
+  amount: validAmount,
+});
+const validDetails = Object.freeze({
+  total: validTotal,
+});
+
+function getLoadedPaymentResponse(iframe, url) {
+  return new Promise(resolve => {
+    iframe.addEventListener(
+      "load",
+      async () => {
+        const { PaymentRequest } = iframe.contentWindow;
+        const response = await new PaymentRequest(
+          validMethods,
+          validDetails
+        ).show();
+        resolve(response);
+      },
+      { once: true }
+    );
+    iframe.src = url;
+  });
+}
+
+function methodNotFullyActive(button, method, ...args) {
+  const text = button.textContent.trim();
+  promise_test(async t => {
+    const iframe = document.createElement("iframe");
+    iframe.allowPaymentRequest = true;
+    document.body.appendChild(iframe);
+
+    // We first got to page1.html, grab a PaymentResponse instance.
+    const response = await getLoadedPaymentResponse(
+      iframe,
+      "/payment-request/resources/page1.html"
+    );
+    // We navigate the iframe again, putting response's document into an inactive state.
+    await new Promise(resolve => {
+      iframe.addEventListener("load", resolve);
+      iframe.src = "/payment-request/resources/page2.html";
+    });
+    // Now, response's relevant global object's document is no longer active.
+    // So, promise needs to reject appropriately.
+    const promise = response[methodName](...args);
+    await promise_rejects(
+      t,
+      "AbortError",
+      promise,
+      "Inactive document, so must throw AbortError"
+    );
+    // We are done, so clean up.
+    iframe.remove();
+  }, text);
+}
+
+function methodBecomesNotFullyActive(button, methodName, ...args) {
+  const text = button.textContent.trim();
+  promise_test(async t => {
+    const iframe = document.createElement("iframe");
+    iframe.allowPaymentRequest = true;
+    document.body.appendChild(iframe);
+
+    // We first got to page1.html, grab a PaymentResponse instance.
+    const response = await getLoadedPaymentResponse(
+      iframe,
+      "/payment-request/resources/page1.html"
+    );
+
+    // we get the promise from page1.html, while it's active!
+    const promise = response[methodName](...args);
+
+    // We navigate the iframe again, putting response's document into an inactive state.
+    await new Promise(resolve => {
+      iframe.addEventListener("load", resolve);
+      iframe.src = "/payment-request/resources/page2.html";
+    });
+
+    // Now, response's relevant global object's document is no longer active.
+    // So, promise needs to reject appropriately.
+    await promise_rejects(
+      t,
+      "AbortError",
+      promise,
+      "Inactive document, so must throw AbortError"
+    );
+    // We are done, so clean up.
+    iframe.remove();
+  }, text);
+}
+</script>
+<section>
+  <p>
+    For each test, when the payment sheet is shown, select a payment method and hit "Pay".
+  </p>
+  <h2>retry() and document active state</h2>
+  <p>Manual Tests for PaymentResponse.retry() - Please run in order!</p>
+  <ol>
+    <li>
+      <button onclick="methodNotFullyActive(this, 'retry', {});">
+        retry()'s retryPromise rejects if document is not fully active.
+      </button>
+    </li>
+    <li>
+      <button onclick="methodBecomesNotFullyActive(this, 'retry', {});">
+        retry()'s retryPromise rejects if the document becomes not fully active.
+      </button>
+    </li>
+  </ol>
+  <h2>complete() and document active state</h2>
+  <p>Manual Tests for PaymentResponse.complete() - Please run in order!</p>
+  <ol>
+    <li>
+      <button onclick="methodNotFullyActive(this, 'complete', 'success');">
+        complete()'s completePromise rejects if document is not fully active.
+      </button>
+    </li>
+    <li>
+      <button onclick="methodBecomesNotFullyActive(this, 'complete', 'success');">
+        complete()'s completePromise rejects if the document becomes not fully active.
+      </button>
+    </li>
+    <li>
+      <button onclick="done();">Done</button>
+    </li>
+  </ol>
+</section>
+<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 653ed55..ddb1e0d 100644 (file)
@@ -29,6 +29,6 @@
   </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>.
+  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>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/retry-method-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/retry-method-manual.https.html
new file mode 100644 (file)
index 0000000..82821a9
--- /dev/null
@@ -0,0 +1,274 @@
+<!doctype html>
+<meta charset="utf8">
+<link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentresponse-retry">
+<title>
+  PaymentResponse.prototype.retry() method
+</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="helpers.js"></script>
+<script>
+test(() => {
+  assert_true(
+    "retry" in PaymentResponse.prototype,
+    "retry must be in prototype"
+  );
+  assert_true(
+    PaymentResponse.prototype.retry instanceof Function,
+    "retry must be a function"
+  );
+}, "PaymentResponse.prototype must have a retry() function (smoke test).");
+
+function checkCompletedCantRetry(button) {
+  button.disabled = true;
+  promise_test(async t => {
+    const { response } = await getPaymentRequestResponse();
+    // sets response.[[complete]] to true.
+    await response.complete("success");
+    return promise_rejects(
+      t,
+      "InvalidStateError",
+      response.retry({}),
+      "response.[[complete]] is true, so rejects with InvalidStateError."
+    );
+  }, button.textContent.trim());
+}
+
+function repeatedCallsToRetry(button) {
+  button.disabled = true;
+  promise_test(async t => {
+    const { response } = await getPaymentRequestResponse();
+    const retryPromise = response.retry({});
+    await promise_rejects(
+      t,
+      "InvalidStateError",
+      response.retry({}),
+      "Calling retry() again rejects with an InvalidStateError"
+    );
+    await retryPromise;
+    await response.complete("success");
+  }, button.textContent.trim());
+}
+
+function callCompleteWhileRetrying(button) {
+  button.disabled = true;
+  promise_test(async t => {
+    const { response } = await getPaymentRequestResponse();
+    const retryPromise = response.retry({});
+    await promise_rejects(
+      t,
+      "InvalidStateError",
+      response.complete("success"),
+      "Calling complete() while retrying rejects with an InvalidStateError"
+    );
+    await retryPromise;
+    await response.complete("success");
+  }, button.textContent.trim());
+}
+
+function callingRequestAbortMustNotAbort(button) {
+  button.disabled = true;
+  promise_test(async t => {
+    const { response, request } = await getPaymentRequestResponse();
+    const retryPromise = response.retry({});
+    await promise_rejects(
+      t,
+      "InvalidStateError",
+      request.abort(),
+      "Calling request.abort() while retrying rejects with an InvalidStateError"
+    );
+    await retryPromise;
+    await response.complete("success");
+  }, button.textContent.trim());
+}
+
+function canRetryMultipleTimes(button) {
+  button.disabled = true;
+  promise_test(async t => {
+    const { response } = await getPaymentRequestResponse();
+    assert_equals(
+      await response.retry({}),
+      undefined,
+      "Expected undefined as the resolve value"
+    );
+    assert_equals(
+      await response.retry({}),
+      undefined,
+      "Expected undefined as the resolve value"
+    );
+    await response.complete("success");
+    await promise_rejects(
+      t,
+      "InvalidStateError",
+      response.retry({}),
+      "Calling retry() after complete() rejects with a InvalidStateError"
+    );
+  }, button.textContent.trim());
+}
+
+function userCanAbortARetry(button) {
+  button.disabled = true;
+  promise_test(async t => {
+    const { response } = await getPaymentRequestResponse();
+    await promise_rejects(
+      t,
+      "AbortError",
+      response.retry({}),
+      "The user aborting a retry rejects with a AbortError"
+    );
+    await promise_rejects(
+      t,
+      "InvalidStateError",
+      response.retry({}),
+      "After the user aborts, response [[complete]] is true so retry() must reject with InvalidStateError"
+    );
+    await promise_rejects(
+      t,
+      "InvalidStateError",
+      response.complete("success"),
+      "After the user aborts, response [[complete]] is true, so complete() rejects with a InvalidStateError"
+    );
+  }, button.textContent.trim());
+}
+
+function userIsShownErrorsFields(button) {
+  button.disabled = true;
+  promise_test(async t => {
+    const { response, request } = await getPaymentRequestResponse({ requestShipping: true });
+    const retryPromise = response.retry({
+      shippingAddress: { city: "Invalid city", addressLine: "Invalid address line" },
+    });
+    await retryPromise;
+    await response.complete("success");
+  }, button.textContent.trim());
+}
+
+function abortTheUpdate(button) {
+  button.disabled = true;
+  promise_test(async t => {
+    const { response, request } = await getPaymentRequestResponse({ requestShipping: true });
+    // causes "abort the update" to run
+    const shippingChangedPromise = new Promise(resolve => {
+      request.onshippingoptionchange = () => {
+        event.updateWith({ total: { amount: { currency: "USD", value: "INVALID" } }});
+        resolve();
+      };
+    });
+    const retryPromise = response.retry({});
+    await shippingChangedPromise;
+    await promise_rejects(
+      t,
+      new TypeError(),
+      retryPromise,
+      "retry() aborts with a TypeError, because totals' value is invalid"
+    );
+    await promise_rejects(
+      t,
+      "InvalidStateError",
+      response.complete("success"),
+      "After the user aborts, response [[complete]] is true, so complete() rejects with a InvalidStateError"
+    );
+  }, button.textContent.trim());
+}
+
+function callingRetryReturnsUniquePromise(button){
+  button.disabled = true;
+  promise_test(async t => {
+    const { response } = await getPaymentRequestResponse();
+    const retryPromise = response.retry({});
+    const promises = new Set([
+      retryPromise,
+      response.retry({}),
+      response.retry({}),
+    ]);
+    assert_equals(promises.size, 3, "Must have three unique objects");
+    await retryPromise;
+    await response.complete();
+  }, button.textContent.trim());
+};
+
+
+</script>
+<h2>
+    Manual Tests for PaymentResponse.retry() - Please run in order!
+</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 presented with the payment sheet, use any credit card select to "Pay" multiple times.
+</p>
+<ol>
+  <li>
+    <button onclick="checkCompletedCantRetry(this);">
+      A completed payment request cannot be retried.
+    </button>
+  </li>
+  <li>
+    <button onclick="repeatedCallsToRetry(this);">
+      Calling retry() more than once yield a rejected promise, but the
+      retryPromise resolves independently.
+    </button>
+  </li>
+  <li>
+    <button onclick="callCompleteWhileRetrying(this);">
+      Calling complete() while a retry() is in progress results in an InvalidStateError.
+    </button>
+  </li>
+  <li>
+    <button onclick="callingRequestAbortMustNotAbort(this);">
+      Trying to abort() via PaymentRequest is not possible.
+    </button>
+  </li>
+  <li>
+    <button onclick="canRetryMultipleTimes(this);">
+      It's possible to retry() multiple times and eventually complete().
+      After complete(), however, retry() rejects with an InvalidStateError.
+    </button>
+  </li>
+  <li>
+    <p>
+      When shown the payment sheet, hit pay once, then abort retrying the payment.
+    </p>
+    <button onclick="userCanAbortARetry(this);">
+      The user aborting retrying a payment causes the retryPromise to reject with AbortError.
+      Aborting a payment is causes it complete.
+    </button>
+  </li>
+  <li>
+    <p>
+      When shown the payment sheet, hit pay once. Check payment sheet for error fields.
+      Then hit escape or otherwise abort the payment.
+    </p>
+    <button onclick="userIsShownErrorsFields(this);">
+      When retrying, the user is shown error fields to fix.
+    </button>
+  </li>
+  <li>
+    <p>
+      When shown the payment sheet, hit pay once. Then retry once.
+    </p>
+    <button onclick="abortTheUpdate(this);">
+      When "abort the update" occurs because of an update error,
+      the `retryPromise` is rejected and response.[[complete]] becomes true.
+    </button>
+  </li>
+  <li>
+    <p>
+      When shown the payment sheet, hit pay once. Then retry once.
+    </p>
+    <button onclick="callingRetryReturnsUniquePromise(this);">
+      Calling retry() multiple times is always a new object.
+    </button>
+  </li>
+  <li>
+    <button onclick="done();">
+      Done!
+    </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>
index b5a4082..92bac2b 100644 (file)
@@ -96,6 +96,6 @@ async function runManualTest(button, options = {}, expected = {}, id) {
   </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>.
+  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 eec7a4d..687d3a5 100644 (file)
@@ -38,6 +38,6 @@
   </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>.
+  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 5125feb..eb55e28 100644 (file)
@@ -1,7 +1,7 @@
 The tests in this directory were imported from the W3C repository.
 Do NOT modify these tests directly in WebKit.
 Instead, create a pull request on the WPT github:
-       https://github.com/w3c/web-platform-tests
+       https://github.com/web-platform-tests/wpt
 
 Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
 
@@ -17,9 +17,13 @@ List of files:
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/complete-method-manual.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/helpers.js
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/methodName-attribute-manual.https.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/payerEmail-attribute-manual.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/payerName-attribute-manual.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/payerPhone-attribute-manual.https.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/rejects_if_not_active-manual.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/requestId-attribute-manual.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/payment-response/shippingAddress-attribute-manual.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/shippingOption-attribute-manual.https.html
index 3d11dd1..149fb58 100644 (file)
@@ -1,7 +1,7 @@
 The tests in this directory were imported from the W3C repository.
 Do NOT modify these tests directly in WebKit.
 Instead, create a pull request on the WPT github:
-       https://github.com/w3c/web-platform-tests
+       https://github.com/web-platform-tests/wpt
 
 Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
 
index 1ce6e52..07b5306 100644 (file)
@@ -80,6 +80,6 @@ function testShippingAddressChange() {
   </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>.
+  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>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html
new file mode 100644 (file)
index 0000000..5c1028e
--- /dev/null
@@ -0,0 +1,281 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Test for PaymentRequest.show(optional detailsPromise) 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>
+  // See function testBadUpdate() for test details!
+  setup({
+    allow_uncaught_exception: true,
+    explicit_done: true,
+    explicit_timeout: true,
+  });
+
+  // == TEST DATA ===
+  // PaymentMethod
+  const validMethod = Object.freeze({
+    supportedMethods: "valid-but-wont-ever-match",
+  });
+
+  const validMethodBasicCard = Object.freeze({
+    supportedMethods: "basic-card",
+  });
+
+  const validMethodApplePay = Object.freeze({
+    supportedMethods: "https://apple.com/apple-pay",
+  });
+
+  // Methods
+  const validMethods = Object.freeze([
+    validMethodBasicCard,
+    validMethod,
+    validMethodApplePay,
+  ]);
+
+  // Amounts
+  const validAmount = Object.freeze({
+    currency: "USD",
+    value: "1.00",
+  });
+
+  const invalidAmount = Object.freeze({
+    currency: "¡INVALID!",
+    value: "A1.0",
+  });
+
+  const negativeAmount = Object.freeze({
+    currency: "USD",
+    value: "-1.00",
+  });
+
+  // Totals
+  const validTotal = Object.freeze({
+    label: "Valid Total",
+    amount: validAmount,
+  });
+
+  const invalidTotal = Object.freeze({
+    label: "Invalid Total",
+    amount: invalidAmount,
+  });
+
+  const invalidNegativeTotal = Object.freeze({
+    label: "Invalid negative total",
+    amount: negativeAmount,
+  });
+
+  // PaymentDetailsInit
+  const validDetails = Object.freeze({
+    total: validTotal,
+  });
+
+  const invalidDetailsNegativeTotal = Object.freeze({
+    total: invalidNegativeTotal,
+  });
+
+  // PaymentOptions
+  const validOptions = Object.freeze({
+    requestShipping: true,
+  });
+
+  // PaymentItem
+  const validPaymentItem = Object.freeze({
+    amount: validAmount,
+    label: "Valid payment item",
+  });
+
+  const invalidPaymentItem = Object.freeze({
+    amount: invalidAmount,
+    label: "Invalid payment item",
+  });
+
+  // PaymentItem
+  const validPaymentItems = Object.freeze([validPaymentItem]);
+  const invalidPaymentItems = Object.freeze([invalidPaymentItem]);
+
+  // PaymentShippingOption
+  const invalidShippingOption = Object.freeze({
+    id: "abc",
+    label: "Invalid shipping option",
+    amount: invalidAmount,
+    selected: true,
+  });
+
+  // PaymentShippingOptions
+  const validShippingOption = Object.freeze({
+    id: "abc",
+    label: "valid shipping option",
+    amount: validAmount,
+  });
+
+  const validShippingOptions = Object.freeze([validShippingOption]);
+  const invalidShippingOptions = Object.freeze([invalidShippingOption]);
+
+  // PaymentDetailsModifier
+  const validModifier = Object.freeze({
+    additionalDisplayItems: validPaymentItems,
+    supportedMethods: "valid-but-wont-ever-match",
+    total: validTotal,
+  });
+
+  const modifierWithInvalidDisplayItems = Object.freeze({
+    additionalDisplayItems: invalidPaymentItems,
+    supportedMethods: "basic-card",
+    total: validTotal,
+  });
+
+  const modifierWithValidDisplayItems = Object.freeze({
+    additionalDisplayItems: validPaymentItems,
+    supportedMethods: "basic-card",
+    total: validTotal,
+  });
+
+  const modifierWithInvalidTotal = Object.freeze({
+    additionalDisplayItems: validPaymentItems,
+    supportedMethods: "basic-card",
+    total: invalidTotal,
+  });
+
+  const recursiveData = {};
+  recursiveData.foo = recursiveData;
+  Object.freeze(recursiveData);
+
+  const modifierWithRecursiveData = Object.freeze({
+    supportedMethods: validMethodBasicCard,
+    total: validTotal,
+    data: recursiveData,
+  });
+  // == END OF TEST DATA ===
+  /*
+    These test work by creating a "valid" payment request and then
+    performing a bad update via `show(detailsPromise)`.
+    The `badDetails` cause detailsPromise to reject with `expectedError`.
+    */
+  function testBadUpdate(testAssertion, badDetails, expectedError) {
+    promise_test(async t => {
+      const request = new PaymentRequest(
+        validMethods,
+        validDetails,
+        validOptions
+      );
+      const detailsPromise = Promise.resolve(badDetails);
+      const acceptPromise = request.show(detailsPromise);
+      await promise_rejects(
+        t,
+        expectedError,
+        acceptPromise,
+        "badDetails must cause acceptPromise to reject with expectedError"
+      );
+    }, testAssertion);
+  }
+</script>
+<h2>
+  PaymentRequest <code>.show(optional detailsPromise)</code> tests
+</h2>
+<h3>
+  Bad details - causes `detailsPromise` to reject.
+</h3>
+<p>
+  Click on each button in sequence from top to bottom without refreshing the page.
+  No payment sheet should be shown, as all provided values cause an error.
+</p>
+<p>
+  <strong>
+    If you see a payment sheet, it means the test has failed.
+  </strong>
+</p>
+<ol>
+  <li><button onclick="
+    const rejectedPromise = Promise.reject(new SyntaxError('test'))
+      .catch(err => err);
+    testBadUpdate(this.textContent, rejectedPromise, 'AbortError');
+  ">
+  Rejection of detailsPromise must abort the update with an 'AbortError' DOMException.
+  </button></li>
+
+  <li><button onclick="
+    const invalidDetails = { total: `this will cause a TypeError!` };
+    testBadUpdate(this.textContent, invalidDetails, new TypeError());
+  ">
+  Total in the update is a string, so converting to IDL must abort the update with a TypeError.
+  </button></li>
+
+  <li><button onclick="
+    const invalidDetails = { total: recursiveData };
+    testBadUpdate(this.textContent, invalidDetails, new TypeError());
+  ">
+  Total is recursive, so converting to IDL must abort the update with a TypeError.
+  </button></li>
+
+  <li><button onclick="
+    testBadUpdate(this.textContent, invalidDetailsNegativeTotal, new TypeError());
+  ">
+  Updating with a negative total results in a TypeError.
+  </button></li>
+
+  <li><button onclick="
+    const badDetails = Object.assign({}, validDetails, {
+      displayItems: invalidPaymentItems
+    });
+    testBadUpdate(this.textContent, badDetails, new RangeError());
+  ">
+  Updating with a displayItem with an invalid currency results in RangeError.
+  </button></li>
+
+  <li><button onclick="
+    const duplicateShippingOptions = [validShippingOption, validShippingOption];
+    const badDetails = Object.assign({}, validDetails, {
+      shippingOptions: duplicateShippingOptions,
+    });
+    testBadUpdate(this.textContent, badDetails, new TypeError());
+  ">
+  Updating with duplicate shippingOptions (same IDs) results in a TypeError.
+  </button></li>
+  <li><button onclick="
+    const badDetails = Object.assign({}, validDetails, {
+      shippingOptions: invalidShippingOptions,
+    });
+    testBadUpdate(this.textContent, badDetails, new RangeError());
+  ">
+  Updating with a shippingOption with an invalid currency value results in a RangError.
+  </button></li>
+
+  <li><button onclick="
+    // validModifier is there as to avoid false positives
+    const badModifiers = { modifiers: [modifierWithInvalidTotal, validModifier] };
+    const badDetails = Object.assign({}, validDetails, badModifiers);
+    testBadUpdate(this.textContent, badDetails, new RangeError());
+  ">
+  Must throw a RangeError when a modifier's total item has an invalid currency.
+  </button></li>
+
+  <li><button onclick="
+    // validModifier is there as to avoid false positives
+    const badModifiers = {
+      modifiers: [modifierWithInvalidDisplayItems, validModifier],
+    };
+    const badDetails = Object.assign({}, validDetails, badModifiers);
+    testBadUpdate(this.textContent, badDetails, new RangeError());
+  ">
+  Must throw a RangeError when a modifier display item has an invalid currency.
+  </button></li>
+
+  <li><button onclick="
+    // validModifier is there as to avoid false positives
+    const badModifiers = {
+      modifiers: [modifierWithRecursiveData, validModifier],
+    };
+    const badDetails = Object.assign({}, validDetails, badModifiers);
+    testBadUpdate(this.textContent, badDetails, new TypeError());
+  ">
+  Must throw as Modifier has a recursive dictionary.
+  </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>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html
new file mode 100644 (file)
index 0000000..70c97fa
--- /dev/null
@@ -0,0 +1,319 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Test for PaymentRequest.show(optional promise) 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({
+  allow_uncaught_exception: true,
+  explicit_done: true,
+  explicit_timeout: true,
+});
+
+// DATA USED BY TESTS
+// PaymentMethods
+const validMethods = Object.freeze([
+  {
+    supportedMethods: "valid-but-wont-ever-match",
+  },
+  {
+    supportedMethods: "basic-card",
+  },
+  {
+    supportedMethods: "https://apple.com/apple-pay",
+  },
+]);
+
+// Amounts
+const failAmount = Object.freeze({
+  currency: "USD",
+  value: "1.00",
+});
+const passAmount = Object.freeze({
+  currency: "CAD",
+  value: "50.00",
+});
+const neutralAmount = Object.freeze({
+  currency: "AUD",
+  value: "0.00",
+});
+
+// Labels
+const failLabel = "💥 TEST HAS FAILED 💥";
+const passLabel = "✅ TEST HAS PASSED ✅";
+const neutralLabel = "Ignore this label";
+// Totals
+const failTotal = Object.freeze({
+  label: failLabel,
+  amount: failAmount,
+});
+const passTotal = Object.freeze({
+  label: passLabel,
+  amount: passAmount,
+});
+const neutralTotal = Object.freeze({
+  label: neutralLabel,
+  amount: passAmount,
+});
+
+// PaymentItem
+const failPaymentItem = Object.freeze({
+  amount: failAmount,
+  label: failLabel,
+});
+const failPaymentItems = Object.freeze([failPaymentItem]);
+
+const passPaymentItem = Object.freeze({
+  amount: passAmount,
+  label: passLabel,
+});
+const passPaymentItems = Object.freeze([passPaymentItem]);
+
+// PaymentShippingOptions
+const failShippingOption = Object.freeze({
+  id: "fail",
+  label: failLabel,
+  amount: failAmount,
+});
+const failShippingOptions = Object.freeze([failShippingOption]);
+
+const neutralShippingOption = Object.freeze({
+  id: "neutral",
+  label: neutralLabel,
+  amount: neutralAmount,
+});
+
+const updatedShippingOption1 = Object.freeze({
+  id: "updated-1",
+  label: `${passLabel} - option 1`,
+  amount: passAmount,
+});
+const updatedShippingOption2 = Object.freeze({
+  id: "updated-2",
+  label: `${passLabel} - option 2 (MUST BE SELECTED!)`,
+  amount: passAmount,
+  selected: true,
+});
+const passShippingOptions = Object.freeze([
+  updatedShippingOption1,
+  updatedShippingOption2,
+]);
+
+// Modifiers
+// create a modifier objects for each validMethods
+// and single additional display item
+const failModifiers = validMethods.map(modifier => {
+  const label = `${failLabel} - (${modifier.supportedMethods})`;
+  return {
+    ...modifier,
+    total: {
+      ...failTotal,
+      label,
+    },
+    additionalDisplayItems: [
+      {
+        ...failPaymentItem,
+        label,
+      },
+    ],
+  };
+});
+// Updates the total for each, and changes the additionalDisplayItems
+const passModifiers = failModifiers.map(modifier => {
+  const label = `${passLabel} - (${modifier.supportedMethods})`;
+  return {
+    ...modifier,
+    total: {
+      ...passTotal,
+      label,
+    },
+    additionalDisplayItems: [
+      {
+        ...passPaymentItem,
+        label,
+      },
+    ],
+  };
+});
+
+// PaymentDetailsInit
+const failDetails = Object.freeze({
+  displayItems: failPaymentItems,
+  id: "this cannot be changed",
+  modifiers: failModifiers,
+  shippingOptions: failShippingOptions,
+  total: failTotal,
+});
+
+const neutralDetails = Object.freeze({
+  displayItems: [],
+  modifiers: [],
+  shippingOptions: [neutralShippingOption],
+  total: neutralTotal,
+});
+
+function smokeTest() {
+  promise_test(async t => {
+    const request = new PaymentRequest(validMethods, failDetails);
+    await promise_rejects(
+      t,
+      new TypeError(),
+      request.show({
+        total: "This throws a TypeError",
+      }),
+      "expected TypeError"
+    );
+  }, "smoke test - checks if the optional details are supported on show() method");
+}
+
+function runUpdateDetailsAlgorithm(
+  buttonElement,
+  details,
+  options = {
+    requestShipping: true,
+  }
+) {
+  const testAssertion = buttonElement.textContent.trim();
+  buttonElement.disabled = true;
+  promise_test(async t => {
+    const request = new PaymentRequest(validMethods, failDetails, options);
+    const detailsPromise = Promise.resolve(details);
+    const acceptPromise = request.show(detailsPromise);
+    assert_equals(request.id, "this cannot be changed", "id must never change.");
+    await promise_rejects(
+      t,
+      "AbortError",
+      acceptPromise,
+      "expected AbortError"
+    );
+  }, testAssertion);
+}
+</script>
+<h2>
+  PaymentRequest <code>.show(optional detailsPromise)</code> tests
+</h2>
+<p>
+  These test cause <code>detailsPromise</code> to resolve successfully with some updated value. As such, that will cause
+  something in the payment sheet to change. Each test describes what is expected to change - if anything.
+</p>
+<p>
+  <strong>Instructions:</strong> Click on each button in sequence from top to bottom without refreshing the page. The payment
+  sheet will be shown. If required, confirm that the expected value appears in the payment sheet. Finally, manually abort/cancel
+  the payment request by closing the payment sheet.
+</p>
+<ol>
+  <li><button onclick="smokeTest()">If the payment sheet is shown, the test has failed.</button></li>
+  <li><button onclick="
+    const details = {
+      ...neutralDetails,
+      id: 'fail',
+    };
+    runUpdateDetailsAlgorithm(this, details);
+  ">
+    When the payment sheet is shown, the provided `id` must have no effect on the payment request.
+  </button></li>
+  <li><button onclick="
+    const details = {
+      ...neutralDetails,
+      total: passTotal
+    };
+    runUpdateDetailsAlgorithm(this, details);
+  ">
+    When the payment sheet is shown, the total must be CAD$50 with the label "✅ TEST HAS PASSED ✅".
+  </button></li>
+  <li><button onclick="
+    const details = {
+      ...neutralDetails,
+      displayItems: passPaymentItems,
+    };
+    runUpdateDetailsAlgorithm(this, details);
+    ">
+    When the payment sheet is shown, there must be a one display item with a value of CAD$50 with the label "✅ TEST HAS PASSED ✅".
+    </button>
+  </li>
+  <li><button onclick="
+    const auItem = {
+      ...passPaymentItem,
+      amount: { value: '40', currency: 'AUD'},
+      pending: true
+    }
+    const details = {
+      ...neutralDetails,
+      displayItems: passPaymentItems.concat(auItem),
+    };
+    runUpdateDetailsAlgorithm(this, details);
+    ">
+    When the payment sheet is shown, there must be
+    two display items: One with a value of CAD$50, another with
+    value AUD$40 that is pending.
+    </button>
+  </li>
+  <li><button onclick="
+    const details = {
+      ...neutralDetails,
+      shippingOptions: [updatedShippingOption1],
+    };
+    runUpdateDetailsAlgorithm(this, details);
+    ">
+    When the payment sheet is shown, there must be a one shipping option
+    with a value of CAD$50.
+    </button>
+  </li>
+  <li><button onclick="
+    const details = {
+      ...neutralDetails,
+      shippingOptions: passShippingOptions,
+    };
+    runUpdateDetailsAlgorithm(this, details);
+    ">
+    When the payment sheet is shown, there must be
+    two shipping options: One with a value of CAD$50, another with
+    value AUD$40 that is selected.
+    </button>
+  </li>
+  <li><button onclick="
+    const details = {
+      ...neutralDetails,
+      modifiers: passModifiers,
+    };
+    runUpdateDetailsAlgorithm(this, details);
+    ">
+    When the payment sheet is shown, the total should be CAD$50.
+  </button>
+  </li>
+  <li>
+    <button onclick="
+      const details = {
+        ...neutralDetails,
+        shippingOptions: [],
+        error: passLabel,
+      };
+      runUpdateDetailsAlgorithm(this, details);
+    ">
+    When the payment sheet is shown, the string "✅ TEST HAS PASSED ✅" should be shown
+    somewhere in the user interface. Alternatively, the payment sheet must indicate to the
+    end user that it's not possible to ship their order.
+    </button>
+  </li>
+  <li>
+    <button onclick="
+      const details = {
+        ...neutralDetails,
+        error: failLabel,
+      };
+      runUpdateDetailsAlgorithm(this, details, {requestShipping: false});
+    ">
+    When the payment sheet is shown, there should not be any errors shown.
+    </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>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-iframe.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-iframe.html
new file mode 100644 (file)
index 0000000..12a1e0c
--- /dev/null
@@ -0,0 +1,40 @@
+<h1>This iframe calls shows() via postMessage()</h1>
+<script>
+"use strict";
+const defaultMethods = Object.freeze([
+  { supportedMethods: "basic-card" },
+  { supportedMethods: "https://apple.com/apple-pay" },
+]);
+
+const defaultDetails = Object.freeze({
+  id: "fail",
+  total: {
+    label: "Total",
+    amount: {
+      currency: "USD",
+      value: "1.00",
+    },
+  },
+});
+
+// We are going to use the id to prove that this works
+// which we will pass back to the caller
+window.onmessage = async event => {
+  const { source, data: { id, request } } = event;
+  switch (request) {
+    case "show-payment-request": {
+      const details = Object.assign({}, defaultDetails, { id });
+      const request = new PaymentRequest(defaultMethods, details);
+      try {
+        const response = await request.show();
+        source.postMessage(response.toJSON(), window.location.origin);
+        await response.complete();
+      } catch (err) {
+        source.postMessage({ requestId: "fail" }, window.location.origin);
+        await request.abort();
+      }
+    }
+  }
+};
+
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-manual.https.html
new file mode 100644 (file)
index 0000000..e4ab550
--- /dev/null
@@ -0,0 +1,81 @@
+<!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,
+  allow_uncaught_exception: true,
+});
+
+const defaultMethods = Object.freeze([
+  { supportedMethods: "basic-card" },
+  { supportedMethods: "https://apple.com/apple-pay" },
+]);
+
+const defaultDetails = Object.freeze({
+  id: "fail",
+  total: {
+    label: "Total",
+    amount: {
+      currency: "USD",
+      value: "1.00",
+    },
+  },
+});
+
+test(() => {
+  assert_throws(
+    "SecurityError",
+    () => {
+      const request = new PaymentRequest(defaultMethods, defaultDetails);
+      request.show(); // <--- should throw here
+      request.abort();
+    },
+    "throws a SecurityError if not triggered by user activation"
+  );
+});
+
+async function runUserActivation(button) {
+  button.disabled = true;
+  const { contentWindow: iframeWindow } = document.getElementById("iframe");
+  const expectedId = "pass123";
+  await Promise.resolve(); // next tick
+  const promiseForResponse = new Promise(resolve => {
+    window.onmessage = ({ data: { requestId } }) => resolve(requestId);
+  });
+  const ops = { id: expectedId, request: "show-payment-request" };
+  iframeWindow.postMessage(ops, window.location.origin);
+  promise_test(async () => {
+    const actualId = await promiseForResponse;
+    assert_equals(actualId, expectedId, "ids must match");
+  }, button.textContent.trim());
+  done();
+}
+
+</script>
+<h2>Test PaymentRequest.show() triggered by user activation using postMessage()</h2>
+<p>
+  Tests that user activation works over postMessage().
+</p>
+<p>
+  Click on bottom below. Hit "Pay".
+</p>
+<ol>
+  <li>
+    <button onclick="runUserActivation(this)">
+      show() is triggered by user activation passed through postMessage() and a promise
+    </button>
+  </li>
+</ol>
+<iframe width="100%" id="iframe" src="show-method-postmessage-iframe.html" allowpaymentrequest></iframe>
+<p>
+  <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>
+</p>
index adc3d6a..06852bf 100644 (file)
@@ -126,6 +126,6 @@ function manualTest(button, { invalidMethod }) {
   </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>.
+  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 bfc83ab..0ba0405 100644 (file)
@@ -65,6 +65,6 @@ async function runAbortTest(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>.
+  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 c4d390f..abaf6cb 100644 (file)
@@ -215,6 +215,6 @@ function testAcceptRequestAlgorithm(
   </ol>
 </section>
 <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>.
+  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 dfabbd2..151f01c 100644 (file)
@@ -1,7 +1,7 @@
 The tests in this directory were imported from the W3C repository.
 Do NOT modify these tests directly in WebKit.
 Instead, create a pull request on the WPT github:
-       https://github.com/w3c/web-platform-tests
+       https://github.com/web-platform-tests/wpt
 
 Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
 
@@ -14,18 +14,22 @@ Property values requiring vendor prefixes:
 None
 ------------------------------------------------------------------------
 List of files:
-/LayoutTests/imported/w3c/web-platform-tests/payment-request/OWNERS
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/META.yml
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/algorithms-manual.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/change-shipping-option-manual.https.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/historical.https.html
-/LayoutTests/imported/w3c/web-platform-tests/payment-request/interfaces.https.html
-/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method-manual.https.html
-/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method-manual.https.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/idlharness.https.window.js
+/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.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
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-ctor-currency-code-checks.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-ctor-pmi-handling.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-request-insecure.http.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.js
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-onshippingaddresschange-attribute.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-onshippingoptionchange-attribute.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-shippingAddress-attribute.https.html
@@ -34,6 +38,10 @@ List of files:
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/shipping-address-changed-manual.https.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-iframe.html
+/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-manual.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/updateWith-method-pmi-handling-manual.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/user-abort-algorithm-manual.https.html
 /LayoutTests/imported/w3c/web-platform-tests/payment-request/user-accepts-payment-request-algo-manual.https.html
index 555d7e1..2aa97de 100644 (file)
@@ -46,18 +46,28 @@ imported/w3c/web-platform-tests/payment-request/payment-request-show-method.http
 imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html [ WontFix ]
 
 # skip manual payment-request tests
+imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-error-member-manual.https.html [ Skip ]
+imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-payer-member-manual.https.html [ Skip ]
+imported/w3c/web-platform-tests/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/algorithms-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/change-shipping-option-manual.https.html [ Skip ]
+imported/w3c/web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/payment-response/complete-method-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/payment-response/methodName-attribute-manual.https.html [ Skip ]
+imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/payment-response/payerEmail-attribute-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/payment-response/payerName-attribute-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/payment-response/payerPhone-attribute-manual.https.html [ Skip ]
+imported/w3c/web-platform-tests/payment-request/payment-response/rejects_if_not_active-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/payment-response/requestId-attribute-manual.https.html [ Skip ]
+imported/w3c/web-platform-tests/payment-request/payment-response/retry-method-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/payment-response/shippingAddress-attribute-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/payment-response/shippingOption-attribute-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/PaymentAddress/attributes-and-toJSON-method-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/shipping-address-changed-manual.https.html [ Skip ]
+imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html [ Skip ]
+imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html [ Skip ]
+imported/w3c/web-platform-tests/payment-request/show-method-postmessage-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/updateWith-method-pmi-handling-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/user-abort-algorithm-manual.https.html [ Skip ]
 imported/w3c/web-platform-tests/payment-request/user-accepts-payment-request-algo-manual.https.html [ Skip ]