chromium/chrome/browser/page_load_metrics/observers/third_party_metrics_observer_browsertest.cc

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

#include "base/test/metrics/histogram_tester.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "components/page_load_metrics/browser/observers/third_party_metrics_observer.h"
#include "components/page_load_metrics/browser/page_load_metrics_test_waiter.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

const char kReadCookieHistogram[] =;
const char kSubframeFCPHistogram[] =;
const char kOpaqueSubframeFCPHistogram[] =;
const char kOpaqueSubframeLCPHistogram[] =;

void InvokeStorageAccessOnFrame(content::RenderFrameHost* frame,
                                blink::mojom::WebFeature storage_feature) {}

blink::mojom::WebFeature MetricForTestCase(blink::mojom::WebFeature test_case) {}

class ThirdPartyMetricsObserverBrowserTest : public InProcessBrowserTest {};

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       OneFirstPartyFrame_NoTimingRecorded) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       OneThirdPartyFrame_OneTimingRecorded) {}

// TODO(crbug.com/334416161): Re-enble this test.
#if BUILDFLAG(IS_WIN)
#define MAYBE_ThreeThirdPartyFrames_ThreeTimingsRecorded
#else
#define MAYBE_ThreeThirdPartyFrames_ThreeTimingsRecorded
#endif
IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       MAYBE_ThreeThirdPartyFrames_ThreeTimingsRecorded) {}

// TODO(crbug.com/334416161): Re-enble this test.
#if BUILDFLAG(IS_WIN)
#define MAYBE_OpaqueOriginSubframe
#else
#define MAYBE_OpaqueOriginSubframe
#endif
IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       MAYBE_OpaqueOriginSubframe) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest, NoStorageEvent) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       FirstPartyCookiesReadAndWrite) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       ThirdPartyCookiesReadAndWrite) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       ThirdPartyCookiesIPAddress) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       MultipleThirdPartyCookiesReadAndWrite) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       FirstPartyDocCookieReadAndWrite) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       ThirdPartyDocCookieReadAndWrite) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       ThirdPartyDocCookieReadNoWrite) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       ThirdPartyDocCookieWriteNoRead) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       FirstPartyStorageAccess_UseCounterNotRecorded) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       ThirdPartyStorageAccess_UseCounterRecorded) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       ThirdPartyFrameWithActivationReported) {}

IN_PROC_BROWSER_TEST_F(ThirdPartyMetricsObserverBrowserTest,
                       FirstPartyFrameWithActivationNotReported) {}

IN_PROC_BROWSER_TEST_F(
    ThirdPartyMetricsObserverBrowserTest,
    ThirdPartyFrameWithAccessAndActivationOnDifferentThirdParties) {}

IN_PROC_BROWSER_TEST_F(
    ThirdPartyMetricsObserverBrowserTest,
    ThirdPartyFrameWithAccessAndActivationOnSameThirdParties) {}

}  // namespace