chromium/chrome/browser/navigation_predictor/anchor_element_preloader_browsertest.cc

// Copyright 2022 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/metrics/field_trial_params.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 "base/test/task_environment.h"
#include "chrome/browser/navigation_predictor/anchor_element_preloader.h"
#include "chrome/browser/predictors/loading_predictor.h"
#include "chrome/browser/predictors/loading_predictor_factory.h"
#include "chrome/browser/predictors/preconnect_manager.h"
#include "chrome/browser/preloading/chrome_preloading.h"
#include "chrome/browser/preloading/preloading_prefs.h"
#include "chrome/browser/subresource_filter/subresource_filter_browser_test_harness.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/ukm/test_ukm_recorder.h"
#include "content/public/browser/preloading.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/preloading_test_util.h"
#include "net/base/features.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 "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/input/web_mouse_event.h"
#include "ui/gfx/geometry/point_conversions.h"

namespace {

UkmEntry;
Preloading_Attempt;

class AnchorElementPreloaderBrowserTest
    : public subresource_filter::SubresourceFilterBrowserTest,
      public predictors::PreconnectManager::Observer {};

IN_PROC_BROWSER_TEST_F(AnchorElementPreloaderBrowserTest, OneAnchor) {}

IN_PROC_BROWSER_TEST_F(AnchorElementPreloaderBrowserTest, OneAnchorInaccurate) {}

// TODO(crbug.com/40255727): Flaky on Win10
#if BUILDFLAG(IS_WIN)
#define MAYBE_Duplicates
#else
#define MAYBE_Duplicates
#endif
IN_PROC_BROWSER_TEST_F(AnchorElementPreloaderBrowserTest, MAYBE_Duplicates) {}

IN_PROC_BROWSER_TEST_F(AnchorElementPreloaderBrowserTest, InvalidHref) {}

// TODO(crbug.com/40835708): Re-enable this test
IN_PROC_BROWSER_TEST_F(AnchorElementPreloaderBrowserTest, DISABLED_IframeTest) {}

IN_PROC_BROWSER_TEST_F(AnchorElementPreloaderBrowserTest,
                       UserSettingDisabledTest) {}

class AnchorElementPreloaderHoldbackBrowserTest
    : public AnchorElementPreloaderBrowserTest {};

IN_PROC_BROWSER_TEST_F(AnchorElementPreloaderHoldbackBrowserTest,
                       PreconnectHoldbackTest) {}

class AnchorElementPreloaderLimitedBrowserTest
    : public AnchorElementPreloaderBrowserTest {};

// TODO(crbug.com/40878140): Re-enable this test
IN_PROC_BROWSER_TEST_F(AnchorElementPreloaderLimitedBrowserTest,
                       DISABLED_LimitExceeded) {}

class AnchorElementSetIsNavigationInDomainBrowserTest
    : public AnchorElementPreloaderBrowserTest {};

IN_PROC_BROWSER_TEST_F(AnchorElementSetIsNavigationInDomainBrowserTest,
                       TestPointerDownOnAnchor) {}

}  // namespace