Commit b8a1c61d authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

De-flake WebClipboardImplTests

The issue was raciness between navigation and FrameFocusedObserver
setup. Focus can be dispatched to the FrameTreeNode before
NavigateToURL* returns, causing the subsequently constructed
FrameFocusedObserver to wait forever for an event that has already
happened.

Because FrameFocusedObserver only monitors the main frame's
FrameTreeNode, which is stable, we can construct the observer before
NavigateToURL*. That's what all this does.

Bug: 872075,867339
Change-Id: I08c68ecb548163ee2097222d549e6985e5c9428a
Reviewed-on: https://chromium-review.googlesource.com/1173016Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582813}
parent 1a9c3607
......@@ -22,21 +22,15 @@ class WebClipboardImplTest : public ContentBrowserTest {
~WebClipboardImplTest() override = default;
};
#if defined(OS_CHROMEOS)
// Test is flaky on ChromeOS (https://crbug.com/867339).
#define MAYBE_PasteRTF DISABLED_PasteRTF
#else
#define MAYBE_PasteRTF PasteRTF
#endif
IN_PROC_BROWSER_TEST_F(WebClipboardImplTest, MAYBE_PasteRTF) {
IN_PROC_BROWSER_TEST_F(WebClipboardImplTest, PasteRTF) {
BrowserTestClipboardScope clipboard;
const std::string rtf_content = "{\\rtf1\\ansi Hello, {\\b world.}}";
clipboard.SetRtf(rtf_content);
FrameFocusedObserver focus_observer(shell()->web_contents()->GetMainFrame());
// paste_listener.html takes RTF from the clipboard and sets the title.
NavigateToURL(shell(), GetTestUrl(".", "paste_listener.html"));
FrameFocusedObserver focus_observer(shell()->web_contents()->GetMainFrame());
focus_observer.Wait();
const base::string16 expected_title = base::UTF8ToUTF16(rtf_content);
......@@ -45,22 +39,16 @@ IN_PROC_BROWSER_TEST_F(WebClipboardImplTest, MAYBE_PasteRTF) {
EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
}
#if (defined(OS_CHROMEOS) && !defined(NDEBUG)) || defined(OS_MACOSX)
// Test is flaky on ChromeOS (dbg) and mac (https://crbug.com/867954).
#define MAYBE_ImageCopy DISABLED_ImageCopy
#else
#define MAYBE_ImageCopy ImageCopy
#endif
IN_PROC_BROWSER_TEST_F(WebClipboardImplTest, MAYBE_ImageCopy) {
IN_PROC_BROWSER_TEST_F(WebClipboardImplTest, ImageCopy) {
BrowserTestClipboardScope clipboard;
clipboard.SetText("");
base::string16 expected_types;
expected_types = base::ASCIIToUTF16("file;image/png string;text/html");
NavigateToURL(shell(), GetTestUrl(".", "image_copy_types.html"));
WebContents* web_contents = shell()->web_contents();
FrameFocusedObserver focus_observer(web_contents->GetMainFrame());
NavigateToURL(shell(), GetTestUrl(".", "image_copy_types.html"));
focus_observer.Wait();
// Populate an iframe with an image, and wait for load to complete.
......
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