#include "chrome/browser/extensions/extension_apitest.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/api/tabs/tabs_api.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.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/common/content_features.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/prerender_test_util.h"
#include "extensions/test/result_catcher.h"
#include "extensions/test/test_extension_dir.h"
#include "net/dns/mock_host_resolver.h"
#if BUILDFLAG(IS_WIN)
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#endif
ContextType;
class ExtensionApiTabTest : public extensions::ExtensionApiTest { … };
class ExtensionApiTabTestWithContextType
: public ExtensionApiTabTest,
public testing::WithParamInterface<ContextType> { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
class ExtensionApiTabBackForwardCacheTest
: public ExtensionApiTabTestWithContextType { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
class ExtensionApiNewTabTest : public ExtensionApiTabTestWithContextType { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(ExtensionApiNewTabTest, Tabs) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTabTest, TabAudible) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_Muted …
#else
#define MAYBE_Muted …
#endif
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, MAYBE_Muted) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTabTest, Tabs2) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, Duplicate) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, Size) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, Update) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, Pinned) { … }
#if (BUILDFLAG(IS_LINUX) && !defined(NDEBUG)) || BUILDFLAG(IS_MAC)
#define MAYBE_Move …
#else
#define MAYBE_Move …
#endif
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, MAYBE_Move) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, Events) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, RelativeURLs) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, Query) { … }
#if !BUILDFLAG(IS_CHROMEOS_LACROS)
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, DISABLED_Highlight) { … }
#endif
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, LastAccessed) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, CrashBrowser) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, Opener) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, Remove) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, RemoveMultiple) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, GetCurrent) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, DISABLED_Connect) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, OnRemoved) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, Reload) { … }
class ExtensionApiCaptureTest
: public ExtensionApiTabTest,
public testing::WithParamInterface<ContextType> { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
#if BUILDFLAG(IS_MAC)
#define MAYBE_CaptureVisibleTabJpeg …
#else
#define MAYBE_CaptureVisibleTabJpeg …
#endif
IN_PROC_BROWSER_TEST_P(ExtensionApiCaptureTest, MAYBE_CaptureVisibleTabJpeg) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_CaptureVisibleTabPng …
#else
#define MAYBE_CaptureVisibleTabPng …
#endif
IN_PROC_BROWSER_TEST_P(ExtensionApiCaptureTest, MAYBE_CaptureVisibleTabPng) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiCaptureTest,
DISABLED_CaptureVisibleTabRace) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_CaptureVisibleFile …
#else
#define MAYBE_CaptureVisibleFile …
#endif
IN_PROC_BROWSER_TEST_P(ExtensionApiCaptureTest, MAYBE_CaptureVisibleFile) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_CaptureVisibleDisabled …
#else
#define MAYBE_CaptureVisibleDisabled …
#endif
IN_PROC_BROWSER_TEST_P(ExtensionApiCaptureTest, MAYBE_CaptureVisibleDisabled) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiCaptureTest, CaptureNullWindow) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, OnCreated) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType,
LazyBackgroundTabsOnCreated) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, OnUpdated) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabBackForwardCacheTest, OnUpdated) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, NoPermissions) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType,
DISABLED_HostPermission) { … }
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || \
BUILDFLAG(IS_CHROMEOS)
#define MAYBE_UpdateWindowResize …
#else
#define MAYBE_UpdateWindowResize …
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTabTest, MAYBE_UpdateWindowResize) { … }
#if BUILDFLAG(IS_WIN)
IN_PROC_BROWSER_TEST_F(ExtensionApiTabTest, FocusWindowDoesNotUnmaximize) {
HWND window =
browser()->window()->GetNativeWindow()->GetHost()->GetAcceleratedWidget();
::SendMessage(window, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
ASSERT_TRUE(RunExtensionTest("window_update/focus")) << message_;
ASSERT_TRUE(::IsZoomed(window));
}
#endif
#if defined(USE_AURA) || BUILDFLAG(IS_MAC)
#define MAYBE_UpdateWindowShowState …
#else
#define MAYBE_UpdateWindowShowState …
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTabTest, MAYBE_UpdateWindowShowState) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType,
IncognitoDisabledByPref) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTabTest, GetViewsOfCreatedPopup) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTabTest, GetViewsOfCreatedWindow) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType,
OnUpdatedDiscardedState) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType, OpenerCraziness) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTabTest, SendMessage) { … }
IN_PROC_BROWSER_TEST_P(ExtensionApiTabTestWithContextType,
TabsPermissionDoesNotLeakTabInfo) { … }
struct IncognitoTestParam { … };
class IncognitoExtensionApiTabTest
: public ExtensionApiTabTest,
public testing::WithParamInterface<IncognitoTestParam> { … };
IN_PROC_BROWSER_TEST_P(IncognitoExtensionApiTabTest, Tabs) { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
class ExtensionApiTabPrerenderingTest : public ExtensionApiTabTest { … };
IN_PROC_BROWSER_TEST_F(ExtensionApiTabPrerenderingTest, DISABLED_Prerendering) { … }
IN_PROC_BROWSER_TEST_F(ExtensionApiTabPrerenderingTest,
PrerenderingIntoANewTab) { … }