#include <memory>
#include <string_view>
#include "base/json/json_reader.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/values_test_util.h"
#include "base/time/time.h"
#include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
#include "chrome/browser/devtools/devtools_window_testing.h"
#include "chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/extension_action_test_helper.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "extensions/browser/api/offscreen/offscreen_document_manager.h"
#include "extensions/browser/api/runtime/runtime_api.h"
#include "extensions/browser/api_test_utils.h"
#include "extensions/browser/background_script_executor.h"
#include "extensions/browser/blocklist_extension_prefs.h"
#include "extensions/browser/blocklist_state.h"
#include "extensions/browser/extension_api_frame_id_map.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_function.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_host_registry.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/offscreen_document_host.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/script_executor.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/common/extension_id.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
#include "extensions/test/test_extension_dir.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/url_constants.h"
namespace extensions {
ContextType;
class RuntimeApiTest : public ExtensionApiTest,
public testing::WithParamInterface<ContextType> { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(RuntimeApiTest, ChromeRuntimePrivileged) { … }
IN_PROC_BROWSER_TEST_P(RuntimeApiTest, ChromeRuntimeUnprivileged) { … }
IN_PROC_BROWSER_TEST_P(RuntimeApiTest, ChromeRuntimeUninstallURL) { … }
IN_PROC_BROWSER_TEST_P(RuntimeApiTest, GetPlatformInfo) { … }
namespace {
const char kUninstallUrl[] = …;
std::string GetActiveUrl(Browser* browser) { … }
class RuntimeAPIUpdateTest : public ExtensionApiTest { … };
}
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeOpenOptionsPage) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeOpenOptionsPageError) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeGetPlatformInfo) { … }
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
ChromeRuntimeGetPackageDirectoryEntryApp) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
ChromeRuntimeGetPackageDirectoryEntryMV2Extension) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
ChromeRuntimeGetPackageDirectoryEntryMV3Extension) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ExtensionTerminatedForRapidReloads) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeReload) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeSendMessage) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeGetBackgroundPage) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeGetBackgroundPageMV3) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, RuntimeRequestUpdateCheck) { … }
IN_PROC_BROWSER_TEST_F(RuntimeAPIUpdateTest,
TerminatedExtensionUpdateHasCorrectPreviousVersion) { … }
IN_PROC_BROWSER_TEST_P(RuntimeApiTest,
DoNotOpenUninstallUrlForBlocklistedExtensions) { … }
BackgroundPageOnlyRuntimeApiTest;
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(BackgroundPageOnlyRuntimeApiTest,
GetViewsOfWindowOpenedFromBackgroundPage) { … }
class RuntimeGetContextsApiTest : public ExtensionApiTest { … };
#if BUILDFLAG(IS_MAC)
#define MAYBE_GetServiceWorkerContext …
#else
#define MAYBE_GetServiceWorkerContext …
#endif
IN_PROC_BROWSER_TEST_F(RuntimeGetContextsApiTest,
MAYBE_GetServiceWorkerContext) { … }
IN_PROC_BROWSER_TEST_F(RuntimeGetContextsApiTest, FilterMatching) { … }
IN_PROC_BROWSER_TEST_F(RuntimeGetContextsApiTest, GetTabContext) { … }
IN_PROC_BROWSER_TEST_F(RuntimeGetContextsApiTest, GetOffscreenDocumentContext) { … }
IN_PROC_BROWSER_TEST_F(RuntimeGetContextsApiTest, GetSidePanelContext) { … }
IN_PROC_BROWSER_TEST_F(RuntimeGetContextsApiTest,
RetrievingIncognitoContexts_SplitMode) { … }
IN_PROC_BROWSER_TEST_F(RuntimeGetContextsApiTest,
RetrievingIncognitoContexts_SpanningMode) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, GetExtensionURL) { … }
class GetContextsWithDeveloperToolsOpened
: public RuntimeGetContextsApiTest,
public testing::WithParamInterface<bool> { … };
#if defined(MEMORY_SANITIZER) && (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS))
#define MAYBE_ReturnsDevToolsContext …
#else
#define MAYBE_ReturnsDevToolsContext …
#endif
IN_PROC_BROWSER_TEST_P(GetContextsWithDeveloperToolsOpened,
MAYBE_ReturnsDevToolsContext) { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
}