#include "components/page_load_metrics/browser/metrics_web_contents_observer.h"
#include <memory>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/process/kill.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "base/timer/mock_timer.h"
#include "components/page_load_metrics/browser/metrics_lifecycle_observer.h"
#include "components/page_load_metrics/browser/page_load_metrics_test_content_browser_client.h"
#include "components/page_load_metrics/browser/page_load_tracker.h"
#include "components/page_load_metrics/browser/test_metrics_web_contents_observer_embedder.h"
#include "components/page_load_metrics/common/page_load_metrics.mojom.h"
#include "content/public/browser/back_forward_cache.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_features.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/render_frame_host_test_support.h"
#include "content/public/test/test_renderer_host.h"
#include "net/base/net_errors.h"
#include "net/cert/cert_status_flags.h"
#include "services/network/public/mojom/fetch_api.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/utility/utility.h"
#include "third_party/blink/public/common/performance/performance_timeline_constants.h"
#include "third_party/blink/public/common/use_counter/use_counter_feature.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom.h"
#include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom.h"
#include "third_party/blink/public/mojom/use_counter/use_counter_feature.mojom-shared.h"
#include "url/url_constants.h"
NavigationSimulator;
namespace page_load_metrics {
namespace {
const char kDefaultTestUrl[] = …;
const char kDefaultTestUrlAnchor[] = …;
const char kDefaultTestUrl2[] = …;
const char kFilteredStartUrl[] = …;
const char kFilteredCommitUrl[] = …;
void PopulatePageLoadTiming(mojom::PageLoadTiming* timing) { … }
blink::mojom::ResourceLoadInfoPtr CreateResourceLoadInfo(
const GURL& url,
network::mojom::RequestDestination request_destination) { … }
}
class MetricsWebContentsObserverTest
: public content::RenderViewHostTestHarness { … };
TEST_F(MetricsWebContentsObserverTest, SuccessfulMainFrameNavigation) { … }
TEST_F(MetricsWebContentsObserverTest,
DISABLED_MainFrameNavigationInternalAbort) { … }
TEST_F(MetricsWebContentsObserverTest, SubFrame) { … }
TEST_F(MetricsWebContentsObserverTest, SameDocumentNoTrigger) { … }
TEST_F(MetricsWebContentsObserverTest, DontLogNewTabPage) { … }
TEST_F(MetricsWebContentsObserverTest, DontLogIrrelevantNavigation) { … }
TEST_F(MetricsWebContentsObserverTest, EmptyTimingError) { … }
TEST_F(MetricsWebContentsObserverTest, NullNavigationStartError) { … }
TEST_F(MetricsWebContentsObserverTest, TimingOrderError) { … }
TEST_F(MetricsWebContentsObserverTest, BadIPC) { … }
TEST_F(MetricsWebContentsObserverTest, ObservePartialNavigation) { … }
TEST_F(MetricsWebContentsObserverTest, StopObservingOnCommit) { … }
TEST_F(MetricsWebContentsObserverTest, StopObservingOnStart) { … }
TEST_F(MetricsWebContentsObserverTest, OutOfOrderCrossFrameTiming) { … }
TEST_F(MetricsWebContentsObserverTest, OutOfOrderCrossFrameTiming2) { … }
TEST_F(MetricsWebContentsObserverTest, FlushBufferOnAppBackground) { … }
TEST_F(MetricsWebContentsObserverTest,
FirstInputDelayMissingFirstInputTimestamp) { … }
TEST_F(MetricsWebContentsObserverTest,
FirstInputTimestampMissingFirstInputDelay) { … }
TEST_F(MetricsWebContentsObserverTest,
FirstInputDelayAndTimingSubframeFirstDeliveredSecond) { … }
TEST_F(MetricsWebContentsObserverTest,
FirstInputDelayAndTimingMainframeFirstDeliveredSecond) { … }
TEST_F(MetricsWebContentsObserverTest, DispatchDelayedMetricsOnPageClose) { … }
TEST_F(MetricsWebContentsObserverTest, DispatchCpuMetricsImmediately) { … }
TEST_F(MetricsWebContentsObserverTest, OnLoadedResource_MainFrame) { … }
TEST_F(MetricsWebContentsObserverTest, OnLoadedResource_Subresource) { … }
TEST_F(MetricsWebContentsObserverTest,
OnLoadedResource_ResourceFromOtherRFHIgnored) { … }
TEST_F(MetricsWebContentsObserverTest,
OnLoadedResource_IgnoreNonHttpOrHttpsScheme) { … }
TEST_F(MetricsWebContentsObserverTest, RecordFeatureUsage) { … }
TEST_F(MetricsWebContentsObserverTest, RecordFeatureUsageNoObserver) { … }
TEST_F(MetricsWebContentsObserverTest, CustomUserTiming) { … }
class MetricsWebContentsObserverBackForwardCacheTest
: public MetricsWebContentsObserverTest,
public content::WebContentsDelegate { … };
TEST_F(MetricsWebContentsObserverBackForwardCacheTest,
RecordFeatureUsageWithBackForwardCache) { … }
TEST_F(MetricsWebContentsObserverBackForwardCacheTest, EnterBackForwardCache) { … }
class MetricsWebContentsObserverBackForwardCacheDisabledTest
: public MetricsWebContentsObserverTest { … };
TEST_F(MetricsWebContentsObserverBackForwardCacheDisabledTest,
EnterBackForwardCacheNotCalled) { … }
class MetricsWebContentsObserverNonPrimaryPageTest
: public MetricsWebContentsObserverBackForwardCacheTest { … };
TEST_F(MetricsWebContentsObserverNonPrimaryPageTest, MemoryUpdates) { … }
}