#include <string>
#include <vector>
#include "base/memory/ref_counted.h"
#include "base/test/scoped_feature_list.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "services/network/public/cpp/cross_origin_resource_policy.h"
#include "services/network/public/mojom/blocked_by_response_reason.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace network {
namespace {
class TestCoepReporter final : public mojom::CrossOriginEmbedderPolicyReporter { … };
}
CrossOriginResourcePolicy::ParsedHeader ParseHeader(
const std::string& test_headers) { … }
TEST(CrossOriginResourcePolicyTest, ParseHeader) { … }
TEST(CrossOriginResourcePolicyTest, CrossSiteHeaderWithCOEP) { … }
bool ShouldAllowSameSite(const std::string& initiator,
const std::string& target) { … }
TEST(CrossOriginResourcePolicyTest, ShouldAllowSameSite) { … }
void CheckCORP(mojom::RequestMode request_mode,
const url::Origin& origin,
mojom::URLResponseHeadPtr response_info,
const CrossOriginEmbedderPolicy& coep,
const DocumentIsolationPolicy& dip,
std::optional<mojom::BlockedByResponseReason> expected_result,
bool expect_coep_report,
bool expect_coep_report_only) { … }
void RunCORPTestWithCOEPAndDIP(
const CrossOriginEmbedderPolicy& coep,
const DocumentIsolationPolicy& dip,
std::optional<mojom::BlockedByResponseReason> expected_result,
bool include_credentials,
bool expect_coep_report,
bool expect_coep_report_only) { … }
TEST(CrossOriginResourcePolicyTest, WithCOEP) { … }
TEST(CrossOriginResourcePolicyTest, WithCOEPNoCredentials) { … }
TEST(CrossOriginResourcePolicyTest, WithDIP) { … }
TEST(CrossOriginResourcePolicyTest, WithDIPNoCredentials) { … }
TEST(CrossOriginResourcePolicyTest, WithCOEPAndDIP) { … }
TEST(CrossOriginResourcePolicyTest, WithCOEPAndDIPNoCredentials) { … }
TEST(CrossOriginResourcePolicyTest, NavigationWithCOEP) { … }
}