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

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

#include "chrome/browser/page_load_metrics/observers/security_state_page_load_metrics_observer.h"

#include <memory>

#include "base/feature_list.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/lookalikes/lookalike_test_helper.h"
#include "chrome/browser/lookalikes/safety_tip_web_contents_observer.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/tabs/tab_enums.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/lookalikes/core/safety_tip_test_utils.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_mock_cert_verifier.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_source.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "ui/base/window_open_disposition.h"
#include "url/gurl.h"

UkmEntry;

// A WebContentsObserver to allow waiting on a change in visible security state.
class SecurityStyleTestObserver : public content::WebContentsObserver {};

class SecurityStatePageLoadMetricsBrowserTest : public InProcessBrowserTest {};

IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest, Simple_Https) {}

IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest, Simple_Http) {}

IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest, ReloadPage) {}

// Tests that Site Engagement histograms are recorded correctly on a page with a
// Safety Tip.
IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest,
                       SafetyTipSiteEngagement) {}

// Tests that the Safety Tip page end reason histogram is recorded properly, by
// reloading the page and checking that the reload-page reason is recorded in
// the histogram.
IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest,
                       ReloadPageWithSafetyTip) {}

IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest, OtherScheme) {}

class SecurityStatePageLoadMetricsBrowserTestWithAutoupgradesDisabled
    : public SecurityStatePageLoadMetricsBrowserTest {};

IN_PROC_BROWSER_TEST_F(
    SecurityStatePageLoadMetricsBrowserTestWithAutoupgradesDisabled,
    MixedContent) {}

IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest,
                       UncommittedLoadWithError) {}

IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest,
                       HostDoesNotExist) {}

// Tests that the Safety Tip page end reason histogram is recorded properly on a
// net error page. No Safety Tip should appear on net errors.
IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest,
                       SafetyTipHostDoesNotExist) {}

IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest,
                       Navigate_Both_NonHtmlMainResource) {}

// Regression test for crbug.com/942326, where foreground duration was not being
// updated unless the tab was hidden.
IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest,
                       NonZeroForegroundTime) {}

class SecurityStatePageLoadMetricsMPArchBrowserTest
    : public SecurityStatePageLoadMetricsBrowserTest {};

class SecurityStatePageLoadMetricsPrerenderBrowserTest
    : public SecurityStatePageLoadMetricsMPArchBrowserTest {};

IN_PROC_BROWSER_TEST_F(
    SecurityStatePageLoadMetricsPrerenderBrowserTest,
    EnsurePrerenderingDoesNotRecordOnCommitSecurityLevelHistogram) {}

class SecurityStatePageLoadMetricsFencedFrameBrowserTest
    : public SecurityStatePageLoadMetricsMPArchBrowserTest {};

IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsFencedFrameBrowserTest,
                       DoNotRecordOnCommitSecurityLevelHistogram) {}