| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "base/memory/singleton.h" | 5 #include "base/memory/singleton.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/browser/browser_plugin/browser_plugin_embedder.h" | 10 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 return test_guest_manager_; | 223 return test_guest_manager_; |
| 224 } | 224 } |
| 225 | 225 |
| 226 private: | 226 private: |
| 227 TestBrowserPluginEmbedder* test_embedder_; | 227 TestBrowserPluginEmbedder* test_embedder_; |
| 228 TestBrowserPluginGuest* test_guest_; | 228 TestBrowserPluginGuest* test_guest_; |
| 229 TestGuestManager* test_guest_manager_; | 229 TestGuestManager* test_guest_manager_; |
| 230 DISALLOW_COPY_AND_ASSIGN(BrowserPluginHostTest); | 230 DISALLOW_COPY_AND_ASSIGN(BrowserPluginHostTest); |
| 231 }; | 231 }; |
| 232 | 232 |
| 233 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AdvanceFocus) { | |
| 234 const char kEmbedderURL[] = "/browser_plugin_focus.html"; | |
| 235 const char* kGuestURL = "/browser_plugin_focus_child.html"; | |
| 236 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, std::string()); | |
| 237 | |
| 238 SimulateMouseClick(test_embedder()->web_contents(), 0, | |
| 239 blink::WebMouseEvent::ButtonLeft); | |
| 240 BrowserPluginHostTest::SimulateTabKeyPress(test_embedder()->web_contents()); | |
| 241 // Wait until we focus into the guest. | |
| 242 test_guest()->WaitForFocus(); | |
| 243 | |
| 244 // TODO(fsamuel): A third Tab key press should not be necessary. | |
| 245 // The browser plugin will take keyboard focus but it will not | |
| 246 // focus an initial element. The initial element is dependent | |
| 247 // upon tab direction which WebKit does not propagate to the plugin. | |
| 248 // See http://crbug.com/147644. | |
| 249 BrowserPluginHostTest::SimulateTabKeyPress(test_embedder()->web_contents()); | |
| 250 BrowserPluginHostTest::SimulateTabKeyPress(test_embedder()->web_contents()); | |
| 251 BrowserPluginHostTest::SimulateTabKeyPress(test_embedder()->web_contents()); | |
| 252 test_guest()->WaitForAdvanceFocus(); | |
| 253 } | |
| 254 | |
| 255 // This test opens a page in http and then opens another page in https, forcing | 233 // This test opens a page in http and then opens another page in https, forcing |
| 256 // a RenderViewHost swap in the web_contents. We verify that the embedder in the | 234 // a RenderViewHost swap in the web_contents. We verify that the embedder in the |
| 257 // web_contents gets cleared properly. | 235 // web_contents gets cleared properly. |
| 258 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderChangedAfterSwap) { | 236 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderChangedAfterSwap) { |
| 259 net::SpawnedTestServer https_server( | 237 net::SpawnedTestServer https_server( |
| 260 net::SpawnedTestServer::TYPE_HTTPS, | 238 net::SpawnedTestServer::TYPE_HTTPS, |
| 261 net::SpawnedTestServer::kLocalhost, | 239 net::SpawnedTestServer::kLocalhost, |
| 262 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 240 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
| 263 ASSERT_TRUE(https_server.Start()); | 241 ASSERT_TRUE(https_server.Start()); |
| 264 | 242 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 rvh->DragTargetDragEnter(drop_data, gfx::Point(start_x, start_y), | 394 rvh->DragTargetDragEnter(drop_data, gfx::Point(start_x, start_y), |
| 417 gfx::Point(start_x, start_y), blink::WebDragOperationEvery, 0); | 395 gfx::Point(start_x, start_y), blink::WebDragOperationEvery, 0); |
| 418 rvh->DragTargetDragOver(gfx::Point(end_x, end_y), gfx::Point(end_x, end_y), | 396 rvh->DragTargetDragOver(gfx::Point(end_x, end_y), gfx::Point(end_x, end_y), |
| 419 blink::WebDragOperationEvery, 0); | 397 blink::WebDragOperationEvery, 0); |
| 420 rvh->DragTargetDrop(gfx::Point(end_x, end_y), gfx::Point(end_x, end_y), 0); | 398 rvh->DragTargetDrop(gfx::Point(end_x, end_y), gfx::Point(end_x, end_y), 0); |
| 421 | 399 |
| 422 base::string16 actual_title = title_watcher.WaitAndGetTitle(); | 400 base::string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 423 EXPECT_EQ(expected_title, actual_title); | 401 EXPECT_EQ(expected_title, actual_title); |
| 424 } | 402 } |
| 425 | 403 |
| 426 // This test verifies that if a browser plugin is hidden before navigation, | |
| 427 // the guest starts off hidden. | |
| 428 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, HiddenBeforeNavigation) { | |
| 429 const char* kEmbedderURL = "/browser_plugin_embedder.html"; | |
| 430 const std::string embedder_code = | |
| 431 "document.getElementById('plugin').style.visibility = 'hidden'"; | |
| 432 StartBrowserPluginTest( | |
| 433 kEmbedderURL, kHTMLForGuest, true, embedder_code); | |
| 434 EXPECT_FALSE(test_guest()->visible()); | |
| 435 } | |
| 436 | |
| 437 // This test verifies that if a browser plugin is focused before navigation then | |
| 438 // the guest starts off focused. | |
| 439 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusBeforeNavigation) { | |
| 440 const char* kEmbedderURL = "/browser_plugin_embedder.html"; | |
| 441 const std::string embedder_code = | |
| 442 "document.getElementById('plugin').focus();"; | |
| 443 StartBrowserPluginTest( | |
| 444 kEmbedderURL, kHTMLForGuest, true, embedder_code); | |
| 445 RenderFrameHost* guest_rfh = test_guest()->web_contents()->GetMainFrame(); | |
| 446 // Verify that the guest is focused. | |
| 447 scoped_ptr<base::Value> value = | |
| 448 content::ExecuteScriptAndGetValue(guest_rfh, "document.hasFocus()"); | |
| 449 bool result = false; | |
| 450 ASSERT_TRUE(value->GetAsBoolean(&result)); | |
| 451 EXPECT_TRUE(result); | |
| 452 } | |
| 453 | |
| 454 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusTracksEmbedder) { | |
| 455 const char* kEmbedderURL = "/browser_plugin_embedder.html"; | |
| 456 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); | |
| 457 // Blur the embedder. | |
| 458 test_embedder()->web_contents()->GetRenderViewHost()->Blur(); | |
| 459 // Ensure that the guest is also blurred. | |
| 460 test_guest()->WaitForBlur(); | |
| 461 } | |
| 462 | |
| 463 // This test verifies that if IME is enabled in the embedder, it is also enabled | 404 // This test verifies that if IME is enabled in the embedder, it is also enabled |
| 464 // in the guest. | 405 // in the guest. |
| 465 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, VerifyInputMethodActive) { | 406 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, VerifyInputMethodActive) { |
| 466 const char* kEmbedderURL = "/browser_plugin_embedder.html"; | 407 const char* kEmbedderURL = "/browser_plugin_embedder.html"; |
| 467 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); | 408 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 468 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 409 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 469 test_guest()->web_contents()->GetRenderViewHost()); | 410 test_guest()->web_contents()->GetRenderViewHost()); |
| 470 EXPECT_TRUE(rvh->input_method_active()); | 411 EXPECT_TRUE(rvh->input_method_active()); |
| 471 } | 412 } |
| 472 | 413 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 scoped_ptr<base::Value> value = | 564 scoped_ptr<base::Value> value = |
| 624 content::ExecuteScriptAndGetValue( | 565 content::ExecuteScriptAndGetValue( |
| 625 guest_rfh, "document.getElementById('input1').value"); | 566 guest_rfh, "document.getElementById('input1').value"); |
| 626 std::string actual_value; | 567 std::string actual_value; |
| 627 ASSERT_TRUE(value->GetAsString(&actual_value)); | 568 ASSERT_TRUE(value->GetAsString(&actual_value)); |
| 628 EXPECT_EQ(base::UTF16ToUTF8(expected_value), actual_value); | 569 EXPECT_EQ(base::UTF16ToUTF8(expected_value), actual_value); |
| 629 } | 570 } |
| 630 } | 571 } |
| 631 | 572 |
| 632 } // namespace content | 573 } // namespace content |
| OLD | NEW |