chromium/third_party/blink/web_tests/http/tests/feature-policy/payment-allowed-by-container-policy-relocate.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/helper.js"></script>
<iframe src="about:blank" allow="payment"></iframe>
<iframe src="about:blank" allowpaymentrequest allow="payment"></iframe>
<iframe src="about:blank" allowpaymentrequest></iframe>
<script>
var srcs = [
  "http://localhost:8000/feature-policy/resources/feature-policy-payment.html",
  "resources/feature-policy-payment-relocate.html"
];

function loadFrame(iframe, src) {
  var allowpaymentrequest = iframe.hasAttribute('allowpaymentrequest');
  var allow = iframe.hasAttribute('allow');
  // paymentrequest is enabled if:
  //     a. relocating within the same origin; or
  //     b. relocating across origin, with allowpaymentrequest not overriden by
  //        container policy.
  var expectedEnabled =
    (src === srcs[0]) || (src === srcs[1] && allowpaymentrequest && !allow)
  promise_test(function() {
    iframe.src = src;
    return new Promise(function(resolve, reject) {
      window.addEventListener('message', function(e) {
          resolve(e.data);
      }, { once: true });
    }).then(function(data) {
      if (expectedEnabled) {
        assert_true(data.enabled, 'Paymentrequest():');
      } else {
        assert_false(data.enabled, 'Paymentrequest():');
        assert_equals(data.name, 'SecurityError', 'Exception Name:');
        assert_equals(data.message, "Failed to construct 'PaymentRequest': " +
            "Must be in a top-level browsing context or an iframe needs to " +
            "specify allow=\"payment\" explicitly", 'Error Message:');
      }
    });
  }, 'Iframe src set to ' + src + ', allowpaymentrequest = ' +
  allowpaymentrequest + ', allow = ' + (allow ? 'payment' : 'undefined') +
  ', payment request is ' + (expectedEnabled ? 'enabled' : 'disabled') +
  ' by container policy.');
}

window.onload = function() {
  loadIframes(srcs);
}
</script>