0

[Extensions] Convert (most of) apps test message listener uses

Update most uses of ExtensionTestMessageListener in //apps and
//chrome/browser/apps to the new constructors with an enum for
ReplyBehavior. Omit the behavior when it's unnecessary (when the
caller does not want to send a custom reply).

This CL should have no behavior change.

Bug: 1324791
Change-Id: I0cb8e2c6b02ee2f1c8eaeb674d4bea5e2c530066
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3662182
Commit-Queue: Trent Apted <tapted@chromium.org>
Auto-Submit: Devlin Cronin <rdevlin.cronin@chromium.org>
Reviewed-by: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1006693}
This commit is contained in:
Devlin Cronin
2022-05-24 01:00:55 +00:00
committed by Chromium LUCI CQ
parent c6af7dbd9c
commit 9f73eb37d4
19 changed files with 164 additions and 162 deletions

@ -51,7 +51,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) {
// Pretend that the app is supposed to be running. // Pretend that the app is supposed to be running.
extension_prefs->SetExtensionRunning(extension->id(), true); extension_prefs->SetExtensionRunning(extension->id(), true);
ExtensionTestMessageListener restart_listener("onRestarted", false); ExtensionTestMessageListener restart_listener("onRestarted");
apps::AppRestoreServiceFactory::GetForBrowserContext(browser()->profile()) apps::AppRestoreServiceFactory::GetForBrowserContext(browser()->profile())
->HandleStartup(true); ->HandleStartup(true);
EXPECT_TRUE(restart_listener.WaitUntilSatisfied()); EXPECT_TRUE(restart_listener.WaitUntilSatisfied());
@ -60,7 +60,8 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) {
// Tests that apps are recorded in the preferences as active when and only when // Tests that apps are recorded in the preferences as active when and only when
// they have visible windows. // they have visible windows.
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ActiveAppsAreRecorded) { IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ActiveAppsAreRecorded) {
ExtensionTestMessageListener ready_listener("ready", true); ExtensionTestMessageListener ready_listener("ready",
ReplyBehavior::kWillReply);
const Extension* extension = const Extension* extension =
LoadExtension(test_data_dir_.AppendASCII("platform_apps/active_test")); LoadExtension(test_data_dir_.AppendASCII("platform_apps/active_test"));
ASSERT_TRUE(extension); ASSERT_TRUE(extension);
@ -163,8 +164,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_FileAccessIsRestored) {
"temp", temp_directory.GetPath()); "temp", temp_directory.GetPath());
extensions::ExtensionHostTestHelper host_helper(profile()); extensions::ExtensionHostTestHelper host_helper(profile());
ExtensionTestMessageListener access_ok_listener( ExtensionTestMessageListener access_ok_listener("restartedFileAccessOK");
"restartedFileAccessOK", false);
const Extension* extension = const Extension* extension =
LoadAndLaunchPlatformApp("file_access_restored_test", "fileWritten"); LoadAndLaunchPlatformApp("file_access_restored_test", "fileWritten");
ASSERT_TRUE(extension); ASSERT_TRUE(extension);

@ -59,7 +59,7 @@ const char* kSwitchesToCopy[] = {
// Case where Chrome is already running. // Case where Chrome is already running.
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
MAYBE_LoadAndLaunchAppChromeRunning) { MAYBE_LoadAndLaunchAppChromeRunning) {
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess(); const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess();
base::CommandLine new_cmdline(cmdline.GetProgram()); base::CommandLine new_cmdline(cmdline.GetProgram());
@ -95,7 +95,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
MAYBE_LoadAndLaunchAppWithFile) { MAYBE_LoadAndLaunchAppWithFile) {
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess(); const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess();
base::CommandLine new_cmdline(cmdline.GetProgram()); base::CommandLine new_cmdline(cmdline.GetProgram());
@ -149,7 +149,7 @@ class LoadAndLaunchPlatformAppBrowserTest : public PlatformAppBrowserTest {
} }
void LoadAndLaunchApp() { void LoadAndLaunchApp() {
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
// Start an actual browser because we can't shut down with just an app // Start an actual browser because we can't shut down with just an app

@ -166,7 +166,8 @@ class AppNotificationsExtensionApiTest : public extensions::ExtensionApiTest {
const extensions::Extension* extension = LoadExtension(extdir); const extensions::Extension* extension = LoadExtension(extdir);
EXPECT_TRUE(extension); EXPECT_TRUE(extension);
ExtensionTestMessageListener launched_listener("launched", true); ExtensionTestMessageListener launched_listener("launched",
ReplyBehavior::kWillReply);
apps::AppServiceProxyFactory::GetForProfile(profile())->Launch( apps::AppServiceProxyFactory::GetForProfile(profile())->Launch(
extension->id(), ui::EF_SHIFT_DOWN, extension->id(), ui::EF_SHIFT_DOWN,
apps::mojom::LaunchSource::kFromTest); apps::mojom::LaunchSource::kFromTest);
@ -207,7 +208,7 @@ IN_PROC_BROWSER_TEST_F(AppNotificationsExtensionApiTest,
ASSERT_FALSE(HasBadge(profile(), extension1->id()).value()); ASSERT_FALSE(HasBadge(profile(), extension1->id()).value());
// Load the basic app to generate a notification. // Load the basic app to generate a notification.
ExtensionTestMessageListener notification_created_listener("created", false); ExtensionTestMessageListener notification_created_listener("created");
const Extension* extension2 = const Extension* extension2 =
LoadAppWithWindowState("notifications/api/basic_app"); LoadAppWithWindowState("notifications/api/basic_app");
ASSERT_TRUE(extension2); ASSERT_TRUE(extension2);
@ -234,7 +235,7 @@ IN_PROC_BROWSER_TEST_F(AppNotificationsExtensionApiTest,
ASSERT_FALSE(HasBadge(profile(), extension1->id()).value()); ASSERT_FALSE(HasBadge(profile(), extension1->id()).value());
// Load the basic app to generate a notification. // Load the basic app to generate a notification.
ExtensionTestMessageListener notification_created_listener1("created", false); ExtensionTestMessageListener notification_created_listener1("created");
const Extension* extension2 = const Extension* extension2 =
LoadAppWithWindowState("notifications/api/basic_app"); LoadAppWithWindowState("notifications/api/basic_app");
ASSERT_TRUE(extension2); ASSERT_TRUE(extension2);
@ -249,7 +250,7 @@ IN_PROC_BROWSER_TEST_F(AppNotificationsExtensionApiTest,
ASSERT_FALSE(HasBadge(profile(), extension1->id()).value()); ASSERT_FALSE(HasBadge(profile(), extension1->id()).value());
// Re-load the basic app to generate a notification again. // Re-load the basic app to generate a notification again.
ExtensionTestMessageListener notification_created_listener2("created", false); ExtensionTestMessageListener notification_created_listener2("created");
const Extension* extension3 = const Extension* extension3 =
LoadAppWithWindowState("notifications/api/basic_app"); LoadAppWithWindowState("notifications/api/basic_app");
ASSERT_TRUE(extension3); ASSERT_TRUE(extension3);

@ -76,7 +76,7 @@ class AppViewTest : public extensions::PlatformAppBrowserTest {
return; return;
} }
ExtensionTestMessageListener done_listener("TEST_PASSED", false); ExtensionTestMessageListener done_listener("TEST_PASSED");
done_listener.set_failure_message("TEST_FAILED"); done_listener.set_failure_message("TEST_FAILED");
if (!content::ExecuteScript( if (!content::ExecuteScript(
embedder_web_contents, embedder_web_contents,
@ -227,7 +227,7 @@ IN_PROC_BROWSER_TEST_F(AppViewTest,
base::StringPrintf("onAppCommand('%s', '%s');", "EMBED", base::StringPrintf("onAppCommand('%s', '%s');", "EMBED",
guest_app->id().c_str()))); guest_app->id().c_str())));
ExtensionTestMessageListener on_embed_requested_listener( ExtensionTestMessageListener on_embed_requested_listener(
"AppViewTest.EmbedRequested", false); "AppViewTest.EmbedRequested");
EXPECT_TRUE(on_embed_requested_listener.WaitUntilSatisfied()); EXPECT_TRUE(on_embed_requested_listener.WaitUntilSatisfied());
// While the host is waiting for the guest to accept/deny embedding, the bad // While the host is waiting for the guest to accept/deny embedding, the bad
// app sends a request to the host. // app sends a request to the host.

@ -706,7 +706,7 @@ class WebViewTestBase : public extensions::PlatformAppBrowserTest {
return; return;
} }
ExtensionTestMessageListener done_listener("TEST_PASSED", false); ExtensionTestMessageListener done_listener("TEST_PASSED");
done_listener.set_failure_message("TEST_FAILED"); done_listener.set_failure_message("TEST_FAILED");
// Note that domAutomationController may not exist for some tests so we // Note that domAutomationController may not exist for some tests so we
// must use the async version of ExecuteScript. // must use the async version of ExecuteScript.
@ -765,13 +765,13 @@ class WebViewTestBase : public extensions::PlatformAppBrowserTest {
// Create the guest. // Create the guest.
content::WebContents* embedder_web_contents = content::WebContents* embedder_web_contents =
GetFirstAppWindowWebContents(); GetFirstAppWindowWebContents();
ExtensionTestMessageListener guest_added("GuestAddedToDom", false); ExtensionTestMessageListener guest_added("GuestAddedToDom");
EXPECT_TRUE(content::ExecuteScript(embedder_web_contents, EXPECT_TRUE(content::ExecuteScript(embedder_web_contents,
base::StringPrintf("createGuest();\n"))); base::StringPrintf("createGuest();\n")));
ASSERT_TRUE(guest_added.WaitUntilSatisfied()); ASSERT_TRUE(guest_added.WaitUntilSatisfied());
// Now load the guest. // Now load the guest.
ExtensionTestMessageListener guest_loaded("GuestLoaded", false); ExtensionTestMessageListener guest_loaded("GuestLoaded");
EXPECT_TRUE(content::ExecuteScript( EXPECT_TRUE(content::ExecuteScript(
embedder_web_contents, embedder_web_contents,
base::StringPrintf("loadGuest(%d);\n", host_and_port.port()))); base::StringPrintf("loadGuest(%d);\n", host_and_port.port())));
@ -803,7 +803,7 @@ class WebViewTestBase : public extensions::PlatformAppBrowserTest {
GetFirstAppWindowWebContents(); GetFirstAppWindowWebContents();
ASSERT_TRUE(embedder_web_contents); ASSERT_TRUE(embedder_web_contents);
ExtensionTestMessageListener test_run_listener("PASSED", false); ExtensionTestMessageListener test_run_listener("PASSED");
test_run_listener.set_failure_message("FAILED"); test_run_listener.set_failure_message("FAILED");
EXPECT_TRUE( EXPECT_TRUE(
content::ExecuteScript( content::ExecuteScript(
@ -814,8 +814,7 @@ class WebViewTestBase : public extensions::PlatformAppBrowserTest {
// Loads an app with a <webview> in it, returns once a guest is created. // Loads an app with a <webview> in it, returns once a guest is created.
void LoadAppWithGuest(const std::string& app_path) { void LoadAppWithGuest(const std::string& app_path) {
ExtensionTestMessageListener launched_listener("WebViewTest.LAUNCHED", ExtensionTestMessageListener launched_listener("WebViewTest.LAUNCHED");
false);
launched_listener.set_failure_message("WebViewTest.FAILURE"); launched_listener.set_failure_message("WebViewTest.FAILURE");
LoadAndLaunchPlatformApp(app_path.c_str(), &launched_listener); LoadAndLaunchPlatformApp(app_path.c_str(), &launched_listener);
@ -833,8 +832,7 @@ class WebViewTestBase : public extensions::PlatformAppBrowserTest {
const std::string& wait_message) { const std::string& wait_message) {
std::unique_ptr<ExtensionTestMessageListener> listener; std::unique_ptr<ExtensionTestMessageListener> listener;
if (!wait_message.empty()) { if (!wait_message.empty()) {
listener = listener = std::make_unique<ExtensionTestMessageListener>(wait_message);
std::make_unique<ExtensionTestMessageListener>(wait_message, false);
} }
EXPECT_TRUE( EXPECT_TRUE(
@ -1172,7 +1170,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, SpatialNavigationJavascriptAPI) {
base::CommandLine::ForCurrentProcess()->AppendSwitch( base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableSpatialNavigation); switches::kEnableSpatialNavigation);
ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED");
next_step_listener.set_failure_message("TEST_STEP_FAILED"); next_step_listener.set_failure_message("TEST_STEP_FAILED");
LoadAndLaunchPlatformApp("web_view/spatial_navigation_state_api", LoadAndLaunchPlatformApp("web_view/spatial_navigation_state_api",
@ -1256,8 +1254,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, ReloadEmbedder) {
// platform_app for this test. // platform_app for this test.
LoadAppWithGuest("web_view/visibility_changed"); LoadAppWithGuest("web_view/visibility_changed");
ExtensionTestMessageListener launched_again_listener("WebViewTest.LAUNCHED", ExtensionTestMessageListener launched_again_listener("WebViewTest.LAUNCHED");
false);
GetEmbedderWebContents()->GetController().Reload(content::ReloadType::NORMAL, GetEmbedderWebContents()->GetController().Reload(content::ReloadType::NORMAL,
false); false);
ASSERT_TRUE(launched_again_listener.WaitUntilSatisfied()); ASSERT_TRUE(launched_again_listener.WaitUntilSatisfied());
@ -1289,8 +1286,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, DisplayNoneSetSrc) {
// Now attempt to navigate the guest again. // Now attempt to navigate the guest again.
SendMessageToEmbedder("navigate-guest"); SendMessageToEmbedder("navigate-guest");
ExtensionTestMessageListener test_passed_listener("WebViewTest.PASSED", ExtensionTestMessageListener test_passed_listener("WebViewTest.PASSED");
false);
// Making the guest visible would trigger loadstop. // Making the guest visible would trigger loadstop.
SendMessageToEmbedder("show-guest"); SendMessageToEmbedder("show-guest");
EXPECT_TRUE(test_passed_listener.WaitUntilSatisfied()); EXPECT_TRUE(test_passed_listener.WaitUntilSatisfied());
@ -1735,7 +1731,7 @@ IN_PROC_BROWSER_TEST_P(WebViewNewWindowTest,
// Run the test and wait until the guest WebContents is available and has // Run the test and wait until the guest WebContents is available and has
// finished loading. // finished loading.
ExtensionTestMessageListener done_listener("TEST_PASSED", false); ExtensionTestMessageListener done_listener("TEST_PASSED");
done_listener.set_failure_message("TEST_FAILED"); done_listener.set_failure_message("TEST_FAILED");
EXPECT_TRUE(content::ExecuteScript( EXPECT_TRUE(content::ExecuteScript(
embedder_web_contents, "runTest('testWebViewAndEmbedderInNewWindow')")); embedder_web_contents, "runTest('testWebViewAndEmbedderInNewWindow')"));
@ -1780,16 +1776,16 @@ IN_PROC_BROWSER_TEST_P(WebViewNewWindowTest,
// unique across all webviews within the app. // unique across all webviews within the app.
IN_PROC_BROWSER_TEST_P(WebViewTest, TwoIframesWebRequest) { IN_PROC_BROWSER_TEST_P(WebViewTest, TwoIframesWebRequest) {
ASSERT_TRUE(StartEmbeddedTestServer()); // For serving webview pages. ASSERT_TRUE(StartEmbeddedTestServer()); // For serving webview pages.
ExtensionTestMessageListener ready1("ready1", true); ExtensionTestMessageListener ready1("ready1", ReplyBehavior::kWillReply);
ExtensionTestMessageListener ready2("ready2", true); ExtensionTestMessageListener ready2("ready2", ReplyBehavior::kWillReply);
LoadAndLaunchPlatformApp("web_view/two_iframes_web_request", "Launched"); LoadAndLaunchPlatformApp("web_view/two_iframes_web_request", "Launched");
EXPECT_TRUE(ready1.WaitUntilSatisfied()); EXPECT_TRUE(ready1.WaitUntilSatisfied());
EXPECT_TRUE(ready2.WaitUntilSatisfied()); EXPECT_TRUE(ready2.WaitUntilSatisfied());
ExtensionTestMessageListener finished1("success1", false); ExtensionTestMessageListener finished1("success1");
finished1.set_failure_message("fail1"); finished1.set_failure_message("fail1");
ExtensionTestMessageListener finished2("success2", false); ExtensionTestMessageListener finished2("success2");
finished2.set_failure_message("fail2"); finished2.set_failure_message("fail2");
// Reply to the listeners to start the navigations and wait for the // Reply to the listeners to start the navigations and wait for the
@ -2116,7 +2112,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestRemoveWebviewOnExit) {
// Run the test and wait until the guest WebContents is available and has // Run the test and wait until the guest WebContents is available and has
// finished loading. // finished loading.
ExtensionTestMessageListener guest_loaded_listener("guest-loaded", false); ExtensionTestMessageListener guest_loaded_listener("guest-loaded");
EXPECT_TRUE(content::ExecuteScript( EXPECT_TRUE(content::ExecuteScript(
embedder_web_contents, embedder_web_contents,
"runTest('testRemoveWebviewOnExit')")); "runTest('testRemoveWebviewOnExit')"));
@ -2340,14 +2336,14 @@ class WebViewHttpsFirstModeTest : public WebViewTest {
void LoadUrlInGuest(const GURL& guest_url) { void LoadUrlInGuest(const GURL& guest_url) {
// Create the guest. // Create the guest.
auto* embedder_web_contents = GetFirstAppWindowWebContents(); auto* embedder_web_contents = GetFirstAppWindowWebContents();
ExtensionTestMessageListener guest_added("GuestAddedToDom", false); ExtensionTestMessageListener guest_added("GuestAddedToDom");
EXPECT_TRUE(content::ExecuteScript(embedder_web_contents, EXPECT_TRUE(content::ExecuteScript(embedder_web_contents,
base::StringPrintf("createGuest();\n"))); base::StringPrintf("createGuest();\n")));
ASSERT_TRUE(guest_added.WaitUntilSatisfied()); ASSERT_TRUE(guest_added.WaitUntilSatisfied());
// Now load the guest. // Now load the guest.
content::TestNavigationObserver observer(guest_url); content::TestNavigationObserver observer(guest_url);
ExtensionTestMessageListener guest_loaded("GuestLoaded", false); ExtensionTestMessageListener guest_loaded("GuestLoaded");
std::string command = std::string command =
base::StringPrintf("loadGuestUrl('%s');\n", guest_url.spec().c_str()); base::StringPrintf("loadGuestUrl('%s');\n", guest_url.spec().c_str());
EXPECT_TRUE(content::ExecuteScript(embedder_web_contents, command)); EXPECT_TRUE(content::ExecuteScript(embedder_web_contents, command));
@ -2650,7 +2646,7 @@ void WebViewTestBase::MediaAccessAPIAllowTestHelper(
std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate()); std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
embedder_web_contents->SetDelegate(mock.get()); embedder_web_contents->SetDelegate(mock.get());
ExtensionTestMessageListener done_listener("TEST_PASSED", false); ExtensionTestMessageListener done_listener("TEST_PASSED");
done_listener.set_failure_message("TEST_FAILED"); done_listener.set_failure_message("TEST_FAILED");
EXPECT_TRUE( EXPECT_TRUE(
content::ExecuteScript( content::ExecuteScript(
@ -2667,7 +2663,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, OpenURLFromTab_CurrentTab_Abort) {
// Verify that OpenURLFromTab with a window disposition of CURRENT_TAB will // Verify that OpenURLFromTab with a window disposition of CURRENT_TAB will
// navigate the current <webview>. // navigate the current <webview>.
ExtensionTestMessageListener load_listener("WebViewTest.LOADSTOP", false); ExtensionTestMessageListener load_listener("WebViewTest.LOADSTOP");
// Navigating to a file URL is forbidden inside a <webview>. // Navigating to a file URL is forbidden inside a <webview>.
content::OpenURLParams params(GURL("file://foo"), content::Referrer(), content::OpenURLParams params(GURL("file://foo"), content::Referrer(),
@ -2691,7 +2687,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, OpenURLFromTab_CurrentTab_Succeed) {
// Verify that OpenURLFromTab with a window disposition of CURRENT_TAB will // Verify that OpenURLFromTab with a window disposition of CURRENT_TAB will
// navigate the current <webview>. // navigate the current <webview>.
ExtensionTestMessageListener load_listener("WebViewTest.LOADSTOP", false); ExtensionTestMessageListener load_listener("WebViewTest.LOADSTOP");
GURL test_url("http://www.google.com"); GURL test_url("http://www.google.com");
content::OpenURLParams params( content::OpenURLParams params(
@ -2710,8 +2706,7 @@ IN_PROC_BROWSER_TEST_P(WebViewNewWindowTest, OpenURLFromTab_NewWindow_Abort) {
// Verify that OpenURLFromTab with a window disposition of NEW_BACKGROUND_TAB // Verify that OpenURLFromTab with a window disposition of NEW_BACKGROUND_TAB
// will trigger the <webview>'s New Window API. // will trigger the <webview>'s New Window API.
ExtensionTestMessageListener new_window_listener( ExtensionTestMessageListener new_window_listener("WebViewTest.NEWWINDOW");
"WebViewTest.NEWWINDOW", false);
// Navigating to a file URL is forbidden inside a <webview>. // Navigating to a file URL is forbidden inside a <webview>.
content::OpenURLParams params(GURL("file://foo"), content::Referrer(), content::OpenURLParams params(GURL("file://foo"), content::Referrer(),
@ -2830,7 +2825,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, ContextMenusAPI_Basic) {
ExecuteScriptWaitForTitle(embedder, "createMenuItem()", "ITEM_CREATED"); ExecuteScriptWaitForTitle(embedder, "createMenuItem()", "ITEM_CREATED");
// 3. Click the created item, wait for the click handlers to fire from JS. // 3. Click the created item, wait for the click handlers to fire from JS.
ExtensionTestMessageListener click_listener("ITEM_CLICKED", false); ExtensionTestMessageListener click_listener("ITEM_CLICKED");
GURL page_url("http://www.google.com"); GURL page_url("http://www.google.com");
// Create and build our test context menu. // Create and build our test context menu.
std::unique_ptr<TestRenderViewContextMenu> menu( std::unique_ptr<TestRenderViewContextMenu> menu(
@ -2878,7 +2873,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, ContextMenusAPI_PreventDefault) {
// Add a preventDefault() call on context menu event so context menu // Add a preventDefault() call on context menu event so context menu
// does not show up. // does not show up.
ExtensionTestMessageListener prevent_default_listener( ExtensionTestMessageListener prevent_default_listener(
"WebViewTest.CONTEXT_MENU_DEFAULT_PREVENTED", false); "WebViewTest.CONTEXT_MENU_DEFAULT_PREVENTED");
EXPECT_TRUE(content::ExecuteScript(embedder, "registerPreventDefault()")); EXPECT_TRUE(content::ExecuteScript(embedder, "registerPreventDefault()"));
ContextMenuShownObserver context_menu_shown_observer; ContextMenuShownObserver context_menu_shown_observer;
@ -2948,7 +2943,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, MediaAccessAPIAllow_TestCheck) {
std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate()); std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
embedder_web_contents->SetDelegate(mock.get()); embedder_web_contents->SetDelegate(mock.get());
ExtensionTestMessageListener done_listener("TEST_PASSED", false); ExtensionTestMessageListener done_listener("TEST_PASSED");
done_listener.set_failure_message("TEST_FAILED"); done_listener.set_failure_message("TEST_FAILED");
EXPECT_TRUE( EXPECT_TRUE(
content::ExecuteScript( content::ExecuteScript(
@ -5351,8 +5346,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, TouchpadPinchSyntheticWheelEvents) {
guest_contents->GetRenderWidgetHostView()->GetRenderWidgetHost()); guest_contents->GetRenderWidgetHostView()->GetRenderWidgetHost());
synchronize_threads.Wait(); synchronize_threads.Wait();
ExtensionTestMessageListener synthetic_wheel_listener("Seen wheel event", ExtensionTestMessageListener synthetic_wheel_listener("Seen wheel event");
false);
const gfx::Rect contents_rect = guest_contents->GetContainerBounds(); const gfx::Rect contents_rect = guest_contents->GetContainerBounds();
const gfx::Point pinch_position(contents_rect.width() / 2, const gfx::Point pinch_position(contents_rect.width() / 2,
@ -5389,7 +5383,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, NoExtensionScriptsInjectedInWebview) {
// webview's DOM has not been modified (in this case, by the extension's // webview's DOM has not been modified (in this case, by the extension's
// content script). // content script).
ExtensionTestMessageListener app_content_script_listener( ExtensionTestMessageListener app_content_script_listener(
"WebViewTest.NO_ELEMENT_INJECTED", false); "WebViewTest.NO_ELEMENT_INJECTED");
app_content_script_listener.set_failure_message( app_content_script_listener.set_failure_message(
"WebViewTest.UNKNOWN_ELEMENT_INJECTED"); "WebViewTest.UNKNOWN_ELEMENT_INJECTED");
LoadAppWithGuest("web_view/a_com_webview"); LoadAppWithGuest("web_view/a_com_webview");
@ -5408,7 +5402,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, NoExtensionScriptsInjectedInWebview) {
using GuestViewExtensionNameCollisionTest = extensions::ExtensionBrowserTest; using GuestViewExtensionNameCollisionTest = extensions::ExtensionBrowserTest;
IN_PROC_BROWSER_TEST_F(GuestViewExtensionNameCollisionTest, IN_PROC_BROWSER_TEST_F(GuestViewExtensionNameCollisionTest,
GuestViewNamesDoNotCollideWithExtensions) { GuestViewNamesDoNotCollideWithExtensions) {
ExtensionTestMessageListener loaded_listener("LOADED", false); ExtensionTestMessageListener loaded_listener("LOADED");
const extensions::Extension* extension = const extensions::Extension* extension =
LoadExtension(test_data_dir_.AppendASCII( LoadExtension(test_data_dir_.AppendASCII(
"platform_apps/web_view/no_extension_name_collision")); "platform_apps/web_view/no_extension_name_collision"));
@ -6043,8 +6037,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessWebViewTest, ContentScript) {
} }
// Navigate <webview> cross-site and ensure the new content script runs. // Navigate <webview> cross-site and ensure the new content script runs.
ExtensionTestMessageListener script_listener("Hello from content script!", ExtensionTestMessageListener script_listener("Hello from content script!");
false);
const GURL second_url = const GURL second_url =
embedded_test_server()->GetURL("b.test", "/title1.html"); embedded_test_server()->GetURL("b.test", "/title1.html");
{ {
@ -6129,8 +6122,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessWebViewTest, ContentScriptInOOPIF) {
// Navigate <webview> subframe cross-site to a URL that matches the content // Navigate <webview> subframe cross-site to a URL that matches the content
// script pattern and ensure the new content script runs. // script pattern and ensure the new content script runs.
ExtensionTestMessageListener script_listener("Hello from content script!", ExtensionTestMessageListener script_listener("Hello from content script!");
false);
const GURL frame_url = const GURL frame_url =
embedded_test_server()->GetURL("b.test", "/title1.html"); embedded_test_server()->GetURL("b.test", "/title1.html");
{ {

@ -148,7 +148,7 @@ class WebViewInteractiveTest : public extensions::PlatformAppBrowserTest {
void MoveMouseInsideWindowWithListener(gfx::Point point, void MoveMouseInsideWindowWithListener(gfx::Point point,
const std::string& message) { const std::string& message) {
ExtensionTestMessageListener move_listener(message, false); ExtensionTestMessageListener move_listener(message);
ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(
gfx::Point(corner_.x() + point.x(), corner_.y() + point.y()))); gfx::Point(corner_.x() + point.x(), corner_.y() + point.y())));
ASSERT_TRUE(move_listener.WaitUntilSatisfied()); ASSERT_TRUE(move_listener.WaitUntilSatisfied());
@ -156,7 +156,7 @@ class WebViewInteractiveTest : public extensions::PlatformAppBrowserTest {
void SendMouseClickWithListener(ui_controls::MouseButton button, void SendMouseClickWithListener(ui_controls::MouseButton button,
const std::string& message) { const std::string& message) {
ExtensionTestMessageListener listener(message, false); ExtensionTestMessageListener listener(message);
SendMouseClick(button); SendMouseClick(button);
ASSERT_TRUE(listener.WaitUntilSatisfied()); ASSERT_TRUE(listener.WaitUntilSatisfied());
} }
@ -273,8 +273,8 @@ class WebViewInteractiveTest : public extensions::PlatformAppBrowserTest {
*embedder_web_contents = GetFirstAppWindowWebContents(); *embedder_web_contents = GetFirstAppWindowWebContents();
std::unique_ptr<ExtensionTestMessageListener> done_listener( auto done_listener =
new ExtensionTestMessageListener("TEST_PASSED", false)); std::make_unique<ExtensionTestMessageListener>("TEST_PASSED");
done_listener->set_failure_message("TEST_FAILED"); done_listener->set_failure_message("TEST_FAILED");
if (!content::ExecuteScript( if (!content::ExecuteScript(
*embedder_web_contents, *embedder_web_contents,
@ -481,8 +481,7 @@ class WebViewInteractiveTest : public extensions::PlatformAppBrowserTest {
ASSERT_TRUE(embedder_web_contents); ASSERT_TRUE(embedder_web_contents);
ASSERT_TRUE(guest_web_contents()); ASSERT_TRUE(guest_web_contents());
// Click the guest to request fullscreen. // Click the guest to request fullscreen.
ExtensionTestMessageListener passed_listener( ExtensionTestMessageListener passed_listener("FULLSCREEN_STEP_PASSED");
"FULLSCREEN_STEP_PASSED", false);
passed_listener.set_failure_message("TEST_FAILED"); passed_listener.set_failure_message("TEST_FAILED");
content::SimulateMouseClickAt(guest_web_contents(), 0, content::SimulateMouseClickAt(guest_web_contents(), 0,
blink::WebMouseEvent::Button::kLeft, blink::WebMouseEvent::Button::kLeft,
@ -578,7 +577,7 @@ IN_PROC_BROWSER_TEST_F(WebViewPointerLockInteractiveTest,
// Click the Lock Pointer button. The first two times the button is clicked // Click the Lock Pointer button. The first two times the button is clicked
// the permission API will deny the request (intentional). // the permission API will deny the request (intentional).
ExtensionTestMessageListener exception_listener("request exception", false); ExtensionTestMessageListener exception_listener("request exception");
SendMouseClickWithListener(ui_controls::LEFT, "lock error"); SendMouseClickWithListener(ui_controls::LEFT, "lock error");
ASSERT_TRUE(exception_listener.WaitUntilSatisfied()); ASSERT_TRUE(exception_listener.WaitUntilSatisfied());
SendMouseClickWithListener(ui_controls::LEFT, "lock error"); SendMouseClickWithListener(ui_controls::LEFT, "lock error");
@ -601,7 +600,7 @@ IN_PROC_BROWSER_TEST_F(WebViewPointerLockInteractiveTest,
MoveMouseInsideWindowWithListener(gfx::Point(75, 25), "mouse-move"); MoveMouseInsideWindowWithListener(gfx::Point(75, 25), "mouse-move");
#endif #endif
ExtensionTestMessageListener unlocked_listener("unlocked", false); ExtensionTestMessageListener unlocked_listener("unlocked");
// Send a key press to unlock the mouse. // Send a key press to unlock the mouse.
SendKeyPressToPlatformApp(ui::VKEY_ESCAPE); SendKeyPressToPlatformApp(ui::VKEY_ESCAPE);
@ -612,8 +611,8 @@ IN_PROC_BROWSER_TEST_F(WebViewPointerLockInteractiveTest,
// webview object. main.js then removes the div containing the webview, which // webview object. main.js then removes the div containing the webview, which
// should unlock, and leave the mouse over the mousemove-capture-container // should unlock, and leave the mouse over the mousemove-capture-container
// div. We then move the mouse over that div to ensure the mouse was properly // div. We then move the mouse over that div to ensure the mouse was properly
// unlocked and that the div receieves the message. // unlocked and that the div receives the message.
ExtensionTestMessageListener move_captured_listener("move-captured", false); ExtensionTestMessageListener move_captured_listener("move-captured");
move_captured_listener.set_failure_message("timeout"); move_captured_listener.set_failure_message("timeout");
// Mouse should already be over lock button (since we just unlocked), so send // Mouse should already be over lock button (since we just unlocked), so send
@ -632,7 +631,7 @@ IN_PROC_BROWSER_TEST_F(WebViewPointerLockInteractiveTest,
fprintf(stderr, "TIMEOUT - retrying\n"); fprintf(stderr, "TIMEOUT - retrying\n");
// About 1 in 40 tests fail to detect mouse moves at this point (why?). // About 1 in 40 tests fail to detect mouse moves at this point (why?).
// Sending a right click seems to fix this (why?). // Sending a right click seems to fix this (why?).
ExtensionTestMessageListener move_listener2("move-captured", false); ExtensionTestMessageListener move_listener2("move-captured");
SendMouseClick(ui_controls::RIGHT); SendMouseClick(ui_controls::RIGHT);
ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(
gfx::Point(corner().x() + 51, corner().y() + 11))); gfx::Point(corner().x() + 51, corner().y() + 11)));
@ -655,7 +654,7 @@ IN_PROC_BROWSER_TEST_F(WebViewPointerLockInteractiveTest,
SendMouseClickWithListener(ui_controls::LEFT, "locked"); SendMouseClickWithListener(ui_controls::LEFT, "locked");
// Try to unlock the mouse now that the focus is outside of the BrowserPlugin // Try to unlock the mouse now that the focus is outside of the BrowserPlugin
ExtensionTestMessageListener unlocked_listener("unlocked", false); ExtensionTestMessageListener unlocked_listener("unlocked");
// Send a key press to unlock the mouse. // Send a key press to unlock the mouse.
SendKeyPressToPlatformApp(ui::VKEY_ESCAPE); SendKeyPressToPlatformApp(ui::VKEY_ESCAPE);
@ -690,7 +689,7 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_FocusTakeFocus) {
embedder_web_contents(), embedder_web_contents(),
"domAutomationController.send(Math.floor(window.clickY));", &clickY)); "domAutomationController.send(Math.floor(window.clickY));", &clickY));
ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED");
next_step_listener.set_failure_message("TEST_STEP_FAILED"); next_step_listener.set_failure_message("TEST_STEP_FAILED");
content::SimulateMouseClickAt(guest_web_contents(), 0, content::SimulateMouseClickAt(guest_web_contents(), 0,
blink::WebMouseEvent::Button::kLeft, blink::WebMouseEvent::Button::kLeft,
@ -721,7 +720,7 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest,
&embedder_web_contents)); &embedder_web_contents));
EXPECT_TRUE(done_listener->WaitUntilSatisfied()); EXPECT_TRUE(done_listener->WaitUntilSatisfied());
ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED");
next_step_listener.set_failure_message("TEST_STEP_FAILED"); next_step_listener.set_failure_message("TEST_STEP_FAILED");
EXPECT_TRUE(content::ExecuteScript( EXPECT_TRUE(content::ExecuteScript(
embedder_web_contents, embedder_web_contents,
@ -747,7 +746,7 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_AdvanceFocus) {
} }
{ {
ExtensionTestMessageListener listener("button1-focused", false); ExtensionTestMessageListener listener("button1-focused");
listener.set_failure_message("TEST_FAILED"); listener.set_failure_message("TEST_FAILED");
// In oopif-webview, the click it directly routed to the guest. // In oopif-webview, the click it directly routed to the guest.
@ -766,7 +765,7 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_AdvanceFocus) {
{ {
// Wait for button1 to be focused again, this means we were asked to // Wait for button1 to be focused again, this means we were asked to
// move the focus to the next focusable element. // move the focus to the next focusable element.
ExtensionTestMessageListener listener("button1-advance-focus", false); ExtensionTestMessageListener listener("button1-advance-focus");
listener.set_failure_message("TEST_FAILED"); listener.set_failure_message("TEST_FAILED");
content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB, content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB,
ui::DomCode::TAB, ui::VKEY_TAB, false, false, ui::DomCode::TAB, ui::VKEY_TAB, false, false,
@ -846,7 +845,7 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, EditCommands) {
// Flush any pending events to make sure we start with a clean slate. // Flush any pending events to make sure we start with a clean slate.
content::RunAllPendingInMessageLoop(); content::RunAllPendingInMessageLoop();
ExtensionTestMessageListener copy_listener("copy", false); ExtensionTestMessageListener copy_listener("copy");
SendCopyKeyPressToPlatformApp(); SendCopyKeyPressToPlatformApp();
// Wait for the guest to receive a 'copy' edit command. // Wait for the guest to receive a 'copy' edit command.
@ -866,7 +865,7 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_EditCommandsNoMenu) {
// Flush any pending events to make sure we start with a clean slate. // Flush any pending events to make sure we start with a clean slate.
content::RunAllPendingInMessageLoop(); content::RunAllPendingInMessageLoop();
ExtensionTestMessageListener start_of_line_listener("StartOfLine", false); ExtensionTestMessageListener start_of_line_listener("StartOfLine");
SendStartOfLineKeyPressToPlatformApp(); SendStartOfLineKeyPressToPlatformApp();
#if BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_MAC)
// On macOS, sending an accelerator [key-down] will also cause the subsequent // On macOS, sending an accelerator [key-down] will also cause the subsequent
@ -893,7 +892,7 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_EditCommandsNoMenu) {
IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, MAYBE_NewWindow_OpenInNewTab) { IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, MAYBE_NewWindow_OpenInNewTab) {
content::WebContents* embedder_web_contents = nullptr; content::WebContents* embedder_web_contents = nullptr;
ExtensionTestMessageListener loaded_listener("Loaded", false); ExtensionTestMessageListener loaded_listener("Loaded");
std::unique_ptr<ExtensionTestMessageListener> done_listener( std::unique_ptr<ExtensionTestMessageListener> done_listener(
RunAppHelper("testNewWindowOpenInNewTab", "web_view/newwindow", RunAppHelper("testNewWindowOpenInNewTab", "web_view/newwindow",
NEEDS_TEST_SERVER, &embedder_web_contents)); NEEDS_TEST_SERVER, &embedder_web_contents));
@ -949,13 +948,10 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Navigation_BackForwardKeys) {
content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents(); content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents();
ASSERT_TRUE(embedder_web_contents); ASSERT_TRUE(embedder_web_contents);
ExtensionTestMessageListener done_listener( ExtensionTestMessageListener done_listener("TEST_PASSED");
"TEST_PASSED", false);
done_listener.set_failure_message("TEST_FAILED"); done_listener.set_failure_message("TEST_FAILED");
ExtensionTestMessageListener ready_back_key_listener( ExtensionTestMessageListener ready_back_key_listener("ReadyForBackKey");
"ReadyForBackKey", false); ExtensionTestMessageListener ready_forward_key_listener("ReadyForForwardKey");
ExtensionTestMessageListener ready_forward_key_listener(
"ReadyForForwardKey", false);
EXPECT_TRUE(content::ExecuteScript( EXPECT_TRUE(content::ExecuteScript(
embedder_web_contents, embedder_web_contents,
@ -1059,7 +1055,7 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_FocusRestored) {
ASSERT_TRUE(guest_web_contents()); ASSERT_TRUE(guest_web_contents());
// 1) We click on the guest so that we get a focus event. // 1) We click on the guest so that we get a focus event.
ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED");
next_step_listener.set_failure_message("TEST_STEP_FAILED"); next_step_listener.set_failure_message("TEST_STEP_FAILED");
{ {
content::SimulateMouseClickAt(guest_web_contents(), 0, content::SimulateMouseClickAt(guest_web_contents(), 0,
@ -1134,7 +1130,7 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, MAYBE_Focus_InputMethod) {
->GetTextInputClient(); ->GetTextInputClient();
ASSERT_TRUE(text_input_client); ASSERT_TRUE(text_input_client);
ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED");
next_step_listener.set_failure_message("TEST_STEP_FAILED"); next_step_listener.set_failure_message("TEST_STEP_FAILED");
// An input element inside the <webview> gets focus and is given some // An input element inside the <webview> gets focus and is given some
@ -1263,7 +1259,7 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, TextSelection) {
GetPlatformAppWindow())); GetPlatformAppWindow()));
// Wait until guest sees a context menu. // Wait until guest sees a context menu.
ExtensionTestMessageListener ctx_listener("MSG_CONTEXTMENU", false); ExtensionTestMessageListener ctx_listener("MSG_CONTEXTMENU");
ContextMenuWaiter menu_observer; ContextMenuWaiter menu_observer;
SimulateRWHMouseClick(guest_web_contents()->GetRenderViewHost()->GetWidget(), SimulateRWHMouseClick(guest_web_contents()->GetRenderViewHost()->GetWidget(),
blink::WebMouseEvent::Button::kRight, 20, 20); blink::WebMouseEvent::Button::kRight, 20, 20);
@ -1318,14 +1314,14 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, MAYBE_FocusAndVisibility) {
LoadAndLaunchPlatformApp("web_view/focus_visibility", LoadAndLaunchPlatformApp("web_view/focus_visibility",
"WebViewInteractiveTest.LOADED"); "WebViewInteractiveTest.LOADED");
ExtensionTestMessageListener test_init_listener( ExtensionTestMessageListener test_init_listener(
"WebViewInteractiveTest.WebViewInitialized", false); "WebViewInteractiveTest.WebViewInitialized");
SendMessageToEmbedder("init-oopif"); SendMessageToEmbedder("init-oopif");
EXPECT_TRUE(test_init_listener.WaitUntilSatisfied()); EXPECT_TRUE(test_init_listener.WaitUntilSatisfied());
// Send several tab-keys. The button inside webview should receive focus at // Send several tab-keys. The button inside webview should receive focus at
// least once. // least once.
ExtensionTestMessageListener key_processed_listener( ExtensionTestMessageListener key_processed_listener(
"WebViewInteractiveTest.KeyUp", false); "WebViewInteractiveTest.KeyUp");
#if BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_MAC)
// On mac, the event listener seems one key event behind and deadlocks. Send // On mac, the event listener seems one key event behind and deadlocks. Send
// an extra tab to get things unblocked. See http://crbug.com/685281 when // an extra tab to get things unblocked. See http://crbug.com/685281 when
@ -1340,19 +1336,19 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, MAYBE_FocusAndVisibility) {
// Verify that the button in the guest receives focus. // Verify that the button in the guest receives focus.
ExtensionTestMessageListener webview_button_focused_listener( ExtensionTestMessageListener webview_button_focused_listener(
"WebViewInteractiveTest.WebViewButtonWasFocused", false); "WebViewInteractiveTest.WebViewButtonWasFocused");
webview_button_focused_listener.set_failure_message( webview_button_focused_listener.set_failure_message(
"WebViewInteractiveTest.WebViewButtonWasNotFocused"); "WebViewInteractiveTest.WebViewButtonWasNotFocused");
SendMessageToEmbedder("verify"); SendMessageToEmbedder("verify");
EXPECT_TRUE(webview_button_focused_listener.WaitUntilSatisfied()); EXPECT_TRUE(webview_button_focused_listener.WaitUntilSatisfied());
// Reset the test and now make the <webview> invisible. // Reset the test and now make the <webview> invisible.
ExtensionTestMessageListener reset_listener("WebViewInteractiveTest.DidReset", ExtensionTestMessageListener reset_listener(
false); "WebViewInteractiveTest.DidReset");
SendMessageToEmbedder("reset"); SendMessageToEmbedder("reset");
EXPECT_TRUE(reset_listener.WaitUntilSatisfied()); EXPECT_TRUE(reset_listener.WaitUntilSatisfied());
ExtensionTestMessageListener did_hide_webview_listener( ExtensionTestMessageListener did_hide_webview_listener(
"WebViewInteractiveTest.DidHideWebView", false); "WebViewInteractiveTest.DidHideWebView");
SendMessageToEmbedder("hide-webview"); SendMessageToEmbedder("hide-webview");
EXPECT_TRUE(did_hide_webview_listener.WaitUntilSatisfied()); EXPECT_TRUE(did_hide_webview_listener.WaitUntilSatisfied());
@ -1364,7 +1360,7 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, MAYBE_FocusAndVisibility) {
EXPECT_TRUE(key_processed_listener.WaitUntilSatisfied()); EXPECT_TRUE(key_processed_listener.WaitUntilSatisfied());
} }
ExtensionTestMessageListener webview_button_not_focused_listener( ExtensionTestMessageListener webview_button_not_focused_listener(
"WebViewInteractiveTest.WebViewButtonWasNotFocused", false); "WebViewInteractiveTest.WebViewButtonWasNotFocused");
webview_button_not_focused_listener.set_failure_message( webview_button_not_focused_listener.set_failure_message(
"WebViewInteractiveTest.WebViewButtonWasFocused"); "WebViewInteractiveTest.WebViewButtonWasFocused");
SendMessageToEmbedder("verify"); SendMessageToEmbedder("verify");
@ -1385,7 +1381,7 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, MAYBE_KeyboardFocusSimple) {
EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(), EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(),
embedder_web_contents()->GetMainFrame()); embedder_web_contents()->GetMainFrame());
ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED");
next_step_listener.set_failure_message("TEST_STEP_FAILED"); next_step_listener.set_failure_message("TEST_STEP_FAILED");
{ {
gfx::Rect offset = embedder_web_contents()->GetContainerBounds(); gfx::Rect offset = embedder_web_contents()->GetContainerBounds();
@ -1432,7 +1428,7 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, MAYBE_KeyboardFocusWindowCycle) {
EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(), EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(),
embedder_web_contents()->GetMainFrame()); embedder_web_contents()->GetMainFrame());
ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED");
next_step_listener.set_failure_message("TEST_STEP_FAILED"); next_step_listener.set_failure_message("TEST_STEP_FAILED");
{ {
gfx::Rect offset = embedder_web_contents()->GetContainerBounds(); gfx::Rect offset = embedder_web_contents()->GetContainerBounds();
@ -1509,8 +1505,7 @@ IN_PROC_BROWSER_TEST_F(WebViewImeInteractiveTest,
// Click the <input> element inside the <webview>. In its focus handle, the // Click the <input> element inside the <webview>. In its focus handle, the
// <input> inside the <webview> initializes its value to "A B X D". // <input> inside the <webview> initializes its value to "A B X D".
ExtensionTestMessageListener focus_listener("WebViewImeTest.InputFocused", ExtensionTestMessageListener focus_listener("WebViewImeTest.InputFocused");
false);
content::WebContents* target_web_contents = guest_web_contents; content::WebContents* target_web_contents = guest_web_contents;
WaitForHitTestData(guest_web_contents); WaitForHitTestData(guest_web_contents);
@ -1532,8 +1527,7 @@ IN_PROC_BROWSER_TEST_F(WebViewImeInteractiveTest,
// Now commit "C" to to replace the range (4, 5). // Now commit "C" to to replace the range (4, 5).
// For OOPIF guests, the target for IME is the RWH for the guest's main frame. // For OOPIF guests, the target for IME is the RWH for the guest's main frame.
// For BrowserPlugin-based guests, input always goes to the embedder. // For BrowserPlugin-based guests, input always goes to the embedder.
ExtensionTestMessageListener input_listener("WebViewImetest.InputReceived", ExtensionTestMessageListener input_listener("WebViewImetest.InputReceived");
false);
content::RenderWidgetHost* target_rwh_for_input = content::RenderWidgetHost* target_rwh_for_input =
target_web_contents->GetRenderWidgetHostView()->GetRenderWidgetHost(); target_web_contents->GetRenderWidgetHostView()->GetRenderWidgetHost();
content::SendImeCommitTextToWidget(target_rwh_for_input, u"C", content::SendImeCommitTextToWidget(target_rwh_for_input, u"C",
@ -1568,8 +1562,7 @@ IN_PROC_BROWSER_TEST_F(WebViewImeInteractiveTest, CompositionRangeUpdates) {
// Click the <input> element inside the <webview>. In its focus handle, the // Click the <input> element inside the <webview>. In its focus handle, the
// <input> inside the <webview> initializes its value to "A B X D". // <input> inside the <webview> initializes its value to "A B X D".
ExtensionTestMessageListener focus_listener("WebViewImeTest.InputFocused", ExtensionTestMessageListener focus_listener("WebViewImeTest.InputFocused");
false);
content::WebContents* embedder_web_contents = content::WebContents* embedder_web_contents =
guest_view::GuestViewBase::FromWebContents(guest_web_contents) guest_view::GuestViewBase::FromWebContents(guest_web_contents)
->embedder_web_contents(); ->embedder_web_contents();

@ -128,7 +128,7 @@ IN_PROC_BROWSER_TEST_F(ArcAppsPrivateApiTest, OnInstalled) {
// newly installed app. // newly installed app.
SetCustomArg("Package_0"); SetCustomArg("Package_0");
extensions::ResultCatcher catcher; extensions::ResultCatcher catcher;
ExtensionTestMessageListener ready_listener("ready", false); ExtensionTestMessageListener ready_listener("ready");
base::FilePath path = base::FilePath path =
test_data_dir_.AppendASCII("arc_app_launcher/install_event"); test_data_dir_.AppendASCII("arc_app_launcher/install_event");

@ -111,7 +111,7 @@ class MediaGalleriesGalleryWatchApiTest : public extensions::ExtensionApiTest {
void ExecuteCmdAndCheckReply(const std::string& js_command, void ExecuteCmdAndCheckReply(const std::string& js_command,
const std::string& ok_message) { const std::string& ok_message) {
ExtensionTestMessageListener listener(ok_message, false); ExtensionTestMessageListener listener(ok_message);
background_main_frame_->ExecuteJavaScriptForTests( background_main_frame_->ExecuteJavaScriptForTests(
base::ASCIIToUTF16(js_command), base::NullCallback()); base::ASCIIToUTF16(js_command), base::NullCallback());
EXPECT_TRUE(listener.WaitUntilSatisfied()); EXPECT_TRUE(listener.WaitUntilSatisfied());
@ -129,8 +129,7 @@ class MediaGalleriesGalleryWatchApiTest : public extensions::ExtensionApiTest {
? kAddGalleryWatchRequestSucceeded ? kAddGalleryWatchRequestSucceeded
: kAddGalleryWatchRequestFailed; : kAddGalleryWatchRequestFailed;
ExtensionTestMessageListener add_gallery_watch_finished( ExtensionTestMessageListener add_gallery_watch_finished(expected_result);
expected_result, false /* no reply */);
ExecuteCmdAndCheckReply(kSetupWatchOnValidGalleriesCmd, kAddGalleryWatchOK); ExecuteCmdAndCheckReply(kSetupWatchOnValidGalleriesCmd, kAddGalleryWatchOK);
EXPECT_TRUE(add_gallery_watch_finished.WaitUntilSatisfied()); EXPECT_TRUE(add_gallery_watch_finished.WaitUntilSatisfied());
} }
@ -169,7 +168,7 @@ class MediaGalleriesGalleryWatchApiTest : public extensions::ExtensionApiTest {
void FetchMediaGalleriesList() { void FetchMediaGalleriesList() {
ExtensionTestMessageListener get_media_systems_finished( ExtensionTestMessageListener get_media_systems_finished(
kGetMediaFileSystemsCallbackOK, false /* no reply */); kGetMediaFileSystemsCallbackOK);
ExecuteCmdAndCheckReply(kGetMediaFileSystemsCmd, kGetMediaFileSystemsOK); ExecuteCmdAndCheckReply(kGetMediaFileSystemsCmd, kGetMediaFileSystemsOK);
EXPECT_TRUE(get_media_systems_finished.WaitUntilSatisfied()); EXPECT_TRUE(get_media_systems_finished.WaitUntilSatisfied());
} }
@ -200,7 +199,7 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesGalleryWatchApiTest,
// Modify gallery contents. // Modify gallery contents.
ExtensionTestMessageListener gallery_change_event_received( ExtensionTestMessageListener gallery_change_event_received(
kGalleryChangedEventReceived, false /* no reply */); kGalleryChangedEventReceived);
ASSERT_TRUE(AddNewFileInTestGallery()); ASSERT_TRUE(AddNewFileInTestGallery());
if (GalleryWatchesSupported()) if (GalleryWatchesSupported())
@ -234,8 +233,7 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesGalleryWatchApiTest,
SetupGalleryWatches(); SetupGalleryWatches();
// Modify gallery contents; expect correct details. // Modify gallery contents; expect correct details.
ExtensionTestMessageListener got_correct_details(kOnGalleryChangedCheckingOK, ExtensionTestMessageListener got_correct_details(kOnGalleryChangedCheckingOK);
false);
ASSERT_TRUE(AddNewFileInTestGallery()); ASSERT_TRUE(AddNewFileInTestGallery());
EXPECT_TRUE(got_correct_details.WaitUntilSatisfied()); EXPECT_TRUE(got_correct_details.WaitUntilSatisfied());
} }
@ -261,7 +259,7 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesGalleryWatchApiTest,
// Modify gallery contents. // Modify gallery contents.
ExtensionTestMessageListener gallery_change_event_received( ExtensionTestMessageListener gallery_change_event_received(
kGalleryChangedEventReceived, false /* no reply */); kGalleryChangedEventReceived);
ASSERT_TRUE(AddNewFileInTestGallery()); ASSERT_TRUE(AddNewFileInTestGallery());
EXPECT_TRUE(gallery_change_event_received.WaitUntilSatisfied()); EXPECT_TRUE(gallery_change_event_received.WaitUntilSatisfied());
@ -294,7 +292,7 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesGalleryWatchApiTest,
// Modify gallery contents. Listener should not get called because add watch // Modify gallery contents. Listener should not get called because add watch
// request was not called. // request was not called.
ExtensionTestMessageListener gallery_change_event_received( ExtensionTestMessageListener gallery_change_event_received(
kGalleryChangedEventReceived, false /* no reply */); kGalleryChangedEventReceived);
ASSERT_TRUE(AddNewFileInTestGallery()); ASSERT_TRUE(AddNewFileInTestGallery());
// Remove gallery watch listener. // Remove gallery watch listener.

@ -157,11 +157,11 @@ class SyncFileSystemTest : public extensions::PlatformAppBrowserTest,
IN_PROC_BROWSER_TEST_F(SyncFileSystemTest, AuthorizationTest) { IN_PROC_BROWSER_TEST_F(SyncFileSystemTest, AuthorizationTest) {
ExtensionTestMessageListener open_failure("checkpoint: Failed to get syncfs", ExtensionTestMessageListener open_failure("checkpoint: Failed to get syncfs",
true); ReplyBehavior::kWillReply);
ExtensionTestMessageListener bar_created("checkpoint: \"/bar\" created", ExtensionTestMessageListener bar_created("checkpoint: \"/bar\" created",
true); ReplyBehavior::kWillReply);
ExtensionTestMessageListener foo_created("checkpoint: \"/foo\" created", ExtensionTestMessageListener foo_created("checkpoint: \"/foo\" created",
true); ReplyBehavior::kWillReply);
extensions::ResultCatcher catcher; extensions::ResultCatcher catcher;
LoadAndLaunchPlatformApp("sync_file_system/authorization_test", "Launched"); LoadAndLaunchPlatformApp("sync_file_system/authorization_test", "Launched");

@ -370,7 +370,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) {
} }
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, InstalledAppWithContextMenu) { IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, InstalledAppWithContextMenu) {
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
InstallAndLaunchPlatformApp("context_menu"); InstallAndLaunchPlatformApp("context_menu");
// Wait for the extension to tell us it's initialized its context menus and // Wait for the extension to tell us it's initialized its context menus and
@ -471,8 +471,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) {
ASSERT_TRUE(menu->HasCommandWithId(extensions_custom_id)); ASSERT_TRUE(menu->HasCommandWithId(extensions_custom_id));
// Execute the menu item // Execute the menu item
ExtensionTestMessageListener onclicked_listener("onClicked fired for id1", ExtensionTestMessageListener onclicked_listener("onClicked fired for id1");
false);
menu->ExecuteCommand(extensions_custom_id, 0); menu->ExecuteCommand(extensions_custom_id, 0);
ASSERT_TRUE(onclicked_listener.WaitUntilSatisfied()); ASSERT_TRUE(onclicked_listener.WaitUntilSatisfied());
@ -1000,7 +999,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_ConstrainedWindowRequest) {
// Close the constrained window and wait for the reply to the permission // Close the constrained window and wait for the reply to the permission
// request. // request.
ExtensionTestMessageListener listener("PermissionRequestDone", false); ExtensionTestMessageListener listener("PermissionRequestDone");
WebContentsModalDialogManager::TestApi test_api( WebContentsModalDialogManager::TestApi test_api(
web_contents_modal_dialog_manager); web_contents_modal_dialog_manager);
test_api.CloseAllDialogs(); test_api.CloseAllDialogs();
@ -1010,14 +1009,15 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_ConstrainedWindowRequest) {
// Tests that an app calling chrome.runtime.reload will reload the app and // Tests that an app calling chrome.runtime.reload will reload the app and
// relaunch it if it was running. // relaunch it if it was running.
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) { IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
const Extension* extension = const Extension* extension =
LoadAndLaunchPlatformApp("reload", &launched_listener); LoadAndLaunchPlatformApp("reload", &launched_listener);
ASSERT_TRUE(extension); ASSERT_TRUE(extension);
ASSERT_TRUE(GetFirstAppWindow()); ASSERT_TRUE(GetFirstAppWindow());
// Now tell the app to reload itself. // Now tell the app to reload itself.
ExtensionTestMessageListener launched_listener2("Launched", false); ExtensionTestMessageListener launched_listener2("Launched");
launched_listener.Reply("reload"); launched_listener.Reply("reload");
ASSERT_TRUE(launched_listener2.WaitUntilSatisfied()); ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
ASSERT_TRUE(GetFirstAppWindow()); ASSERT_TRUE(GetFirstAppWindow());
@ -1026,7 +1026,8 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) {
// Tests that reloading a component app loads its (lazy) background page. // Tests that reloading a component app loads its (lazy) background page.
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
ComponentReloadLoadsLazyBackgroundPage) { ComponentReloadLoadsLazyBackgroundPage) {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
const Extension* component_app = LoadExtensionAsComponentWithManifest( const Extension* component_app = LoadExtensionAsComponentWithManifest(
test_data_dir_.AppendASCII("platform_apps") test_data_dir_.AppendASCII("platform_apps")
.AppendASCII("component_reload"), .AppendASCII("component_reload"),
@ -1035,7 +1036,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
// Now tell the app to reload itself. // Now tell the app to reload itself.
ExtensionTestMessageListener launched_listener2("Launched", false); ExtensionTestMessageListener launched_listener2("Launched");
launched_listener.Reply("reload"); launched_listener.Reply("reload");
ASSERT_TRUE(launched_listener2.WaitUntilSatisfied()); ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
} }
@ -1095,7 +1096,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
app_loaded_observer.Wait(); app_loaded_observer.Wait();
ASSERT_TRUE(should_install.seen()); ASSERT_TRUE(should_install.seen());
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
apps::AppServiceProxyFactory::GetForProfile(browser()->profile()) apps::AppServiceProxyFactory::GetForProfile(browser()->profile())
->BrowserAppLauncher() ->BrowserAppLauncher()
->LaunchAppWithParamsForTesting(apps::AppLaunchParams( ->LaunchAppWithParamsForTesting(apps::AppLaunchParams(
@ -1120,7 +1121,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, PRE_ComponentAppBackgroundPage) {
test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); test_data_dir_.AppendASCII("platform_apps").AppendASCII("component"));
ASSERT_TRUE(extension); ASSERT_TRUE(extension);
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
apps::AppServiceProxyFactory::GetForProfile(browser()->profile()) apps::AppServiceProxyFactory::GetForProfile(browser()->profile())
->BrowserAppLauncher() ->BrowserAppLauncher()
->LaunchAppWithParamsForTesting(apps::AppLaunchParams( ->LaunchAppWithParamsForTesting(apps::AppLaunchParams(
@ -1161,7 +1162,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ComponentAppBackgroundPage) {
app_loaded_observer.Wait(); app_loaded_observer.Wait();
ASSERT_TRUE(should_install.seen()); ASSERT_TRUE(should_install.seen());
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
apps::AppServiceProxyFactory::GetForProfile(browser()->profile()) apps::AppServiceProxyFactory::GetForProfile(browser()->profile())
->BrowserAppLauncher() ->BrowserAppLauncher()
->LaunchAppWithParamsForTesting(apps::AppLaunchParams( ->LaunchAppWithParamsForTesting(apps::AppLaunchParams(
@ -1189,7 +1190,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
app_loaded_observer.Wait(); app_loaded_observer.Wait();
{ {
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
apps::AppServiceProxyFactory::GetForProfile(browser()->profile()) apps::AppServiceProxyFactory::GetForProfile(browser()->profile())
->BrowserAppLauncher() ->BrowserAppLauncher()
->LaunchAppWithParamsForTesting(apps::AppLaunchParams( ->LaunchAppWithParamsForTesting(apps::AppLaunchParams(
@ -1200,7 +1201,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
} }
{ {
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
ASSERT_TRUE(ExecuteScriptInBackgroundPageNoWait( ASSERT_TRUE(ExecuteScriptInBackgroundPageNoWait(
extension->id(), extension->id(),
// NoWait actually waits for a domAutomationController.send() which is // NoWait actually waits for a domAutomationController.send() which is
@ -1385,14 +1386,14 @@ IN_PROC_BROWSER_TEST_F(RestartDeviceTest, Restart) {
EnterKioskSession(); EnterKioskSession();
ASSERT_EQ(0, num_request_restart_calls()); ASSERT_EQ(0, num_request_restart_calls());
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
const Extension* extension = const Extension* extension =
LoadAndLaunchPlatformApp("restart_device", &launched_listener); LoadAndLaunchPlatformApp("restart_device", &launched_listener);
ASSERT_TRUE(extension); ASSERT_TRUE(extension);
launched_listener.Reply("restart"); launched_listener.Reply("restart");
ExtensionTestMessageListener restart_requested_listener("restartRequested", ExtensionTestMessageListener restart_requested_listener("restartRequested");
false);
ASSERT_TRUE(restart_requested_listener.WaitUntilSatisfied()); ASSERT_TRUE(restart_requested_listener.WaitUntilSatisfied());
EXPECT_EQ(1, num_request_restart_calls()); EXPECT_EQ(1, num_request_restart_calls());
@ -1443,7 +1444,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppsIgnoreDefaultZoom) {
// Launch another window. This is a simple way to guarantee that any messages // Launch another window. This is a simple way to guarantee that any messages
// that would have been delivered to the app renderer and back for zoom have // that would have been delivered to the app renderer and back for zoom have
// made it through. // made it through.
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
LaunchPlatformApp(extension); LaunchPlatformApp(extension);
EXPECT_TRUE(launched_listener.WaitUntilSatisfied()); EXPECT_TRUE(launched_listener.WaitUntilSatisfied());
@ -1495,8 +1496,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
web_contents->GetRenderWidgetHostView()->GetRenderWidgetHost()); web_contents->GetRenderWidgetHostView()->GetRenderWidgetHost());
synchronize_threads.Wait(); synchronize_threads.Wait();
ExtensionTestMessageListener synthetic_wheel_listener("Seen wheel event", ExtensionTestMessageListener synthetic_wheel_listener("Seen wheel event");
false);
const gfx::Rect contents_rect = web_contents->GetContainerBounds(); const gfx::Rect contents_rect = web_contents->GetContainerBounds();
const gfx::Point pinch_position(contents_rect.width() / 2, const gfx::Point pinch_position(contents_rect.width() / 2,

@ -119,7 +119,7 @@ const Extension* PlatformAppBrowserTest::LoadAndLaunchPlatformApp(
const Extension* PlatformAppBrowserTest::LoadAndLaunchPlatformApp( const Extension* PlatformAppBrowserTest::LoadAndLaunchPlatformApp(
const char* name, const char* name,
const std::string& message) { const std::string& message) {
ExtensionTestMessageListener launched_listener(message, false); ExtensionTestMessageListener launched_listener(message);
const Extension* extension = const Extension* extension =
LoadAndLaunchPlatformApp(name, &launched_listener); LoadAndLaunchPlatformApp(name, &launched_listener);
@ -275,8 +275,9 @@ void PlatformAppBrowserTest::CallAdjustBoundsToBeVisibleOnScreenForAppWindow(
AppWindow* PlatformAppBrowserTest::CreateTestAppWindow( AppWindow* PlatformAppBrowserTest::CreateTestAppWindow(
const std::string& window_create_options) { const std::string& window_create_options) {
ExtensionTestMessageListener launched_listener("launched", true); ExtensionTestMessageListener launched_listener("launched",
ExtensionTestMessageListener loaded_listener("window_loaded", false); ReplyBehavior::kWillReply);
ExtensionTestMessageListener loaded_listener("window_loaded");
// Load and launch the test app. // Load and launch the test app.
const Extension* extension = const Extension* extension =

@ -12,7 +12,8 @@
class ExtensionPointerLockTest : public extensions::PlatformAppBrowserTest { class ExtensionPointerLockTest : public extensions::PlatformAppBrowserTest {
public: public:
bool RunExtensionPointerLockTest(const char* app_path) { bool RunExtensionPointerLockTest(const char* app_path) {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
LoadAndLaunchPlatformApp(app_path, &launched_listener); LoadAndLaunchPlatformApp(app_path, &launched_listener);
extensions::ResultCatcher catcher; extensions::ResultCatcher catcher;

@ -430,7 +430,7 @@ IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_Launch) {
// Case 2: Launch the shim, it should start the app. // Case 2: Launch the shim, it should start the app.
{ {
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
base::CommandLine shim_cmdline(base::CommandLine::NO_PROGRAM); base::CommandLine shim_cmdline(base::CommandLine::NO_PROGRAM);
shim_cmdline.AppendSwitch(app_mode::kLaunchedForTest); shim_cmdline.AppendSwitch(app_mode::kLaunchedForTest);
NSRunningApplication* shim_app = base::mac::OpenApplicationWithPath( NSRunningApplication* shim_app = base::mac::OpenApplicationWithPath(
@ -480,7 +480,7 @@ IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_ShowWindow) {
// Launch the app. It should create a hidden window, but the shim should not // Launch the app. It should create a hidden window, but the shim should not
// launch. // launch.
{ {
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
LaunchPlatformApp(app); LaunchPlatformApp(app);
EXPECT_TRUE(launched_listener.WaitUntilSatisfied()); EXPECT_TRUE(launched_listener.WaitUntilSatisfied());
} }
@ -519,7 +519,7 @@ IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_ShowWindow) {
// Launch a second window. It should not launch the shim. // Launch a second window. It should not launch the shim.
{ {
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
LaunchPlatformApp(app); LaunchPlatformApp(app);
EXPECT_TRUE(launched_listener.WaitUntilSatisfied()); EXPECT_TRUE(launched_listener.WaitUntilSatisfied());
} }
@ -651,7 +651,7 @@ IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_RebuildShim) {
// rebuild the shim. // rebuild the shim.
// (3) After rebuilding, Chrome again launches the shim and expects it to // (3) After rebuilding, Chrome again launches the shim and expects it to
// behave normally. // behave normally.
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
base::CommandLine shim_cmdline(base::CommandLine::NO_PROGRAM); base::CommandLine shim_cmdline(base::CommandLine::NO_PROGRAM);
NSRunningApplication* shim_app = base::mac::OpenApplicationWithPath( NSRunningApplication* shim_app = base::mac::OpenApplicationWithPath(
shim_path, shim_cmdline, NSWorkspaceLaunchDefault); shim_path, shim_cmdline, NSWorkspaceLaunchDefault);

@ -56,7 +56,7 @@ class AppShimQuitTest : public PlatformAppBrowserTest {
void SetUpAppShim() { void SetUpAppShim() {
ASSERT_EQ(0u, [[NSApp windows] count]); ASSERT_EQ(0u, [[NSApp windows] count]);
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
ASSERT_EQ(1u, [[NSApp windows] count]); ASSERT_EQ(1u, [[NSApp windows] count]);

@ -101,7 +101,8 @@ class AppWindowAPITest : public extensions::PlatformAppBrowserTest {
if (!BeginAppWindowAPITest(testName)) if (!BeginAppWindowAPITest(testName))
return false; return false;
ExtensionTestMessageListener round_trip_listener("WaitForRoundTrip", true); ExtensionTestMessageListener round_trip_listener("WaitForRoundTrip",
ReplyBehavior::kWillReply);
if (!round_trip_listener.WaitUntilSatisfied()) { if (!round_trip_listener.WaitUntilSatisfied()) {
message_ = "Did not get the 'WaitForRoundTrip' message."; message_ = "Did not get the 'WaitForRoundTrip' message.";
return false; return false;
@ -120,7 +121,8 @@ class AppWindowAPITest : public extensions::PlatformAppBrowserTest {
private: private:
bool BeginAppWindowAPITest(const char* testName) { bool BeginAppWindowAPITest(const char* testName) {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
LoadAndLaunchPlatformApp("window_api", &launched_listener); LoadAndLaunchPlatformApp("window_api", &launched_listener);
if (!launched_listener.WaitUntilSatisfied()) { if (!launched_listener.WaitUntilSatisfied()) {
message_ = "Did not get the 'Launched' message."; message_ = "Did not get the 'Launched' message.";
@ -216,7 +218,8 @@ IN_PROC_BROWSER_TEST_F(AppWindowAPITest,
// test will check if the geometry cache entry for the test window has // test will check if the geometry cache entry for the test window has
// changed. When the change happens, the test will let the app know so it can // changed. When the change happens, the test will let the app know so it can
// continue running. // continue running.
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
content::WindowedNotificationObserver app_loaded_observer( content::WindowedNotificationObserver app_loaded_observer(
content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
@ -233,7 +236,8 @@ IN_PROC_BROWSER_TEST_F(AppWindowAPITest,
WindowOpenDisposition::NEW_WINDOW, WindowOpenDisposition::NEW_WINDOW,
apps::mojom::LaunchSource::kFromTest)); apps::mojom::LaunchSource::kFromTest));
ExtensionTestMessageListener geometry_listener("ListenGeometryChange", true); ExtensionTestMessageListener geometry_listener("ListenGeometryChange",
ReplyBehavior::kWillReply);
ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
launched_listener.Reply("testRestoreAfterGeometryCacheChange"); launched_listener.Reply("testRestoreAfterGeometryCacheChange");

@ -33,7 +33,8 @@ using extensions::AppWindow;
using extensions::NativeAppWindow; using extensions::NativeAppWindow;
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenWindow) { IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenWindow) {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
LoadAndLaunchPlatformApp("leave_fullscreen", &launched_listener); LoadAndLaunchPlatformApp("leave_fullscreen", &launched_listener);
// We start by making sure the window is actually focused. // We start by making sure the window is actually focused.
@ -70,7 +71,8 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenWindow) {
} }
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenDOM) { IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenDOM) {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
LoadAndLaunchPlatformApp("leave_fullscreen", &launched_listener); LoadAndLaunchPlatformApp("leave_fullscreen", &launched_listener);
// We start by making sure the window is actually focused. // We start by making sure the window is actually focused.
@ -115,7 +117,8 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenDOM) {
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
ESCDoesNotLeaveFullscreenWindow) { ESCDoesNotLeaveFullscreenWindow) {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
LoadAndLaunchPlatformApp("prevent_leave_fullscreen", &launched_listener); LoadAndLaunchPlatformApp("prevent_leave_fullscreen", &launched_listener);
// We start by making sure the window is actually focused. // We start by making sure the window is actually focused.
@ -142,7 +145,7 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE)); ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE));
ExtensionTestMessageListener second_key_listener("B_KEY_RECEIVED", false); ExtensionTestMessageListener second_key_listener("B_KEY_RECEIVED");
ASSERT_TRUE(SimulateKeyPress(ui::VKEY_B)); ASSERT_TRUE(SimulateKeyPress(ui::VKEY_B));
@ -156,7 +159,8 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
} }
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCDoesNotLeaveFullscreenDOM) { IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCDoesNotLeaveFullscreenDOM) {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
LoadAndLaunchPlatformApp("prevent_leave_fullscreen", &launched_listener); LoadAndLaunchPlatformApp("prevent_leave_fullscreen", &launched_listener);
// We start by making sure the window is actually focused. // We start by making sure the window is actually focused.
@ -190,7 +194,7 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCDoesNotLeaveFullscreenDOM) {
ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE)); ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE));
ExtensionTestMessageListener second_key_listener("B_KEY_RECEIVED", false); ExtensionTestMessageListener second_key_listener("B_KEY_RECEIVED");
ASSERT_TRUE(SimulateKeyPress(ui::VKEY_B)); ASSERT_TRUE(SimulateKeyPress(ui::VKEY_B));
@ -208,7 +212,8 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCDoesNotLeaveFullscreenDOM) {
// and 'overrideEscFullscreen'. // and 'overrideEscFullscreen'.
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
ESCDoesNotLeaveFullscreenOldPermission) { ESCDoesNotLeaveFullscreenOldPermission) {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
LoadAndLaunchPlatformApp("prevent_leave_fullscreen_old", &launched_listener); LoadAndLaunchPlatformApp("prevent_leave_fullscreen_old", &launched_listener);
// We start by making sure the window is actually focused. // We start by making sure the window is actually focused.
@ -235,7 +240,7 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE)); ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE));
ExtensionTestMessageListener second_key_listener("B_KEY_RECEIVED", false); ExtensionTestMessageListener second_key_listener("B_KEY_RECEIVED");
ASSERT_TRUE(SimulateKeyPress(ui::VKEY_B)); ASSERT_TRUE(SimulateKeyPress(ui::VKEY_B));
@ -262,7 +267,8 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_TestInnerBounds) {
void AppWindowInteractiveTest::TestOuterBoundsHelper( void AppWindowInteractiveTest::TestOuterBoundsHelper(
const std::string& frame_type) { const std::string& frame_type) {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
const extensions::Extension* app = const extensions::Extension* app =
LoadAndLaunchPlatformApp("outer_bounds", &launched_listener); LoadAndLaunchPlatformApp("outer_bounds", &launched_listener);
@ -381,15 +387,17 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, TestDrawAttention) {
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, TestCreateHidden) { IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, TestCreateHidden) {
// Created hidden both times. // Created hidden both times.
{ {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
LoadAndLaunchPlatformApp("hidden_with_id", &launched_listener); LoadAndLaunchPlatformApp("hidden_with_id", &launched_listener);
EXPECT_TRUE(launched_listener.WaitUntilSatisfied()); EXPECT_TRUE(launched_listener.WaitUntilSatisfied());
ExtensionTestMessageListener create_listener_1("Launched", true); ExtensionTestMessageListener create_listener_1("Launched",
ReplyBehavior::kWillReply);
launched_listener.Reply("createHidden"); launched_listener.Reply("createHidden");
EXPECT_TRUE(create_listener_1.WaitUntilSatisfied()); EXPECT_TRUE(create_listener_1.WaitUntilSatisfied());
AppWindow* app_window = GetFirstAppWindow(); AppWindow* app_window = GetFirstAppWindow();
EXPECT_TRUE(app_window->is_hidden()); EXPECT_TRUE(app_window->is_hidden());
ExtensionTestMessageListener create_listener_2("Launched", false); ExtensionTestMessageListener create_listener_2("Launched");
create_listener_1.Reply("createHidden"); create_listener_1.Reply("createHidden");
EXPECT_TRUE(create_listener_2.WaitUntilSatisfied()); EXPECT_TRUE(create_listener_2.WaitUntilSatisfied());
EXPECT_TRUE(app_window->is_hidden()); EXPECT_TRUE(app_window->is_hidden());
@ -398,15 +406,17 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, TestCreateHidden) {
// Created hidden, then visible. The second create should show the window. // Created hidden, then visible. The second create should show the window.
{ {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
LoadAndLaunchPlatformApp("hidden_with_id", &launched_listener); LoadAndLaunchPlatformApp("hidden_with_id", &launched_listener);
EXPECT_TRUE(launched_listener.WaitUntilSatisfied()); EXPECT_TRUE(launched_listener.WaitUntilSatisfied());
ExtensionTestMessageListener create_listener_1("Launched", true); ExtensionTestMessageListener create_listener_1("Launched",
ReplyBehavior::kWillReply);
launched_listener.Reply("createHidden"); launched_listener.Reply("createHidden");
EXPECT_TRUE(create_listener_1.WaitUntilSatisfied()); EXPECT_TRUE(create_listener_1.WaitUntilSatisfied());
AppWindow* app_window = GetFirstAppWindow(); AppWindow* app_window = GetFirstAppWindow();
EXPECT_TRUE(app_window->is_hidden()); EXPECT_TRUE(app_window->is_hidden());
ExtensionTestMessageListener create_listener_2("Launched", false); ExtensionTestMessageListener create_listener_2("Launched");
create_listener_1.Reply("createVisible"); create_listener_1.Reply("createVisible");
EXPECT_TRUE(create_listener_2.WaitUntilSatisfied()); EXPECT_TRUE(create_listener_2.WaitUntilSatisfied());
EXPECT_FALSE(app_window->is_hidden()); EXPECT_FALSE(app_window->is_hidden());
@ -480,7 +490,8 @@ IN_PROC_BROWSER_TEST_F(AppWindowHiddenKeepAliveTest, StaysHidden) {
// A window that is created hidden but shown soon after should keep Chrome // A window that is created hidden but shown soon after should keep Chrome
// alive. // alive.
IN_PROC_BROWSER_TEST_F(AppWindowHiddenKeepAliveTest, HiddenThenShown) { IN_PROC_BROWSER_TEST_F(AppWindowHiddenKeepAliveTest, HiddenThenShown) {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
LoadAndLaunchPlatformApp("hidden_then_shown", &launched_listener); LoadAndLaunchPlatformApp("hidden_then_shown", &launched_listener);
AppWindow* app_window = GetFirstAppWindow(); AppWindow* app_window = GetFirstAppWindow();
EXPECT_TRUE(app_window->is_hidden()); EXPECT_TRUE(app_window->is_hidden());
@ -490,7 +501,7 @@ IN_PROC_BROWSER_TEST_F(AppWindowHiddenKeepAliveTest, HiddenThenShown) {
browser->window()->Close(); browser->window()->Close();
// The app window will show after 3 seconds. // The app window will show after 3 seconds.
ExtensionTestMessageListener shown_listener("Shown", false); ExtensionTestMessageListener shown_listener("Shown");
launched_listener.Reply(""); launched_listener.Reply("");
EXPECT_TRUE(shown_listener.WaitUntilSatisfied()); EXPECT_TRUE(shown_listener.WaitUntilSatisfied());
EXPECT_FALSE(app_window->is_hidden()); EXPECT_FALSE(app_window->is_hidden());

@ -24,7 +24,8 @@ void FullscreenChangeWaiter::Wait() {
bool AppWindowInteractiveTest::RunAppWindowInteractiveTest( bool AppWindowInteractiveTest::RunAppWindowInteractiveTest(
const char* testName) { const char* testName) {
ExtensionTestMessageListener launched_listener("Launched", true); ExtensionTestMessageListener launched_listener("Launched",
ReplyBehavior::kWillReply);
LoadAndLaunchPlatformApp("window_api_interactive", &launched_listener); LoadAndLaunchPlatformApp("window_api_interactive", &launched_listener);
extensions::ResultCatcher catcher; extensions::ResultCatcher catcher;
@ -44,7 +45,7 @@ bool AppWindowInteractiveTest::SimulateKeyPress(ui::KeyboardCode key) {
} }
void AppWindowInteractiveTest::WaitUntilKeyFocus() { void AppWindowInteractiveTest::WaitUntilKeyFocus() {
ExtensionTestMessageListener key_listener("KeyReceived", false); ExtensionTestMessageListener key_listener("KeyReceived");
while (!key_listener.was_satisfied()) { while (!key_listener.was_satisfied()) {
ASSERT_TRUE(SimulateKeyPress(ui::VKEY_Z)); ASSERT_TRUE(SimulateKeyPress(ui::VKEY_Z));

@ -33,7 +33,7 @@ IN_PROC_BROWSER_TEST_F(AudioFocusWebContentsObserverBrowserTest,
PlatformAppHasDifferentAudioFocus) { PlatformAppHasDifferentAudioFocus) {
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
ExtensionTestMessageListener launched_listener("Launched", false); ExtensionTestMessageListener launched_listener("Launched");
const extensions::Extension* extension = const extensions::Extension* extension =
InstallAndLaunchPlatformApp("minimal"); InstallAndLaunchPlatformApp("minimal");
ASSERT_TRUE(extension); ASSERT_TRUE(extension);
@ -49,7 +49,7 @@ IN_PROC_BROWSER_TEST_F(AudioFocusWebContentsObserverBrowserTest,
EXPECT_NE(base::UnguessableToken::Null(), GetAudioFocusGroupId(web_contents)); EXPECT_NE(base::UnguessableToken::Null(), GetAudioFocusGroupId(web_contents));
// Create a new window and navigate it to the test app. // Create a new window and navigate it to the test app.
ExtensionTestMessageListener new_launched_listener("Launched", false); ExtensionTestMessageListener new_launched_listener("Launched");
LaunchPlatformApp(extension); LaunchPlatformApp(extension);
ASSERT_TRUE(new_launched_listener.WaitUntilSatisfied()); ASSERT_TRUE(new_launched_listener.WaitUntilSatisfied());

@ -134,7 +134,7 @@ void PlatformAppNavigationRedirectorBrowserTest::TestNavigationInTab(
InstallPlatformApp(handler); InstallPlatformApp(handler);
ExtensionTestMessageListener handler_listener(handler_start_message, false); ExtensionTestMessageListener handler_listener(handler_start_message);
ASSERT_TRUE(ui_test_utils::NavigateToURL( ASSERT_TRUE(ui_test_utils::NavigateToURL(
browser(), embedded_test_server()->GetURL(base::StringPrintf( browser(), embedded_test_server()->GetURL(base::StringPrintf(
@ -201,7 +201,7 @@ void PlatformAppNavigationRedirectorBrowserTest::TestNavigationInApp(
InstallPlatformApp(handler); InstallPlatformApp(handler);
ExtensionTestMessageListener handler_listener(handler_start_message, false); ExtensionTestMessageListener handler_listener(handler_start_message);
LoadAndLaunchPlatformApp(launcher, launcher_done_message); LoadAndLaunchPlatformApp(launcher, launcher_done_message);
@ -254,7 +254,7 @@ void PlatformAppNavigationRedirectorBrowserTest::TestNavigationInBrowser(
InstallPlatformApp(handler); InstallPlatformApp(handler);
ExtensionTestMessageListener handler_listener(handler_start_message, false); ExtensionTestMessageListener handler_listener(handler_start_message);
NavigateParams params( NavigateParams params(
browser(), browser(),