| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   79                   ->GetValue() |   79                   ->GetValue() | 
|   80                   ->GetAsBoolean(&result)); |   80                   ->GetAsBoolean(&result)); | 
|   81   EXPECT_TRUE(result); |   81   EXPECT_TRUE(result); | 
|   82  |   82  | 
|   83   HeadlessWebContents* web_contents2 = |   83   HeadlessWebContents* web_contents2 = | 
|   84       browser_context->CreateWebContentsBuilder() |   84       browser_context->CreateWebContentsBuilder() | 
|   85           .SetInitialURL(embedded_test_server()->GetURL("/hello.html")) |   85           .SetInitialURL(embedded_test_server()->GetURL("/hello.html")) | 
|   86           .Build(); |   86           .Build(); | 
|   87   EXPECT_TRUE(WaitForLoad(web_contents2)); |   87   EXPECT_TRUE(WaitForLoad(web_contents2)); | 
|   88  |   88  | 
|   89   // Focus of different WebContents is independent. |   89   // TODO(irisu): Focus of two web contents should be independent of the other. | 
 |   90   // Both web_contents and web_contents2 should be focused at this point. | 
 |   91   // NOTE(dvallet): Mac headless implementation already does this. | 
|   90   EXPECT_TRUE(EvaluateScript(web_contents, "document.hasFocus()") |   92   EXPECT_TRUE(EvaluateScript(web_contents, "document.hasFocus()") | 
|   91                   ->GetResult() |   93                   ->GetResult() | 
|   92                   ->GetValue() |   94                   ->GetValue() | 
|   93                   ->GetAsBoolean(&result)); |   95                   ->GetAsBoolean(&result)); | 
 |   96 #if !defined(OS_MACOSX) | 
 |   97   EXPECT_FALSE(result); | 
 |   98 #else | 
 |   99   // Mac sets all contents as focused. | 
|   94   EXPECT_TRUE(result); |  100   EXPECT_TRUE(result); | 
 |  101 #endif | 
|   95   EXPECT_TRUE(EvaluateScript(web_contents2, "document.hasFocus()") |  102   EXPECT_TRUE(EvaluateScript(web_contents2, "document.hasFocus()") | 
|   96                   ->GetResult() |  103                   ->GetResult() | 
|   97                   ->GetValue() |  104                   ->GetValue() | 
|   98                   ->GetAsBoolean(&result)); |  105                   ->GetAsBoolean(&result)); | 
|   99   EXPECT_TRUE(result); |  106   EXPECT_TRUE(result); | 
|  100 } |  107 } | 
|  101  |  108  | 
|  102 namespace { |  109 namespace { | 
|  103 bool DecodePNG(std::string base64_data, SkBitmap* bitmap) { |  110 bool DecodePNG(std::string base64_data, SkBitmap* bitmap) { | 
|  104   std::string png_data; |  111   std::string png_data; | 
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  180     devtools_client_->GetSecurity()->GetExperimental()->Disable( |  187     devtools_client_->GetSecurity()->GetExperimental()->Disable( | 
|  181         security::DisableParams::Builder().Build()); |  188         security::DisableParams::Builder().Build()); | 
|  182     devtools_client_->GetSecurity()->GetExperimental()->RemoveObserver(this); |  189     devtools_client_->GetSecurity()->GetExperimental()->RemoveObserver(this); | 
|  183     FinishAsynchronousTest(); |  190     FinishAsynchronousTest(); | 
|  184   } |  191   } | 
|  185 }; |  192 }; | 
|  186  |  193  | 
|  187 HEADLESS_ASYNC_DEVTOOLED_TEST_F(HeadlessWebContentsSecurityTest); |  194 HEADLESS_ASYNC_DEVTOOLED_TEST_F(HeadlessWebContentsSecurityTest); | 
|  188  |  195  | 
|  189 }  // namespace headless |  196 }  // namespace headless | 
| OLD | NEW |