Chromium Code Reviews| Index: headless/lib/headless_web_contents_browsertest.cc |
| diff --git a/headless/lib/headless_web_contents_browsertest.cc b/headless/lib/headless_web_contents_browsertest.cc |
| index 693e2dceeaa7ce9a1e380914e119a2923fabe70c..22e387752852b8402d05449dccb1db3ac146e275 100644 |
| --- a/headless/lib/headless_web_contents_browsertest.cc |
| +++ b/headless/lib/headless_web_contents_browsertest.cc |
| @@ -61,6 +61,38 @@ IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, WindowOpen) { |
| browser_context->GetAllWebContents().size()); |
| } |
| +IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, Focus) { |
| + EXPECT_TRUE(embedded_test_server()->Start()); |
| + |
| + HeadlessBrowserContext* browser_context = |
| + browser()->CreateBrowserContextBuilder().Build(); |
| + |
| + HeadlessWebContents* web_contents = |
| + browser_context->CreateWebContentsBuilder() |
| + .SetInitialURL(embedded_test_server()->GetURL("/hello.html")) |
| + .Build(); |
| + EXPECT_TRUE(WaitForLoad(web_contents)); |
| + |
| + bool result; |
| + EXPECT_TRUE(EvaluateScript(web_contents, "document.hasFocus()") |
| + ->GetResult() |
| + ->GetValue() |
| + ->GetAsBoolean(&result)); |
| + EXPECT_TRUE(result); |
| + |
| + HeadlessWebContents* web_contents2 = |
| + browser_context->CreateWebContentsBuilder() |
| + .SetInitialURL(embedded_test_server()->GetURL("/hello.html")) |
| + .Build(); |
| + EXPECT_TRUE(WaitForLoad(web_contents2)); |
| + |
| + EXPECT_TRUE(EvaluateScript(web_contents, "document.hasFocus()") |
|
Eric Seckler
2017/02/22 09:00:04
nit: Let's add a todo here - focus of two web cont
irisu
2017/02/23 00:02:26
Done.
|
| + ->GetResult() |
| + ->GetValue() |
| + ->GetAsBoolean(&result)); |
| + EXPECT_FALSE(result); |
| +} |
| + |
| namespace { |
| bool DecodePNG(std::string base64_data, SkBitmap* bitmap) { |
| std::string png_data; |