payment-allowed-by-permissions-policy.https.sub.html (2149B)
1 <!DOCTYPE html> 2 <body> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/permissions-policy/resources/permissions-policy.js"></script> 6 <script> 7 "use strict"; 8 const same_origin_src = 9 "/permissions-policy/resources/permissions-policy-payment.html"; 10 const cross_origin_src = 11 "https://{{hosts[alt][]}}:{{ports[https][0]}}" + same_origin_src; 12 const header = 'permissions policy header "payment=*"'; 13 14 test(() => { 15 const supportedMethods = [ 16 { 17 supportedMethods: "https://{{domains[nonexistent]}}/payment-request", 18 }, 19 ]; 20 const details = { 21 total: { 22 label: "Test", 23 amount: { currency: "USD", value: "5.00" }, 24 }, 25 }; 26 try { 27 new PaymentRequest(supportedMethods, details); 28 } catch (e) { 29 assert_unreached(); 30 } 31 }, `${header} allows Payment Request API the top-level document.`); 32 33 promise_test((test) => { 34 return test_feature_availability({ 35 feature_description: "PaymentRequest()", 36 test, 37 src: same_origin_src, 38 expect_feature_available: expect_feature_available_default, 39 is_promise_test: true, 40 }); 41 }, `${header} allows Payment Request API same-origin iframes.`); 42 43 promise_test(async (test) => { 44 return test_feature_availability({ 45 feature_description: "PaymentRequest()", 46 test, 47 src: cross_origin_src, 48 expect_feature_available: expect_feature_unavailable_default, 49 is_promise_test: true, 50 }); 51 }, `Payment Request API is disabled in cross-origin iframe if allow="payment" is not set and ${header}.`); 52 53 promise_test(async (test) => { 54 return test_feature_availability({ 55 feature_description: "PaymentRequest()", 56 test, 57 src: cross_origin_src, 58 expect_feature_available: expect_feature_available_default, 59 feature_name: "payment", 60 is_promise_test: true, 61 }); 62 }, `${header} allow="payment" allows Payment Request in cross-origin iframes.`); 63 </script> 64 </body>