Commit 66593c81 authored by Ehsan Karamad's avatar Ehsan Karamad Committed by Commit Bot

Make 'web_view_browsertest.cc' (almost) BrowserPlugin-free

The BrowserPlugin related tests in the file were to test features that
affect BP-based GuestViews; this only includes MimeHandlerViewGuest.

This CL moves one more such test to
'chrome_mime_handler_view_browsertest.cc'. This also involves adapting
the test such that it creates a MimeHandlerViewGuest instead of
WebViewGuest based on BrowserPlugin.

The last remaining test in 'web_view_browsertest.cc' will be removed and
adapted in a followup CL (to make sure the process is easily reversible
in case the new tests end up having issues on bots).

Bug: 553069, 330264
Change-Id: Iaa7ba33189ecb8b23e8489dab8e9b2b5e378a9be
Reviewed-on: https://chromium-review.googlesource.com/1217147Reviewed-by: default avatarJames MacLean <wjmaclean@chromium.org>
Reviewed-by: default avatarEhsan Karamad <ekaramad@chromium.org>
Commit-Queue: Ehsan Karamad <ekaramad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590372}
parent 53a4eba9
...@@ -3977,97 +3977,6 @@ IN_PROC_BROWSER_TEST_P(WebViewGuestScrollTest, ...@@ -3977,97 +3977,6 @@ IN_PROC_BROWSER_TEST_P(WebViewGuestScrollTest,
guest_frame_observer.WaitForScrollOffset(default_offset); guest_frame_observer.WaitForScrollOffset(default_offset);
} }
#if defined(USE_AURA)
class WebViewGuestTouchFocusBrowserPluginSpecificTest
: public WebViewBrowserPluginSpecificTest {
public:
WebViewGuestTouchFocusBrowserPluginSpecificTest() {}
void SetUpCommandLine(base::CommandLine* command_line) override {
WebViewBrowserPluginSpecificTest::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(
switches::kTouchEventFeatureDetection,
switches::kTouchEventFeatureDetectionEnabled);
}
private:
DISALLOW_COPY_AND_ASSIGN(WebViewGuestTouchFocusBrowserPluginSpecificTest);
};
class FocusChangeWaiter {
public:
explicit FocusChangeWaiter(content::WebContents* web_contents,
bool expected_focus)
: web_contents_(web_contents), expected_focus_(expected_focus) {}
~FocusChangeWaiter() {}
void WaitForFocusChange() {
while (expected_focus_ !=
IsWebContentsBrowserPluginFocused(web_contents_)) {
base::RunLoop().RunUntilIdle();
}
}
private:
content::WebContents* web_contents_;
bool expected_focus_;
};
IN_PROC_BROWSER_TEST_F(WebViewGuestTouchFocusBrowserPluginSpecificTest,
TouchFocusesBrowserPluginInEmbedder) {
// This test is only relevant for non-OOPIF WebView.
ASSERT_FALSE(
base::FeatureList::IsEnabled(::features::kGuestViewCrossProcessFrames));
LoadAppWithGuest("web_view/guest_focus_test");
// Lookup relevant information about guest and embedder.
content::WebContents* embedder_contents = GetEmbedderWebContents();
std::vector<content::WebContents*> guest_web_contents_list;
GetGuestViewManager()->WaitForNumGuestsCreated(1u);
GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list);
ASSERT_EQ(1u, guest_web_contents_list.size());
content::WebContents* guest_contents = guest_web_contents_list[0];
gfx::Rect embedder_rect = embedder_contents->GetContainerBounds();
gfx::Rect guest_rect = guest_contents->GetContainerBounds();
guest_rect.set_x(guest_rect.x() - embedder_rect.x());
guest_rect.set_y(guest_rect.y() - embedder_rect.y());
embedder_rect.set_x(0);
embedder_rect.set_y(0);
// Don't send events that need to be routed until we know the child's surface
// is ready for hit testing.
content::WaitForHitTestDataOrGuestSurfaceReady(guest_contents);
// 1) BrowserPlugin should not be focused at start.
EXPECT_FALSE(IsWebContentsBrowserPluginFocused(guest_contents));
// 2) Send touch event to guest, now BrowserPlugin should get focus.
{
gfx::Point point = guest_rect.CenterPoint();
FocusChangeWaiter focus_waiter(guest_contents, true);
SendRoutedTouchTapSequence(embedder_contents, point);
SendRoutedGestureTapSequence(embedder_contents, point);
focus_waiter.WaitForFocusChange();
EXPECT_TRUE(IsWebContentsBrowserPluginFocused(guest_contents));
}
// 3) Send touch start to embedder, now BrowserPlugin should lose focus.
{
gfx::Point point(10, 10);
FocusChangeWaiter focus_waiter(guest_contents, false);
SendRoutedTouchTapSequence(embedder_contents, point);
SendRoutedGestureTapSequence(embedder_contents, point);
focus_waiter.WaitForFocusChange();
EXPECT_FALSE(IsWebContentsBrowserPluginFocused(guest_contents));
}
}
#endif
INSTANTIATE_TEST_CASE_P(WebViewScrollBubbling, INSTANTIATE_TEST_CASE_P(WebViewScrollBubbling,
WebViewGuestScrollTouchTest, WebViewGuestScrollTouchTest,
testing::Bool()); testing::Bool());
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
#include "content/public/test/hit_test_region_observer.h"
#include "content/public/test/test_renderer_host.h" #include "content/public/test/test_renderer_host.h"
#include "extensions/browser/api/extensions_api_client.h" #include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.h" #include "extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.h"
...@@ -131,6 +132,26 @@ class ChromeMimeHandlerViewBrowserPluginTest ...@@ -131,6 +132,26 @@ class ChromeMimeHandlerViewBrowserPluginTest
DISALLOW_COPY_AND_ASSIGN(ChromeMimeHandlerViewBrowserPluginTest); DISALLOW_COPY_AND_ASSIGN(ChromeMimeHandlerViewBrowserPluginTest);
}; };
// Helper class to monitor focus on a WebContents with BrowserPlugin (guest).
class FocusChangeWaiter {
public:
explicit FocusChangeWaiter(content::WebContents* web_contents,
bool expected_focus)
: web_contents_(web_contents), expected_focus_(expected_focus) {}
~FocusChangeWaiter() {}
void WaitForFocusChange() {
while (expected_focus_ !=
IsWebContentsBrowserPluginFocused(web_contents_)) {
base::RunLoop().RunUntilIdle();
}
}
private:
content::WebContents* web_contents_;
bool expected_focus_;
};
// Flaky under MSan: https://crbug.com/837757 // Flaky under MSan: https://crbug.com/837757
#if defined(MEMORY_SANITIZER) #if defined(MEMORY_SANITIZER)
#define MAYBE_BP_AutoResizeMessages DISABLED_AutoResizeMessages #define MAYBE_BP_AutoResizeMessages DISABLED_AutoResizeMessages
...@@ -255,6 +276,49 @@ IN_PROC_BROWSER_TEST_F(ChromeMimeHandlerViewBrowserPluginTest, ...@@ -255,6 +276,49 @@ IN_PROC_BROWSER_TEST_F(ChromeMimeHandlerViewBrowserPluginTest,
waiter.Wait(); waiter.Wait();
EXPECT_TRUE(aura_webview->HasFocus()); EXPECT_TRUE(aura_webview->HasFocus());
} }
IN_PROC_BROWSER_TEST_F(ChromeMimeHandlerViewBrowserPluginTest,
TouchFocusesBrowserPluginInEmbedder) {
InitializeTestPage(embedded_test_server()->GetURL("/test_embedded.html"));
auto embedder_rect = embedder_web_contents()->GetContainerBounds();
auto guest_rect = guest_web_contents()->GetContainerBounds();
guest_rect.set_x(guest_rect.x() - embedder_rect.x());
guest_rect.set_y(guest_rect.y() - embedder_rect.y());
embedder_rect.set_x(0);
embedder_rect.set_y(0);
// Don't send events that need to be routed until we know the child's surface
// is ready for hit testing.
content::WaitForHitTestDataOrGuestSurfaceReady(guest_web_contents());
// 1) BrowserPlugin should not be focused at start.
ASSERT_FALSE(IsWebContentsBrowserPluginFocused(guest_web_contents()));
// 2) Send touch event to guest, now BrowserPlugin should get focus.
{
gfx::Point point = guest_rect.CenterPoint();
FocusChangeWaiter focus_waiter(guest_web_contents(), true);
SendRoutedTouchTapSequence(embedder_web_contents(), point);
SendRoutedGestureTapSequence(embedder_web_contents(), point);
focus_waiter.WaitForFocusChange();
ASSERT_TRUE(IsWebContentsBrowserPluginFocused(guest_web_contents()));
}
// 3) Send touch start to embedder, now BrowserPlugin should lose focus.
{
// Choose a point outside of guest (but inside the embedder).
gfx::Point point = guest_rect.bottom_right();
point += gfx::Vector2d(10, 10);
EXPECT_TRUE(embedder_rect.Contains(point));
FocusChangeWaiter focus_waiter(guest_web_contents(), false);
SendRoutedTouchTapSequence(embedder_web_contents(), point);
SendRoutedGestureTapSequence(embedder_web_contents(), point);
focus_waiter.WaitForFocusChange();
ASSERT_FALSE(IsWebContentsBrowserPluginFocused(guest_web_contents()));
}
}
#endif // USE_AURA #endif // USE_AURA
class ChromeMimeHandlerViewBrowserPluginScrollTest class ChromeMimeHandlerViewBrowserPluginScrollTest
......
...@@ -183,7 +183,7 @@ ...@@ -183,7 +183,7 @@
# content::WaitForChildFrameSurfaceReady hangs. # content::WaitForChildFrameSurfaceReady hangs.
-SitePerProcessDevToolsSanityTest.InputDispatchEventsToOOPIF -SitePerProcessDevToolsSanityTest.InputDispatchEventsToOOPIF
-WebViewGuestTouchFocusBrowserPluginSpecificTest.TouchFocusesBrowserPluginInEmbedder -ChromeMimeHandlerViewBrowserPluginTest.TouchFocusesBrowserPluginInEmbedder
# Function under test uses ash::Shell for window list. # Function under test uses ash::Shell for window list.
-SortWindowsByZIndexBrowserTest.* -SortWindowsByZIndexBrowserTest.*
......
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
-WebViewScrollBubbling/WebViewGuestScrollTest.TestGuestWheelScrollsBubble/* -WebViewScrollBubbling/WebViewGuestScrollTest.TestGuestWheelScrollsBubble/*
# FATAL:hit_test_region_observer.cc(164)] Check failed: frame_sink_id.is_valid(). # FATAL:hit_test_region_observer.cc(164)] Check failed: frame_sink_id.is_valid().
-WebViewGuestTouchFocusBrowserPluginSpecificTest.TouchFocusesBrowserPluginInEmbedder -ChromeMimeHandlerViewBrowserPluginTest.TouchFocusesBrowserPluginInEmbedder
# Picture-in-Picture does not work with mash because VideoSurfaceLayer is # Picture-in-Picture does not work with mash because VideoSurfaceLayer is
# disabled. # disabled.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment