Commit 5ef2021e authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

Deflake headless WebContentsOpenTests

Bug: 1045980, 1078405, 1090936

Change-Id: I1a004c9fa0cdb5300bb94ce55a80ef3fffaace6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2417098
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarCollin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808082}
parent a7ed4e6a
...@@ -1163,7 +1163,10 @@ const char* kPageWhichOpensAWindow = R"( ...@@ -1163,7 +1163,10 @@ const char* kPageWhichOpensAWindow = R"(
<html> <html>
<body> <body>
<script> <script>
window.open('/page2.html'); const win = window.open('/page2.html');
if (!win)
console.error('ready');
win.addEventListener('load', () => console.log('ready'));
</script> </script>
</body> </body>
</html> </html>
...@@ -1178,18 +1181,18 @@ Page 2. ...@@ -1178,18 +1181,18 @@ Page 2.
)"; )";
} // namespace } // namespace
class WebContentsOpenTest : public page::Observer, class WebContentsOpenTest : public runtime::Observer,
public HeadlessAsyncDevTooledBrowserTest { public HeadlessAsyncDevTooledBrowserTest {
public: public:
void RunDevTooledTest() override { void RunDevTooledTest() override {
devtools_client_->GetPage()->AddObserver(this);
interceptor_->InsertResponse("http://foo.com/index.html", interceptor_->InsertResponse("http://foo.com/index.html",
{kPageWhichOpensAWindow, "text/html"}); {kPageWhichOpensAWindow, "text/html"});
interceptor_->InsertResponse("http://foo.com/page2.html", interceptor_->InsertResponse("http://foo.com/page2.html",
{kPage2, "text/html"}); {kPage2, "text/html"});
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed); base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
devtools_client_->GetPage()->Enable(run_loop.QuitClosure()); devtools_client_->GetRuntime()->AddObserver(this);
devtools_client_->GetRuntime()->Enable(run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
devtools_client_->GetPage()->Navigate("http://foo.com/index.html"); devtools_client_->GetPage()->Navigate("http://foo.com/index.html");
...@@ -1203,7 +1206,8 @@ class DontBlockWebContentsOpenTest : public WebContentsOpenTest { ...@@ -1203,7 +1206,8 @@ class DontBlockWebContentsOpenTest : public WebContentsOpenTest {
builder.SetBlockNewWebContents(false); builder.SetBlockNewWebContents(false);
} }
void OnLoadEventFired(const page::LoadEventFiredParams&) override { void OnConsoleAPICalled(
const runtime::ConsoleAPICalledParams& params) override {
EXPECT_THAT( EXPECT_THAT(
interceptor_->urls_requested(), interceptor_->urls_requested(),
ElementsAre("http://foo.com/index.html", "http://foo.com/page2.html")); ElementsAre("http://foo.com/index.html", "http://foo.com/page2.html"));
...@@ -1211,10 +1215,7 @@ class DontBlockWebContentsOpenTest : public WebContentsOpenTest { ...@@ -1211,10 +1215,7 @@ class DontBlockWebContentsOpenTest : public WebContentsOpenTest {
} }
}; };
// TODO(crbug.com/1045980): Disabled due to flakiness. HEADLESS_ASYNC_DEVTOOLED_TEST_F(DontBlockWebContentsOpenTest);
// TODO(crbug.com/1078405): Disabled due to flakiness.
// TODO(crbug.com/1090936): Disabled due to flakiness.
DISABLED_HEADLESS_ASYNC_DEVTOOLED_TEST_F(DontBlockWebContentsOpenTest);
class BlockWebContentsOpenTest : public WebContentsOpenTest { class BlockWebContentsOpenTest : public WebContentsOpenTest {
public: public:
...@@ -1223,18 +1224,14 @@ class BlockWebContentsOpenTest : public WebContentsOpenTest { ...@@ -1223,18 +1224,14 @@ class BlockWebContentsOpenTest : public WebContentsOpenTest {
builder.SetBlockNewWebContents(true); builder.SetBlockNewWebContents(true);
} }
void OnLoadEventFired(const page::LoadEventFiredParams&) override { void OnConsoleAPICalled(
const runtime::ConsoleAPICalledParams& params) override {
EXPECT_THAT(interceptor_->urls_requested(), EXPECT_THAT(interceptor_->urls_requested(),
ElementsAre("http://foo.com/index.html")); ElementsAre("http://foo.com/index.html"));
FinishAsynchronousTest(); FinishAsynchronousTest();
} }
}; };
#if defined(OS_WIN)
// TODO(crbug.com/1045980): Disabled due to flakiness.
DISABLED_HEADLESS_ASYNC_DEVTOOLED_TEST_F(BlockWebContentsOpenTest);
#else
HEADLESS_ASYNC_DEVTOOLED_TEST_F(BlockWebContentsOpenTest); HEADLESS_ASYNC_DEVTOOLED_TEST_F(BlockWebContentsOpenTest);
#endif
} // namespace headless } // namespace headless
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