Chromium Code Reviews| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/singleton.h" | 6 #include "base/memory/singleton.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
| 12 #include "content/browser/browser_plugin/browser_plugin_embedder.h" | 12 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
| 13 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 13 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 14 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | 14 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
| 15 #include "content/browser/browser_plugin/test_browser_plugin_guest.h" | 15 #include "content/browser/browser_plugin/test_browser_plugin_guest.h" |
| 16 #include "content/browser/browser_plugin/test_browser_plugin_guest_delegate.h" | 16 #include "content/browser/browser_plugin/test_browser_plugin_guest_delegate.h" |
| 17 #include "content/browser/browser_plugin/test_guest_manager_delegate.h" | 17 #include "content/browser/browser_plugin/test_guest_manager.h" |
| 18 #include "content/browser/child_process_security_policy_impl.h" | 18 #include "content/browser/child_process_security_policy_impl.h" |
| 19 #include "content/browser/frame_host/render_frame_host_impl.h" | 19 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 20 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 20 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
| 21 #include "content/browser/renderer_host/render_view_host_impl.h" | 21 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 22 #include "content/browser/web_contents/web_contents_impl.h" | 22 #include "content/browser/web_contents/web_contents_impl.h" |
| 23 #include "content/common/browser_plugin/browser_plugin_messages.h" | 23 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 24 #include "content/common/view_messages.h" | 24 #include "content/common/view_messages.h" |
| 25 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
| 26 #include "content/public/browser/notification_types.h" | 26 #include "content/public/browser/notification_types.h" |
| 27 #include "content/public/browser/render_frame_host.h" | 27 #include "content/public/browser/render_frame_host.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 bool is_guest_data_url, | 259 bool is_guest_data_url, |
| 260 const std::string& embedder_code) { | 260 const std::string& embedder_code) { |
| 261 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 261 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 262 GURL test_url(embedded_test_server()->GetURL(embedder_url)); | 262 GURL test_url(embedded_test_server()->GetURL(embedder_url)); |
| 263 NavigateToURL(shell(), test_url); | 263 NavigateToURL(shell(), test_url); |
| 264 | 264 |
| 265 WebContentsImpl* embedder_web_contents = static_cast<WebContentsImpl*>( | 265 WebContentsImpl* embedder_web_contents = static_cast<WebContentsImpl*>( |
| 266 shell()->web_contents()); | 266 shell()->web_contents()); |
| 267 static_cast<ShellBrowserContext*>( | 267 static_cast<ShellBrowserContext*>( |
| 268 embedder_web_contents->GetBrowserContext())-> | 268 embedder_web_contents->GetBrowserContext())-> |
| 269 set_guest_manager_delegate_for_testing( | 269 set_guest_manager_for_testing( |
| 270 TestGuestManagerDelegate::GetInstance()); | 270 TestGuestManager::GetInstance()); |
| 271 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 271 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 272 embedder_web_contents->GetRenderViewHost()); | 272 embedder_web_contents->GetRenderViewHost()); |
| 273 RenderFrameHost* rfh = embedder_web_contents->GetMainFrame(); | 273 RenderFrameHost* rfh = embedder_web_contents->GetMainFrame(); |
| 274 // Focus the embedder. | 274 // Focus the embedder. |
| 275 rvh->Focus(); | 275 rvh->Focus(); |
| 276 // Activative IME. | 276 // Activative IME. |
| 277 rvh->SetInputMethodActive(true); | 277 rvh->SetInputMethodActive(true); |
| 278 | 278 |
| 279 // Allow the test to do some operations on the embedder before we perform | 279 // Allow the test to do some operations on the embedder before we perform |
| 280 // the first navigation of the guest. | 280 // the first navigation of the guest. |
| 281 if (!embedder_code.empty()) | 281 if (!embedder_code.empty()) |
| 282 ExecuteSyncJSFunction(rfh, embedder_code); | 282 ExecuteSyncJSFunction(rfh, embedder_code); |
| 283 | 283 |
| 284 if (!is_guest_data_url) { | 284 if (!is_guest_data_url) { |
| 285 test_url = embedded_test_server()->GetURL(guest_url); | 285 test_url = embedded_test_server()->GetURL(guest_url); |
| 286 ExecuteSyncJSFunction( | 286 ExecuteSyncJSFunction( |
| 287 rfh, base::StringPrintf("SetSrc('%s');", test_url.spec().c_str())); | 287 rfh, base::StringPrintf("SetSrc('%s');", test_url.spec().c_str())); |
| 288 } else { | 288 } else { |
| 289 ExecuteSyncJSFunction( | 289 ExecuteSyncJSFunction( |
| 290 rfh, base::StringPrintf("SetSrc('%s');", guest_url.c_str())); | 290 rfh, base::StringPrintf("SetSrc('%s');", guest_url.c_str())); |
| 291 } | 291 } |
| 292 | 292 |
| 293 test_embedder_ = static_cast<TestBrowserPluginEmbedder*>( | 293 test_embedder_ = static_cast<TestBrowserPluginEmbedder*>( |
| 294 embedder_web_contents->GetBrowserPluginEmbedder()); | 294 embedder_web_contents->GetBrowserPluginEmbedder()); |
| 295 ASSERT_TRUE(test_embedder_); | 295 ASSERT_TRUE(test_embedder_); |
| 296 | 296 |
| 297 test_guest_manager_ = | 297 test_guest_manager_ = |
| 298 static_cast<TestGuestManagerDelegate*>( | 298 static_cast<TestGuestManager*>( |
| 299 embedder_web_contents->GetBrowserContext()-> | 299 embedder_web_contents->GetBrowserContext()-> |
| 300 GetGuestManagerDelegate()); | 300 GetGuestManager()); |
|
lazyboy
2014/05/05 21:47:46
Should fit in previous line.
Fady Samuel
2014/05/07 19:01:51
Done.
| |
| 301 | 301 |
| 302 WebContentsImpl* test_guest_web_contents = | 302 WebContentsImpl* test_guest_web_contents = |
| 303 test_guest_manager_->WaitForGuestAdded(); | 303 test_guest_manager_->WaitForGuestAdded(); |
| 304 | 304 |
| 305 test_guest_ = static_cast<TestBrowserPluginGuest*>( | 305 test_guest_ = static_cast<TestBrowserPluginGuest*>( |
| 306 test_guest_web_contents->GetBrowserPluginGuest()); | 306 test_guest_web_contents->GetBrowserPluginGuest()); |
| 307 test_guest_->WaitForLoadStop(); | 307 test_guest_->WaitForLoadStop(); |
| 308 } | 308 } |
| 309 | 309 |
| 310 TestBrowserPluginEmbedder* test_embedder() const { return test_embedder_; } | 310 TestBrowserPluginEmbedder* test_embedder() const { return test_embedder_; } |
| 311 TestBrowserPluginGuest* test_guest() const { return test_guest_; } | 311 TestBrowserPluginGuest* test_guest() const { return test_guest_; } |
| 312 TestGuestManagerDelegate* test_guest_manager() const { | 312 TestGuestManager* test_guest_manager() const { |
| 313 return test_guest_manager_; | 313 return test_guest_manager_; |
| 314 } | 314 } |
| 315 | 315 |
| 316 private: | 316 private: |
| 317 TestBrowserPluginEmbedder* test_embedder_; | 317 TestBrowserPluginEmbedder* test_embedder_; |
| 318 TestBrowserPluginGuest* test_guest_; | 318 TestBrowserPluginGuest* test_guest_; |
| 319 TestGuestManagerDelegate* test_guest_manager_; | 319 TestGuestManager* test_guest_manager_; |
| 320 DISALLOW_COPY_AND_ASSIGN(BrowserPluginHostTest); | 320 DISALLOW_COPY_AND_ASSIGN(BrowserPluginHostTest); |
| 321 }; | 321 }; |
| 322 | 322 |
| 323 // This test ensures that if guest isn't there and we resize the guest (from | 323 // This test ensures that if guest isn't there and we resize the guest (from |
| 324 // js), it remembers the size correctly. | 324 // js), it remembers the size correctly. |
| 325 // | 325 // |
| 326 // Initially we load an embedder with a guest without a src attribute (which has | 326 // Initially we load an embedder with a guest without a src attribute (which has |
| 327 // dimension 640x480), resize it to 100x200, and then we set the source to a | 327 // dimension 640x480), resize it to 100x200, and then we set the source to a |
| 328 // sample guest. In the end we verify that the correct size has been set. | 328 // sample guest. In the end we verify that the correct size has been set. |
| 329 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, NavigateAfterResize) { | 329 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, NavigateAfterResize) { |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 scoped_ptr<base::Value> value = | 1023 scoped_ptr<base::Value> value = |
| 1024 content::ExecuteScriptAndGetValue( | 1024 content::ExecuteScriptAndGetValue( |
| 1025 guest_rfh, "document.getElementById('input1').value"); | 1025 guest_rfh, "document.getElementById('input1').value"); |
| 1026 std::string actual_value; | 1026 std::string actual_value; |
| 1027 ASSERT_TRUE(value->GetAsString(&actual_value)); | 1027 ASSERT_TRUE(value->GetAsString(&actual_value)); |
| 1028 EXPECT_EQ(base::UTF16ToUTF8(expected_value), actual_value); | 1028 EXPECT_EQ(base::UTF16ToUTF8(expected_value), actual_value); |
| 1029 } | 1029 } |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 } // namespace content | 1032 } // namespace content |
| OLD | NEW |