#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include <array>
#include <memory>
#include <string>
#include "base/files/scoped_temp_dir.h"
#include "base/format_macros.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/strings/pattern.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/test_future.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/devtools/devtools_window_testing.h"
#include "chrome/browser/extensions/api/tab_groups/tab_groups_util.h"
#include "chrome/browser/extensions/api/tabs/tabs_api.h"
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/extensions/browser_extension_window_controller.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit_source.h"
#include "chrome/browser/resource_coordinator/tab_manager.h"
#include "chrome/browser/resource_coordinator/time.h"
#include "chrome/browser/resource_coordinator/utils.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.h"
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_trust_checker.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.h"
#include "chrome/browser/web_applications/isolated_web_apps/test/isolated_web_app_builder.h"
#include "chrome/browser/web_applications/isolated_web_apps/test/test_signed_web_bundle_builder.h"
#include "chrome/browser/web_applications/test/web_app_install_test_utils.h"
#include "chrome/browser/web_applications/web_app_command_scheduler.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_provider_factory.h"
#include "chrome/common/chrome_switches.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/policy/core/common/policy_pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_features.h"
#include "content/public/common/url_constants.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_test_utils.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/mojom/context_type.mojom.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "pdf/buildflags.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/page/page_zoom.h"
#include "ui/base/ozone_buildflags.h"
#include "ui/base/window_open_disposition.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/widget/widget_interactive_uitest_utils.h"
#if BUILDFLAG(IS_MAC)
#include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
#endif
#if BUILDFLAG(ENABLE_PDF)
#include "base/test/with_feature_override.h"
#include "chrome/browser/pdf/pdf_extension_test_base.h"
#include "chrome/browser/pdf/pdf_extension_test_util.h"
#include "chrome/browser/pdf/test_pdf_viewer_stream_manager.h"
#include "pdf/pdf_features.h"
#endif
namespace extensions {
keys;
utils;
namespace {
bool HasAnyPrivacySensitiveFields(const base::Value::Dict& dict) { … }
class TestFunctionDispatcherDelegate
: public extensions::ExtensionFunctionDispatcher::Delegate { … };
class ExtensionTabsTest : public PlatformAppBrowserTest { … };
class ExtensionWindowCreateTest : public InProcessBrowserTest { … };
const int kUndefinedId = …;
const ExtensionTabUtil::ScrubTabBehavior kDontScrubBehavior = …;
int GetTabId(const base::Value::Dict& tab) { … }
int GetTabWindowId(const base::Value::Dict& tab) { … }
int GetWindowId(const base::Value::Dict& window) { … }
}
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetCurrentWindow) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindowsAllTypes) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, UpdateNoPermissions) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest,
DisallowNonIncognitoUrlInIncognitoWindow) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DefaultToIncognitoWhenItIsForced) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest,
DefaultToIncognitoWhenItIsForcedAndNoArgs) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest,
DontCreateNormalWindowWhenIncognitoForced) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest,
DontCreateIncognitoWindowWhenIncognitoDisabled) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryAllTabsWithDevTools) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryTabGroups) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DontCreateTabInClosingPopupWindow) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, InvalidUpdateWindowState) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, InvalidUpdateWindowBounds) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, UpdateDevToolsWindow) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, ExtensionAPICannotNavigateDevtools) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_AcceptState …
#else
#define MAYBE_AcceptState …
#endif
IN_PROC_BROWSER_TEST_F(ExtensionWindowCreateTest, MAYBE_AcceptState) { … }
IN_PROC_BROWSER_TEST_F(ExtensionWindowCreateTest, ValidateCreateWindowState) { … }
IN_PROC_BROWSER_TEST_F(ExtensionWindowCreateTest, ValidateCreateWindowBounds) { … }
IN_PROC_BROWSER_TEST_F(ExtensionWindowCreateTest, CreatePopupWindowFromWebUI) { … }
struct ExtensionWindowCreateIwaParam { … };
class ExtensionWindowCreateIwaTest
: public InProcessBrowserTest,
public testing::WithParamInterface<ExtensionWindowCreateIwaParam> { … };
IN_PROC_BROWSER_TEST_P(ExtensionWindowCreateIwaTest, CreateWindowForIwa) { … }
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, NoTabsEventOnDevTools) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, NoTabsAppWindow) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_FilteredEvents …
#else
#define MAYBE_FilteredEvents …
#endif
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, MAYBE_FilteredEvents) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, OnBoundsChanged) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, WindowsCreate) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, ExecuteScriptOnDevTools) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardedProperty) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardWithId) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardWithInvalidId) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardWithoutId) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, AutoDiscardableProperty) { … }
class ExtensionTabsZoomTest : public ExtensionTabsTest { … };
void ExtensionTabsZoomTest::SetUpOnMainThread() { … }
bool ExtensionTabsZoomTest::RunSetZoom(int tab_id, double zoom_factor) { … }
testing::AssertionResult ExtensionTabsZoomTest::RunGetZoom(
int tab_id,
double* zoom_factor) { … }
bool ExtensionTabsZoomTest::RunSetZoomSettings(int tab_id,
const char* mode,
const char* scope) { … }
testing::AssertionResult ExtensionTabsZoomTest::RunGetZoomSettings(
int tab_id,
std::string* mode,
std::string* scope) { … }
testing::AssertionResult ExtensionTabsZoomTest::RunGetDefaultZoom(
int tab_id,
double* default_zoom_factor) { … }
std::string ExtensionTabsZoomTest::RunSetZoomExpectError(int tab_id,
double zoom_factor) { … }
std::string ExtensionTabsZoomTest::RunSetZoomSettingsExpectError(
int tab_id,
const char* mode,
const char* scope) { … }
content::WebContents* ExtensionTabsZoomTest::OpenUrlAndWaitForLoad(
const GURL& url) { … }
namespace {
double GetZoomLevel(const content::WebContents* web_contents) { … }
content::OpenURLParams GetOpenParams(const char* url) { … }
}
IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, SetAndGetZoom) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, GetDefaultZoom) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, SetToDefaultZoom) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, ZoomSettings) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, PerTabResetsOnNavigation) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, GetZoomSettings) { … }
IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, CannotZoomInvalidTab) { … }
#if BUILDFLAG(ENABLE_PDF)
class ExtensionApiPdfTest : public base::test::WithFeatureOverride,
public PDFExtensionTestBase { … };
IN_PROC_BROWSER_TEST_P(ExtensionApiPdfTest, TemporaryAddressSpoof) { … }
INSTANTIATE_FEATURE_OVERRIDE_TEST_SUITE(…);
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowsCreate_WithOpener) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowsCreate_NoOpener) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowsCreate_OpenerAndOrigin) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabsUpdate_WebToAboutBlank) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabsUpdate_WebToAboutNewTab) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabsUpdate_WebToNonWAR) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
ExtensionAPICannotCreateWindowForDevtools) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ExtensionAPICannotMoveDevtoolsTab) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ExtensionAPICannotGroupDevtoolsTab) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ExtensionAPICannotDiscardDevtoolsTab) { … }
}