#include <memory>
#include <string_view>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
#include "base/thread_annotations.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/base/features.h"
#include "net/test/embedded_test_server/http_request.h"
#include "services/network/public/mojom/referrer_policy.mojom-shared.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/input/web_mouse_event.h"
#include "third_party/blink/public/common/loader/referrer_utils.h"
#include "third_party/blink/public/common/switches.h"
#include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h"
class ReferrerPolicyTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Origin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsDefault) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickTargetBlankOrigin) { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_ContextMenuOrigin …
#else
#define MAYBE_ContextMenuOrigin …
#endif
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_ContextMenuOrigin) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_HttpsContextMenuOrigin …
#else
#define MAYBE_HttpsContextMenuOrigin …
#endif
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_HttpsContextMenuOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsRedirect) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickRedirect) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickRedirect) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickRedirect) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickRedirect) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankRedirect) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankRedirect) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankRedirect) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest,
HttpsMiddleClickTargetBlankRedirect) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_ContextMenuRedirect …
#else
#define MAYBE_ContextMenuRedirect …
#endif
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_ContextMenuRedirect) { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_HttpsContextMenuRedirect …
#else
#define MAYBE_HttpsContextMenuRedirect …
#endif
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_HttpsContextMenuRedirect) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, RequestTabletSite) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, IFrame) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest,
HttpLeftClickHTTPSRedirectToHTTPOriginWhenCrossOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest,
HttpLeftClickRedirectToHTTPSOriginWhenCrossOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest,
HttpLeftClickRedirectToHTTPOriginWhenCrossOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest,
HttpLeftClickHTTPRedirectToHTTPSameOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest,
HttpLeftClickHTTPRedirectToHTTPSSameOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest,
HttpLeftClickHTTPRedirectToHTTPStrictOrigin) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest,
HttpLeftClickHTTPSRedirectToHTTPStrictOrigin) { … }
struct ReferrerOverrideParams { … } kReferrerOverrideParams[] = …;
class ReferrerOverrideTest
: public ReferrerPolicyTest,
public ::testing::WithParamInterface<ReferrerOverrideParams> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(ReferrerOverrideTest, SameOriginNavigation) { … }
IN_PROC_BROWSER_TEST_P(ReferrerOverrideTest, CrossOriginNavigation) { … }
IN_PROC_BROWSER_TEST_P(ReferrerOverrideTest,
CrossOriginNavigationBrowserInitiated) { … }
IN_PROC_BROWSER_TEST_P(ReferrerOverrideTest, CrossOriginDowngradeNavigation) { … }
IN_PROC_BROWSER_TEST_P(ReferrerOverrideTest, CrossOriginRedirect) { … }
IN_PROC_BROWSER_TEST_P(ReferrerOverrideTest, CrossOriginToSameOriginRedirect) { … }
IN_PROC_BROWSER_TEST_P(ReferrerOverrideTest, SameOriginSubresource) { … }
IN_PROC_BROWSER_TEST_P(ReferrerOverrideTest,
SameOriginToCrossOriginSubresourceRedirect) { … }
class ReferrerPolicyCapReferrerToOriginOnCrossOriginTest
: public ReferrerPolicyTest { … };
IN_PROC_BROWSER_TEST_F(ReferrerPolicyCapReferrerToOriginOnCrossOriginTest,
HonorsMoreRestrictivePolicyOnNavigation) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyCapReferrerToOriginOnCrossOriginTest,
HonorsMoreRestrictivePolicyOnRedirect) { … }
IN_PROC_BROWSER_TEST_F(ReferrerPolicyCapReferrerToOriginOnCrossOriginTest,
RespectsNoReferrerPref) { … }