#include "base/strings/strcat.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_view_host.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/extensions/extension_action_test_helper.h"
#include "chrome/browser/ui/views/extensions/extension_popup.h"
#include "chrome/browser/ui/views/extensions/security_dialog_tracker.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/permissions/permission_request_manager_test_api.h"
#include "components/constrained_window/constrained_window_views.h"
#include "components/javascript_dialogs/app_modal_dialog_controller.h"
#include "components/javascript_dialogs/app_modal_dialog_queue.h"
#include "components/permissions/request_type.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/test/browser_test.h"
#include "extensions/browser/disable_reason.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_host_test_helper.h"
#include "extensions/common/mojom/view_type.mojom.h"
#include "extensions/test/test_extension_dir.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/events/base_event_utils.h"
#include "ui/views/test/button_test_api.h"
#include "ui/views/test/widget_activation_waiter.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/widget/unique_widget_ptr.h"
#include "ui/views/window/dialog_delegate.h"
ExtensionPopupInteractiveUiTest;
namespace {
class DevToolsAttachWaiter : public content::DevToolsAgentHostObserver { … };
views::UniqueWidgetPtr CreateTestTopLevelWidget() { … }
views::UniqueWidgetPtr CreateTestDialogWidget(views::Widget* parent) { … }
void ExpectWidgetDestroy(base::WeakPtr<views::Widget> widget) { … }
base::WeakPtr<views::Widget> WaitForLastExtensionPopupVisible() { … }
base::WeakPtr<views::Widget> OpenExtensionPopup(
Browser* browser,
const extensions::Extension* extension) { … }
}
IN_PROC_BROWSER_TEST_F(ExtensionPopupInteractiveUiTest,
UnloadExtensionWhileInspectingPopup) { … }
IN_PROC_BROWSER_TEST_F(ExtensionPopupInteractiveUiTest,
ExtensionPopupOverPermissions) { … }
IN_PROC_BROWSER_TEST_F(ExtensionPopupInteractiveUiTest,
ExtensionPopupDoesNotCloseWhileInpsecting) { … }
IN_PROC_BROWSER_TEST_F(ExtensionPopupInteractiveUiTest,
ExtensionPopupDoesNotCloseWhileShowingJSAlert) { … }
IN_PROC_BROWSER_TEST_F(ExtensionPopupInteractiveUiTest,
ExtensionPopupClosesOnShowingWebDialog) { … }
IN_PROC_BROWSER_TEST_F(ExtensionPopupInteractiveUiTest,
ExtensionPopupClosesOnActivatingBrowserWindow) { … }
#if BUILDFLAG(IS_MAC)
IN_PROC_BROWSER_TEST_F(
ExtensionPopupInteractiveUiTest,
ExtensionPopupClosesOnActivatingBrowserWindowMacFullscreen) {
static constexpr char kManifest[] =
R"({
"name": "Test Extension",
"manifest_version": 3,
"action": { "default_popup": "popup.html" },
"version": "0.1"
})";
extensions::TestExtensionDir test_dir;
test_dir.WriteManifest(kManifest);
test_dir.WriteFile(FILE_PATH_LITERAL("popup.html"),
"<html>Hello, world!</html>");
const extensions::Extension* extension =
LoadExtension(test_dir.UnpackedPath());
ASSERT_TRUE(extension);
ui_test_utils::ToggleFullscreenModeAndWait(browser());
base::WeakPtr<views::Widget> extension_popup_widget =
OpenExtensionPopup(browser(), extension);
browser()->window()->Activate();
ExpectWidgetDestroy(extension_popup_widget);
}
#endif
IN_PROC_BROWSER_TEST_F(
ExtensionPopupInteractiveUiTest,
ExtensionPopupDoesNotClosesOnActivatingOtherTopLevelWindow) { … }
IN_PROC_BROWSER_TEST_F(ExtensionPopupInteractiveUiTest,
APITriggeredPopupIsBlockedBySecurityDialog) { … }
IN_PROC_BROWSER_TEST_F(ExtensionPopupInteractiveUiTest,
UserTriggeredPopupIsBlockedBySecurityUI) { … }