chromium/content/browser/cookie_deprecation_label/cookie_deprecation_label_browsertest.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <memory>

#include "base/containers/contains.h"
#include "base/metrics/histogram_base.h"
#include "base/strings/strcat.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "content/browser/cookie_deprecation_label/cookie_deprecation_label_test_utils.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_content_browser_client.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/shell/browser/shell.h"
#include "net/dns/mock_host_resolver.h"
#include "net/http/http_status_code.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace content {

namespace {

EmbeddedTestServer;

constexpr char kSecCookieDeprecationHeaderStatus[] =;

class CookieDeprecationLabelBrowserTestBase : public ContentBrowserTest {};

class CookieDeprecationLabelDisabledBrowserTest
    : public CookieDeprecationLabelBrowserTestBase {};

IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelDisabledBrowserTest,
                       FeatureDisabled_CookieDeprecationLabelHeaderNotAdded) {}

class CookieDeprecationLabelEnabledBrowserTest
    : public CookieDeprecationLabelBrowserTestBase {};

IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelEnabledBrowserTest,
                       HeaderAddedOnceOptedIn) {}

IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelEnabledBrowserTest,
                       HeaderCanOnlyBeSetViaOptInCookie) {}

IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelEnabledBrowserTest,
                       OptedInRedirectChain_HeaderAdded) {}

IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelEnabledBrowserTest,
                       InvalidOptInCookie_HeaderNotAdded) {}

IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelEnabledBrowserTest,
                       RequestNotSecure_HeaderNotAdded) {}

IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelEnabledBrowserTest,
                       NotAllowed_EmptyLabelReturned) {}

IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelEnabledBrowserTest,
                       Allowed_LabelReturned) {}

IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelEnabledBrowserTest,
                       OffTheRecord_EmptyLabelReturned) {}

class CookieDeprecationLabelEnabledEmptyLabelBrowserTest
    : public CookieDeprecationLabelBrowserTestBase {};

IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelEnabledEmptyLabelBrowserTest,
                       EmptyLabel_CookieDeprecationLabelHeaderNotAdded) {}

class CookieDeprecationLabelOffTheRecordEnabledBrowserTest
    : public CookieDeprecationLabelBrowserTestBase {};

// Ensure that cookie deprecation labels are present in incognito mode if the
// "enable_otr_profiles" feature parameter is true. See also the
// CookieDeprecationLabelEnabledBrowserTest.OffTheRecord_EmptyLabelReturned
// test.
IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelOffTheRecordEnabledBrowserTest,
                       OffTheRecord_LabelReturned) {}

}  // namespace

}  // namespace content