
<meta name=timeout content=long>
<title>reporting same origin with report-to</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/common/utils.js"></script>
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="/html/cross-origin-opener-policy/resources/common.js"></script>
<script src="/html/cross-origin-opener-policy/reporting/resources/reporting-common.js"></script>

<script>

let tests = [
  // popup origin, popup COOP, popup COEP, popup COOP report-only, popup COEP report-only, expected reports

  // Open a cross-origin popup with COOP report-only with coep, which mismatches
  // with the current document (opener) COOP (unsafe-none) and COOP report-only
  // (same-origin) values.
  [
    SAME_ORIGIN,
    "",
    "require-corp",
    `same-origin; report-to="${popupReportOnlyEndpoint.name}"`,
    "",
    [
      {
        "endpoint": popupReportOnlyEndpoint,
        "report": {
          "body": {
            "disposition": "reporting",
            "effectivePolicy": "same-origin-plus-coep",
            "previousResponseURL": `${location.href}`,
            "referrer": `${location.origin}/`,
            "type": "navigation-to-response"
          },
          "url": /uuid=EXECUTOR_UUID$/,
          "type": "coop"
        }
      }
    ]
  ],
  // Open a cross-origin popup with COOP report-only with coep report-only,
  // which mismatches with the current document (opener) COOP (unsafe-none) and
  // COOP report-only (same-origin) values.
  [
    SAME_ORIGIN,
    "",
    "",
    `same-origin; report-to="${popupReportOnlyEndpoint.name}"`,
    "require-corp",
    [
      {
        "endpoint": popupReportOnlyEndpoint,
        "report": {
          "body": {
            "disposition": "reporting",
            "effectivePolicy": "same-origin-plus-coep",
            "previousResponseURL": `${location.href}`,
            "referrer": `${location.origin}/`,
            "type": "navigation-to-response"
          },
          "url": /uuid=EXECUTOR_UUID$/,
          "type": "coop"
        }
      }
    ]
  ],
];

runNavigationReportingTests(document.title, tests);

</script>
