Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "content/public/test/browser_test.h" | 10 #include "content/public/test/browser_test.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 HeadlessWebContents* web_contents = | 54 HeadlessWebContents* web_contents = |
| 55 browser_context->CreateWebContentsBuilder() | 55 browser_context->CreateWebContentsBuilder() |
| 56 .SetInitialURL(embedded_test_server()->GetURL("/window_open.html")) | 56 .SetInitialURL(embedded_test_server()->GetURL("/window_open.html")) |
| 57 .Build(); | 57 .Build(); |
| 58 EXPECT_TRUE(WaitForLoad(web_contents)); | 58 EXPECT_TRUE(WaitForLoad(web_contents)); |
| 59 | 59 |
| 60 EXPECT_EQ(static_cast<size_t>(2), | 60 EXPECT_EQ(static_cast<size_t>(2), |
| 61 browser_context->GetAllWebContents().size()); | 61 browser_context->GetAllWebContents().size()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, Focus) { | |
| 65 EXPECT_TRUE(embedded_test_server()->Start()); | |
| 66 | |
| 67 HeadlessBrowserContext* browser_context = | |
| 68 browser()->CreateBrowserContextBuilder().Build(); | |
| 69 | |
| 70 HeadlessWebContents* web_contents = | |
| 71 browser_context->CreateWebContentsBuilder() | |
| 72 .SetInitialURL(embedded_test_server()->GetURL("/hello.html")) | |
| 73 .Build(); | |
| 74 EXPECT_TRUE(WaitForLoad(web_contents)); | |
| 75 | |
| 76 bool result; | |
| 77 EXPECT_TRUE(EvaluateScript(web_contents, "document.hasFocus()") | |
| 78 ->GetResult() | |
| 79 ->GetValue() | |
| 80 ->GetAsBoolean(&result)); | |
| 81 EXPECT_TRUE(result); | |
| 82 | |
| 83 HeadlessWebContents* web_contents2 = | |
| 84 browser_context->CreateWebContentsBuilder() | |
| 85 .SetInitialURL(embedded_test_server()->GetURL("/hello.html")) | |
| 86 .Build(); | |
| 87 EXPECT_TRUE(WaitForLoad(web_contents2)); | |
| 88 | |
| 89 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.
| |
| 90 ->GetResult() | |
| 91 ->GetValue() | |
| 92 ->GetAsBoolean(&result)); | |
| 93 EXPECT_FALSE(result); | |
| 94 } | |
| 95 | |
| 64 namespace { | 96 namespace { |
| 65 bool DecodePNG(std::string base64_data, SkBitmap* bitmap) { | 97 bool DecodePNG(std::string base64_data, SkBitmap* bitmap) { |
| 66 std::string png_data; | 98 std::string png_data; |
| 67 if (!base::Base64Decode(base64_data, &png_data)) | 99 if (!base::Base64Decode(base64_data, &png_data)) |
| 68 return false; | 100 return false; |
| 69 return gfx::PNGCodec::Decode( | 101 return gfx::PNGCodec::Decode( |
| 70 reinterpret_cast<unsigned const char*>(png_data.data()), png_data.size(), | 102 reinterpret_cast<unsigned const char*>(png_data.data()), png_data.size(), |
| 71 bitmap); | 103 bitmap); |
| 72 } | 104 } |
| 73 } // namespace | 105 } // namespace |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 devtools_client_->GetSecurity()->GetExperimental()->Disable( | 174 devtools_client_->GetSecurity()->GetExperimental()->Disable( |
| 143 security::DisableParams::Builder().Build()); | 175 security::DisableParams::Builder().Build()); |
| 144 devtools_client_->GetSecurity()->GetExperimental()->RemoveObserver(this); | 176 devtools_client_->GetSecurity()->GetExperimental()->RemoveObserver(this); |
| 145 FinishAsynchronousTest(); | 177 FinishAsynchronousTest(); |
| 146 } | 178 } |
| 147 }; | 179 }; |
| 148 | 180 |
| 149 HEADLESS_ASYNC_DEVTOOLED_TEST_F(HeadlessWebContentsSecurityTest); | 181 HEADLESS_ASYNC_DEVTOOLED_TEST_F(HeadlessWebContentsSecurityTest); |
| 150 | 182 |
| 151 } // namespace headless | 183 } // namespace headless |
| OLD | NEW |