chromium/third_party/blink/web_tests/wpt_internal/digital-goods/digital-goods-default-permissions-policy.https.sub.html

<!DOCTYPE html>
<html>
<body>
  <script src=/resources/testharness.js></script>
  <script src=/resources/testharnessreport.js></script>
  <script src=/permissions-policy/resources/permissions-policy.js></script>
  <script type='module'>
    import '/wpt_internal/digital-goods/resources/mock-digital-goods-service.js';

    var same_origin_src = '/wpt_internal/digital-goods/resources/permissions-policy-helper.html';
    // Same top level origin as `same_origin_src` but adds 'www' subdomain.
    var subdomain_src = 'https://{{domains[www]}}:{{ports[https][0]}}' + same_origin_src;
    var header = 'Default "payment" permissions policy';

    promise_test(async () => {
      try {
        await window.getDigitalGoodsService('https://example.com/billing');
      } catch (error) {
        assert_unreached(error);
      }
    }, header + ' allows the top-level document.');

    async_test(t => {
      test_feature_availability('getDigitalGoodsService()', t, same_origin_src,
        expect_feature_available_default);
    }, header + ' allows same-origin iframes.');

    async_test(t => {
      test_feature_availability('getDigitalGoodsService()', t, subdomain_src,
        expect_feature_unavailable_default);
    }, header + ' disallows subdomain iframes.');

    async_test(t => {
      test_feature_availability('getDigitalGoodsService()', t, same_origin_src,
        expect_feature_available_default, 'payment');
    }, header + '  allow="payment" allows same-origin iframes.');

    async_test(t => {
      test_feature_availability('getDigitalGoodsService()', t, subdomain_src,
        expect_feature_available_default, 'payment');
    }, header + ' allow="payment" allows subdomain iframes.');
  </script>
</body>
</html>