chromium/chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc

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

#include <iterator>
#include <memory>
#include <string>
#include <string_view>
#include <unordered_set>
#include <utility>
#include <vector>

#include "base/check_op.h"
#include "base/containers/to_vector.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/memory/weak_ptr.h"
#include "base/path_service.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/trace_event_analyzer.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer.h"
#include "chrome/browser/page_load_metrics/observers/document_write_page_load_metrics_observer.h"
#include "chrome/browser/page_load_metrics/observers/service_worker_page_load_metrics_observer.h"
#include "chrome/browser/page_load_metrics/page_load_metrics_initialize.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/preloading/prefetch/no_state_prefetch/no_state_prefetch_manager_factory.h"
#include "chrome/browser/preloading/prefetch/no_state_prefetch/no_state_prefetch_test_utils.h"
#include "chrome/browser/preloading/preview/preview_test_util.h"
#include "chrome/browser/profiles/keep_alive/profile_keep_alive_types.h"
#include "chrome/browser/profiles/keep_alive/scoped_profile_keep_alive.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h"
#include "chrome/browser/sessions/session_restore.h"
#include "chrome/browser/sessions/session_restore_test_helper.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/sessions/session_service_test_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/common/features.h"
#include "components/embedder_support/user_agent_utils.h"
#include "components/keep_alive_registry/keep_alive_types.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
#include "components/no_state_prefetch/browser/no_state_prefetch_handle.h"
#include "components/no_state_prefetch/browser/no_state_prefetch_manager.h"
#include "components/no_state_prefetch/browser/prerender_histograms.h"
#include "components/no_state_prefetch/common/no_state_prefetch_origin.h"
#include "components/page_load_metrics/browser/observers/abandoned_page_load_metrics_observer.h"
#include "components/page_load_metrics/browser/observers/core/uma_page_load_metrics_observer.h"
#include "components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer.h"
#include "components/page_load_metrics/browser/page_load_metrics_test_waiter.h"
#include "components/page_load_metrics/browser/page_load_tracker.h"
#include "components/prefs/pref_service.h"
#include "components/sessions/content/content_test_helper.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/browser/back_forward_cache.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/tracing_controller.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/referrer.h"
#include "content/public/common/result_codes.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/download_test_observer.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/hit_test_region_observer.h"
#include "content/public/test/navigation_handle_observer.h"
#include "content/public/test/no_renderer_crashes_assertion.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_navigation_observer.h"
#include "net/base/net_errors.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/network/public/cpp/features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/chrome_debug_urls.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom.h"
#include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom.h"
#include "ui/gfx/geometry/size.h"
#include "url/gurl.h"

PageEndReason;
PageLoadMetricsTestWaiter;
TimingField;
WebFeature;
SizeIs;
UnorderedElementsAre;
NoStatePrefetch;
PageLoad;
HistoryNavigation;
Query;
TraceAnalyzer;
TraceEventVector;

namespace {

constexpr char kCacheablePathPrefix[] =;

const char kResponseWithNoStore[] =;

constexpr char kCreateFrameAtPositionScript[] =;

constexpr char kCreateFrameAtPositionNotifyOnLoadScript[] =;

constexpr char kCreateFrameAtTopRightPositionScript[] =;

std::unique_ptr<net::test_server::HttpResponse> HandleCachableRequestHandler(
    const net::test_server::HttpRequest& request) {}

}  // namespace

class PageLoadMetricsBrowserTest : public InProcessBrowserTest {};

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PageLCPImagePriority) {}

class PageLoadMetricsBrowserTestAnimatedLCP
    : public PageLoadMetricsBrowserTest {};

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoNavigation) {}

// TODO(crbug.com/40839280): Re-enable this test
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       DISABLED_MainFrameViewportRect) {}

// TODO(crbug.com/40916877): Fix this test on Mac.
#if BUILDFLAG(IS_MAC)
#define MAYBE_MainFrameIntersection_RTLPage
#else
#define MAYBE_MainFrameIntersection_RTLPage
#endif
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       MAYBE_MainFrameIntersection_RTLPage) {}

IN_PROC_BROWSER_TEST_F(
    PageLoadMetricsBrowserTest,
    // TODO(crbug.com/40839452): Re-enable this test
    DISABLED_NonZeroMainFrameScrollOffset_NestedSameOriginFrame_MainFrameIntersection) {}

// TODO(crbug.com/40234728): Fix flakiness.
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC)
#define MAYBE_NonZeroMainFrameScrollOffset_NestedCrossOriginFrame_MainFrameIntersection
#else
#define MAYBE_NonZeroMainFrameScrollOffset_NestedCrossOriginFrame_MainFrameIntersection
#endif
IN_PROC_BROWSER_TEST_F(
    PageLoadMetricsBrowserTest,
    MAYBE_NonZeroMainFrameScrollOffset_NestedCrossOriginFrame_MainFrameIntersection) {}

// TODO(crbug.com/40916877): Fix this test on Mac.
#if BUILDFLAG(IS_MAC)
#define MAYBE_NonZeroMainFrameScrollOffset_SameOriginFrameAppended_MainFrameIntersection
#else
#define MAYBE_NonZeroMainFrameScrollOffset_SameOriginFrameAppended_MainFrameIntersection
#endif
IN_PROC_BROWSER_TEST_F(
    PageLoadMetricsBrowserTest,
    MAYBE_NonZeroMainFrameScrollOffset_SameOriginFrameAppended_MainFrameIntersection) {}

// TODO(crbug.com/40916877): Fix this test on Mac.
#if BUILDFLAG(IS_MAC)
#define MAYBE_NonZeroMainFrameScrollOffset_CrossOriginFrameAppended_MainFrameIntersection
#else
#define MAYBE_NonZeroMainFrameScrollOffset_CrossOriginFrameAppended_MainFrameIntersection
#endif
IN_PROC_BROWSER_TEST_F(
    PageLoadMetricsBrowserTest,
    MAYBE_NonZeroMainFrameScrollOffset_CrossOriginFrameAppended_MainFrameIntersection) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NewPage) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, Redirect) {}

class PageLoadMetricsPre3pcdBrowserTest : public PageLoadMetricsBrowserTest {};

// TODO(crbug.com/40931292): Re-enable this test on Lacros.
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_NoStatePrefetchMetrics
#else
#define MAYBE_NoStatePrefetchMetrics
#endif
// Triggers nostate prefetch, and verifies that the UKM metrics related to
// nostate prefetch are recorded correctly.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsPre3pcdBrowserTest,
                       MAYBE_NoStatePrefetchMetrics) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, CachedPage) {}

// Test that we log kMainFrameResource_RequestHasNoStore when response has
// cache-control:no-store response header.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, MainFrameHasNoStore) {}

// Test that we set kMainFrameResource_RequestHasNoStore to false when response
// has no cache-control:no-store header.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       MainFrameDoesnotHaveNoStore) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NewPageInNewForegroundTab) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoPaintForEmptyDocument) {}

// TODO(crbug.com/41472183): Flaky on Win and Linux.
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_NoPaintForEmptyDocumentInChildFrame
#else
#define MAYBE_NoPaintForEmptyDocumentInChildFrame
#endif
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       MAYBE_NoPaintForEmptyDocumentInChildFrame) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PaintInChildFrame) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PaintInDynamicChildFrame) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PaintInMultipleChildFrames) {}

// TODO(crbug.com/334416161): Re-enable this test on Windows.
#if BUILDFLAG(IS_WIN)
#define MAYBE_PaintInMainAndChildFrame
#else
#define MAYBE_PaintInMainAndChildFrame
#endif
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       MAYBE_PaintInMainAndChildFrame) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SameDocumentNavigation) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SameUrlNavigation) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       DocWriteAbortsSubframeNavigation) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NonHtmlMainResource) {}

// TODO(crbug.com/40774566): Test flakes on Chrome OS.
#if BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_NonHttpOrHttpsUrl
#else
#define MAYBE_NonHttpOrHttpsUrl
#endif
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, MAYBE_NonHttpOrHttpsUrl) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, HttpErrorPage) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, ChromeErrorPage) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, Ignore204Pages) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, IgnoreDownloads) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoDocumentWrite) {}

// Flaky on lacros. See https://crbug.com/1484915
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_DocumentWriteBlock
#else
#define MAYBE_DocumentWriteBlock
#endif
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, MAYBE_DocumentWriteBlock) {}


// TODO(crbug.com/40931345, crbug.com/334416161): Re-enable this test on Lacros
// and Windows.
#if BUILDFLAG(IS_CHROMEOS_LACROS) || BUILDFLAG(IS_WIN)
#define MAYBE_DocumentWriteReload
#else
#define MAYBE_DocumentWriteReload
#endif
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, MAYBE_DocumentWriteReload) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteAsync) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteSameDomain) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoDocumentWriteScript) {}

// TODO(crbug.com/40516222): Flaky on Linux dbg.
// TODO(crbug.com/41328109): Now flaky on Win and Mac.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DISABLED_BadXhtml) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PayloadSize) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PayloadSizeChildFrame) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       PayloadSizeIgnoresDownloads) {}

// Test UseCounter Features observed in the main frame are recorded, exactly
// once per feature.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterFeaturesInMainFrame) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterCSSPropertiesInMainFrame) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterAnimatedCSSPropertiesInMainFrame) {}

class PageLoadMetricsBrowserTestWithAutoupgradesDisabled
    : public PageLoadMetricsBrowserTest {};

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestWithAutoupgradesDisabled,
                       UseCounterFeaturesMixedContent) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestWithAutoupgradesDisabled,
                       UseCounterCSSPropertiesMixedContent) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestWithAutoupgradesDisabled,
                       UseCounterAnimatedCSSPropertiesMixedContent) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterFeaturesInNonSecureMainFrame) {}

// Test UseCounter UKM features observed.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterUkmFeaturesLogged) {}

// Test UseCounter UKM mixed content features observed.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestWithAutoupgradesDisabled,
                       UseCounterUkmMixedContentFeaturesLogged) {}

// Test UseCounter Features observed in a child frame are recorded, exactly
// once per feature.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, UseCounterFeaturesInIframe) {}

// Test UseCounter Features observed in multiple child frames are recorded,
// exactly once per feature.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterFeaturesInMultipleIframes) {}

// Test UseCounter CSS properties observed in a child frame are recorded,
// exactly once per feature.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterCSSPropertiesInIframe) {}

// Test UseCounter CSS Properties observed in multiple child frames are
// recorded, exactly once per feature.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterCSSPropertiesInMultipleIframes) {}

// Test UseCounter CSS properties observed in a child frame are recorded,
// exactly once per feature.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterAnimatedCSSPropertiesInIframe) {}

// Test UseCounter CSS Properties observed in multiple child frames are
// recorded, exactly once per feature.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterAnimatedCSSPropertiesInMultipleIframes) {}

// Test UseCounter Features observed for SVG pages.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterObserveSVGImagePage) {}

// Test UseCounter Permissions Policy Usages in main frame.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterPermissionsPolicyUsageInMainFrame) {}

// Test UseCounter Permissions Policy Usages observed in child frame
// are recorded, exactly once per feature.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterPermissionsPolicyUsageInIframe) {}

// Test UseCounter Permissions Policy Usages observed in multiple child frames
// are recorded, exactly once per feature.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       UseCounterPermissionsPolicyUsageInMultipleIframes) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, LoadingMetrics) {}

class SessionRestorePageLoadMetricsBrowserTest
    : public PageLoadMetricsBrowserTest {};

class SessionRestorePaintWaiter : public SessionRestoreObserver {};

IN_PROC_BROWSER_TEST_F(SessionRestorePageLoadMetricsBrowserTest,
                       InitialVisibilityOfSingleRestoredTab) {}

IN_PROC_BROWSER_TEST_F(SessionRestorePageLoadMetricsBrowserTest,
                       InitialVisibilityOfMultipleRestoredTabs) {}

enum class ReduceTransferSizeUpdatedIPCTestCase {};

class PageLoadMetricsResourceLoadBrowserTest
    : public PageLoadMetricsBrowserTest,
      public ::testing::WithParamInterface<
          ReduceTransferSizeUpdatedIPCTestCase> {};

INSTANTIATE_TEST_SUITE_P();

// TODO(crbug.com/41412649) Disabled due to flaky timeouts on all platforms.
IN_PROC_BROWSER_TEST_P(PageLoadMetricsResourceLoadBrowserTest,
                       DISABLED_ReceivedAggregateResourceDataLength) {}

IN_PROC_BROWSER_TEST_P(PageLoadMetricsResourceLoadBrowserTest,
                       ChunkedResponse_OverheadDoesNotCountForBodyBytes) {}

IN_PROC_BROWSER_TEST_P(PageLoadMetricsResourceLoadBrowserTest,
                       ReceivedCompleteResources) {}

// TODO(crbug.com/334416161): Re-enable this test on Windows.
#if BUILDFLAG(IS_WIN)
#define MAYBE_InputEventsForClick
#else
#define MAYBE_InputEventsForClick
#endif
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, MAYBE_InputEventsForClick) {}

class SoftNavigationBrowserTest : public PageLoadMetricsBrowserTest {};

class SoftNavigationBrowserTestWithSoftNavigationHeuristicsFlag
    : public SoftNavigationBrowserTest {};

// TODO(crbug.com/341578843): Flaky on many platforms.
IN_PROC_BROWSER_TEST_F(SoftNavigationBrowserTest, DISABLED_SoftNavigation) {}

// TODO(crbug.com/40946340): Flaky on several platforms.
IN_PROC_BROWSER_TEST_F(
    SoftNavigationBrowserTestWithSoftNavigationHeuristicsFlag,
    DISABLED_SoftNavigation) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, InputEventsForOmniboxMatch) {}

// TODO(crbug.com/334416161): Re-enable this test on Windows.
#if BUILDFLAG(IS_WIN)
#define MAYBE_InputEventsForJavaScriptHref
#else
#define MAYBE_InputEventsForJavaScriptHref
#endif
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       MAYBE_InputEventsForJavaScriptHref) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       InputEventsForJavaScriptWindowOpen) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, FirstInputFromScroll) {}

// Does a navigation to a page controlled by a service worker and verifies
// that service worker page load metrics are logged.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, ServiceWorkerMetrics) {}

// Does a navigation to a page controlled by a skippable service worker
// fetch handler and verifies that the page load metrics are logged.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       ServiceWorkerSkippableFetchHandlerMetrics) {}

// Does a navigation to a page which records a WebFeature before commit.
// Regression test for https://crbug.com/1043018.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PreCommitWebFeature) {}

// TODO(crbug.com/40916877): Fix this test on Mac.
#if BUILDFLAG(IS_MAC)
#define MAYBE_MainFrameIntersectionsMainFrame
#else
#define MAYBE_MainFrameIntersectionsMainFrame
#endif
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       MAYBE_MainFrameIntersectionsMainFrame) {}

// TODO(crbug.com/40916877): Fix this test on Mac.
#if BUILDFLAG(IS_MAC)
#define MAYBE_MainFrameIntersectionSingleFrame
#else
#define MAYBE_MainFrameIntersectionSingleFrame
#endif
// Creates a single frame within the main frame and verifies the intersection
// with the main frame.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       MAYBE_MainFrameIntersectionSingleFrame) {}

// TODO(crbug.com/40916877): Fix this test on Mac.
#if BUILDFLAG(IS_MAC)
#define MAYBE_MainFrameIntersectionSameOrigin
#else
#define MAYBE_MainFrameIntersectionSameOrigin
#endif
// Creates a set of nested frames within the main frame and verifies
// their intersections with the main frame.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       MAYBE_MainFrameIntersectionSameOrigin) {}

// TODO(crbug.com/40916877): Fix this test on Mac.
#if BUILDFLAG(IS_MAC)
#define MAYBE_MainFrameIntersectionCrossOrigin
#else
#define MAYBE_MainFrameIntersectionCrossOrigin
#endif
// Creates a set of nested frames, with a cross origin subframe, within the
// main frame and verifies their intersections with the main frame.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       MAYBE_MainFrameIntersectionCrossOrigin) {}

// TODO(crbug.com/40916877): Fix this test on Mac.
#if BUILDFLAG(IS_MAC)
#define MAYBE_MainFrameIntersectionCrossOriginOutOfView
#else
#define MAYBE_MainFrameIntersectionCrossOriginOutOfView
#endif
// Creates a set of nested frames, with a cross origin subframe that is out of
// view within the main frame and verifies their intersections with the main
// frame.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       MAYBE_MainFrameIntersectionCrossOriginOutOfView) {}

// TODO(crbug.com/40916877): Fix this test on Mac.
#if BUILDFLAG(IS_MAC)
#define MAYBE_MainFrameIntersectionCrossOriginScrolled
#else
#define MAYBE_MainFrameIntersectionCrossOriginScrolled
#endif
// Creates a set of nested frames, with a cross origin subframe that is out of
// view within the main frame and verifies their intersections with the main
// frame. The out of view frame is then scrolled back into view and the
// intersection is verified.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       MAYBE_MainFrameIntersectionCrossOriginScrolled) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PageLCPStopsUponInput) {}

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC)
// The LinkPreview feature is implemented only on desktops, and window
// implementation assumes the Aura for now.
// TODO(crbug.com/305004651): Implement the feature for other platforms and
// enable the following tests on the remaining platforms.
class PageLoadMetricsPreviewBrowserTest : public PageLoadMetricsBrowserTest {};

IN_PROC_BROWSER_TEST_F(PageLoadMetricsPreviewBrowserTest,
                       PreviewPrimaryPageType) {}

#endif  // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC)

class PageLoadMetricsBrowserTestTerminatedPage
    : public PageLoadMetricsBrowserTest {};

class PageLoadMetricsBrowserTestDiscardedPage
    : public PageLoadMetricsBrowserTestTerminatedPage,
      public ::testing::WithParamInterface<bool> {};

IN_PROC_BROWSER_TEST_P(PageLoadMetricsBrowserTestDiscardedPage,
                       UkmIsRecordedForDiscardedTabPage) {}

INSTANTIATE_TEST_SUITE_P();

class PageLoadMetricsBrowserTestClosedPage
    : public PageLoadMetricsBrowserTestTerminatedPage,
      public ::testing::WithParamInterface<bool> {};

IN_PROC_BROWSER_TEST_P(PageLoadMetricsBrowserTestClosedPage,
                       UkmIsRecordedForClosedTabPage) {}

INSTANTIATE_TEST_SUITE_P();

// This test is to verify page load metrics are recorded in case when the
// render process is shut down.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestTerminatedPage,
                       UkmIsRecordedWhenRenderProcessShutsDown) {}

// This class is used to verify page load metrics are recorded in case of
// crashes of different kinds. These crashes are simulated by navigating to the
// chrome debug urls.
class PageLoadMetricsBrowserTestCrashedPage
    : public PageLoadMetricsBrowserTestTerminatedPage,
      public ::testing::WithParamInterface<const char*> {};

// TODO(crbug.com/40280758): Very flaky on Lacros.
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_UkmIsRecordedForCrashedTabPage
#else
#define MAYBE_UkmIsRecordedForCrashedTabPage
#endif
IN_PROC_BROWSER_TEST_P(PageLoadMetricsBrowserTestCrashedPage,
                       MAYBE_UkmIsRecordedForCrashedTabPage) {}

INSTANTIATE_TEST_SUITE_P();

// Test is flaky. https://crbug.com/1260953
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX) || \
    BUILDFLAG(IS_WIN)
#define MAYBE_PageLCPAnimatedImage
#else
#define MAYBE_PageLCPAnimatedImage
#endif
// Tests that an animated image's reported LCP values are smaller than its load
// times, when the feature flag for animated image reporting is enabled.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestAnimatedLCP,
                       MAYBE_PageLCPAnimatedImage) {}

// Tests that a non-animated image's reported LCP values are larger than its
// load times, when the feature flag for animated image reporting is enabled.
// TODO(crbug.com/40218474): Flaky on Mac/Linux/Lacros.
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_PageLCPNonAnimatedImage
#else
#define MAYBE_PageLCPNonAnimatedImage
#endif
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestAnimatedLCP,
                       MAYBE_PageLCPNonAnimatedImage) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, FirstInputDelayFromClick) {}

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SameOriginNavigation) {}

// TODO(crbug.com/334416161): Re-enable this test on Windows.
#if BUILDFLAG(IS_WIN)
#define MAYBE_CrossOriginNavigation
#else
#define MAYBE_CrossOriginNavigation
#endif
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
                       MAYBE_CrossOriginNavigation) {}

class PageLoadMetricsBrowserTestWithFencedFrames
    : public PageLoadMetricsBrowserTest {};

// TODO(crbug.com/334416161): Re-enable this test on Windows.
#if BUILDFLAG(IS_WIN)
#define MAYBE_PageLoadPrivacySandboxAdsFencedFramesMetrics
#else
#define MAYBE_PageLoadPrivacySandboxAdsFencedFramesMetrics
#endif
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestWithFencedFrames,
                       MAYBE_PageLoadPrivacySandboxAdsFencedFramesMetrics) {}

class PageLoadMetricsBrowserTestWithBackForwardCache
    : public PageLoadMetricsBrowserTest {};

IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestWithBackForwardCache,
                       BackForwardCacheEvent) {}

// Test UseCounter UKM features observed when a page is in the BFCache and is
// evicted from it.
IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestWithBackForwardCache,
                       UseCounterUkmFeaturesLoggedOnBFCacheEviction) {}

class NavigationPageLoadMetricsBrowserTest
    : public PageLoadMetricsBrowserTest,
      public ::testing::WithParamInterface<std::string> {};

IN_PROC_BROWSER_TEST_P(NavigationPageLoadMetricsBrowserTest, FirstInputDelay) {}

std::vector<std::string> NavigationPageLoadMetricsBrowserTestTestValues() {}

INSTANTIATE_TEST_SUITE_P();

class PrerenderPageLoadMetricsBrowserTest : public PageLoadMetricsBrowserTest {};

IN_PROC_BROWSER_TEST_F(PrerenderPageLoadMetricsBrowserTest, PrerenderEvent) {}

IN_PROC_BROWSER_TEST_F(PrerenderPageLoadMetricsBrowserTest,
                       PrerenderingDoNotRecordUKM) {}

enum BackForwardCacheStatus {};

class PageLoadMetricsBackForwardCacheBrowserTest
    : public PageLoadMetricsBrowserTest,
      public testing::WithParamInterface<BackForwardCacheStatus> {};

// Verifies the page end reasons are as we expect. This means that the first
// page end reason is always recorded in Navigation.PageEndReason3, and
// subsequent reasons are recorded in HistoryNavigation.PageEndReason if bfcache
// is enabled, or Navigation.PageEndReason3 if not.
void PageLoadMetricsBackForwardCacheBrowserTest::VerifyPageEndReasons(
    const std::vector<PageEndReason>& reasons,
    const GURL& url,
    bool is_bfcache_enabled) {}

int64_t PageLoadMetricsBackForwardCacheBrowserTest::CountForMetricForURL(
    std::string_view entry_name,
    std::string_view metric_name,
    const GURL& url) {}

IN_PROC_BROWSER_TEST_P(PageLoadMetricsBackForwardCacheBrowserTest,
                       LogsPageEndReasons) {}

void PageLoadMetricsBackForwardCacheBrowserTest::ExpectNewForegroundDuration(
    const GURL& url,
    bool expect_bfcache) {}

IN_PROC_BROWSER_TEST_P(PageLoadMetricsBackForwardCacheBrowserTest,
                       LogsBasicPageForegroundDuration) {}

IN_PROC_BROWSER_TEST_P(PageLoadMetricsBackForwardCacheBrowserTest,
                       LogsPageForegroundDurationOnHide) {}

INSTANTIATE_TEST_SUITE_P();