| 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 |
| 64 namespace { | 84 namespace { |
| 65 bool DecodePNG(std::string base64_data, SkBitmap* bitmap) { | 85 bool DecodePNG(std::string base64_data, SkBitmap* bitmap) { |
| 66 std::string png_data; | 86 std::string png_data; |
| 67 if (!base::Base64Decode(base64_data, &png_data)) | 87 if (!base::Base64Decode(base64_data, &png_data)) |
| 68 return false; | 88 return false; |
| 69 return gfx::PNGCodec::Decode( | 89 return gfx::PNGCodec::Decode( |
| 70 reinterpret_cast<unsigned const char*>(png_data.data()), png_data.size(), | 90 reinterpret_cast<unsigned const char*>(png_data.data()), png_data.size(), |
| 71 bitmap); | 91 bitmap); |
| 72 } | 92 } |
| 73 } // namespace | 93 } // namespace |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 devtools_client_->GetSecurity()->GetExperimental()->Disable( | 162 devtools_client_->GetSecurity()->GetExperimental()->Disable( |
| 143 security::DisableParams::Builder().Build()); | 163 security::DisableParams::Builder().Build()); |
| 144 devtools_client_->GetSecurity()->GetExperimental()->RemoveObserver(this); | 164 devtools_client_->GetSecurity()->GetExperimental()->RemoveObserver(this); |
| 145 FinishAsynchronousTest(); | 165 FinishAsynchronousTest(); |
| 146 } | 166 } |
| 147 }; | 167 }; |
| 148 | 168 |
| 149 HEADLESS_ASYNC_DEVTOOLED_TEST_F(HeadlessWebContentsSecurityTest); | 169 HEADLESS_ASYNC_DEVTOOLED_TEST_F(HeadlessWebContentsSecurityTest); |
| 150 | 170 |
| 151 } // namespace headless | 171 } // namespace headless |
| OLD | NEW |