chromium/chrome/browser/no_best_effort_tasks_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 <string_view>

#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "build/buildflag.h"
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/url_constants.h"

#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/unpacked_installer.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/common/extension.h"
#endif

namespace {

class RunLoopUntilLoadedAndPainted : public content::WebContentsObserver {};

class NoBestEffortTasksTest : public InProcessBrowserTest {};

#if BUILDFLAG(ENABLE_EXTENSIONS)
constexpr std::string_view kExtensionId =;
constexpr base::TimeDelta kSendMessageRetryPeriod =;
#endif

}  // namespace

// Verify that it is possible to load and paint the initial about:blank page
// without running BEST_EFFORT tasks.
// TODO(crbug.com/40932711): Disabled due to excessive flakiness.
IN_PROC_BROWSER_TEST_F(NoBestEffortTasksTest, DISABLED_LoadAndPaintAboutBlank) {}

// Verify that it is possible to load and paint a page from the network without
// running BEST_EFFORT tasks.
//
// This test has more dependencies than LoadAndPaintAboutBlank, including
// loading cookies.
// TODO(crbug.com/40932711): Disabled due to excessive flakiness.
IN_PROC_BROWSER_TEST_F(NoBestEffortTasksTest,
                       DISABLED_LoadAndPaintFromNetwork) {}

// Verify that it is possible to load and paint a file:// URL without running
// BEST_EFFORT tasks. Regression test for https://crbug.com/973244.
// TODO(crbug.com/40932711): Disabled due to excessive flakiness.
IN_PROC_BROWSER_TEST_F(NoBestEffortTasksTest, DISABLED_LoadAndPaintFileScheme) {}

// Verify that an extension can be loaded and perform basic messaging without
// running BEST_EFFORT tasks. Regression test for http://crbug.com/177163#c112.
//
// NOTE: If this test times out, it might help to look at how
// http://crbug.com/924416 was resolved.
#if BUILDFLAG(ENABLE_EXTENSIONS)
IN_PROC_BROWSER_TEST_F(NoBestEffortTasksTest, LoadExtensionAndSendMessages) {}
#endif  // BUILDFLAG(ENABLE_EXTENSIONS)

// Verify that Blob XMLHttpRequest finishes without running BEST_EFFORT tasks.
// Regression test for https://crbug.com/989868.
IN_PROC_BROWSER_TEST_F(NoBestEffortTasksTest, BlobXMLHttpRequest) {}

// A test specialization for verifying quota storage related operations do not
// use BEST_EFFORT tasks.
class NoBestEffortTasksTestWithQuota : public NoBestEffortTasksTest {};

// Verify that cache_storage finishes without running BEST_EFFORT tasks.
// Regression test for https://crbug.com/1006546.
IN_PROC_BROWSER_TEST_F(NoBestEffortTasksTestWithQuota, CacheStorage) {}

// Verify that quota estimate() finishes without running BEST_EFFORT tasks.
// Regression test for https://crbug.com/1006546.
IN_PROC_BROWSER_TEST_F(NoBestEffortTasksTestWithQuota, QuotaEstimate) {}