OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 12 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
13 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | 13 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
14 #include "content/browser/browser_plugin/test_browser_plugin_embedder.h" | 14 #include "content/browser/browser_plugin/test_browser_plugin_embedder.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_manager.h" | 16 #include "content/browser/browser_plugin/test_browser_plugin_guest_manager.h" |
| 17 #include "content/browser/child_process_security_policy_impl.h" |
17 #include "content/browser/renderer_host/render_view_host_impl.h" | 18 #include "content/browser/renderer_host/render_view_host_impl.h" |
18 #include "content/browser/web_contents/web_contents_impl.h" | 19 #include "content/browser/web_contents/web_contents_impl.h" |
19 #include "content/common/view_messages.h" | 20 #include "content/common/view_messages.h" |
20 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
21 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
22 #include "content/public/browser/render_view_host_observer.h" | 23 #include "content/public/browser/render_view_host_observer.h" |
23 #include "content/public/browser/render_widget_host_view.h" | 24 #include "content/public/browser/render_widget_host_view.h" |
24 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
25 #include "content/public/test/browser_test_utils.h" | 26 #include "content/public/test/browser_test_utils.h" |
26 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 test_embedder()->web_contents()->GetRenderViewHost()); | 849 test_embedder()->web_contents()->GetRenderViewHost()); |
849 GURL test_url = test_server()->GetURL("close-socket"); | 850 GURL test_url = test_server()->GetURL("close-socket"); |
850 ExecuteSyncJSFunction( | 851 ExecuteSyncJSFunction( |
851 rvh, base::StringPrintf("SetSrc('%s');", test_url.spec().c_str())); | 852 rvh, base::StringPrintf("SetSrc('%s');", test_url.spec().c_str())); |
852 string16 actual_title = title_watcher.WaitAndGetTitle(); | 853 string16 actual_title = title_watcher.WaitAndGetTitle(); |
853 EXPECT_EQ(expected_title, actual_title); | 854 EXPECT_EQ(expected_title, actual_title); |
854 } | 855 } |
855 | 856 |
856 { | 857 { |
857 // Navigate the guest to an illegal chrome:// URL. | 858 // Navigate the guest to an illegal chrome:// URL. |
| 859 GURL test_url("chrome://newtab"); |
| 860 ChildProcessSecurityPolicyImpl* policy = |
| 861 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 862 // Register chrome:// as a safe scheme so as to bypass |
| 863 // ChildProcessSecurityPolicyImpl::CanRequestURL(). |
| 864 if (!policy->IsWebSafeScheme(test_url.scheme())) |
| 865 policy->RegisterWebSafeScheme(test_url.scheme()); |
858 const string16 expected_title = ASCIIToUTF16("ERR_INVALID_URL"); | 866 const string16 expected_title = ASCIIToUTF16("ERR_INVALID_URL"); |
859 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 867 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
860 expected_title); | 868 expected_title); |
861 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 869 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
862 test_embedder()->web_contents()->GetRenderViewHost()); | 870 test_embedder()->web_contents()->GetRenderViewHost()); |
863 GURL test_url("chrome://newtab"); | |
864 ExecuteSyncJSFunction( | 871 ExecuteSyncJSFunction( |
865 rvh, base::StringPrintf("SetSrc('%s');", test_url.spec().c_str())); | 872 rvh, base::StringPrintf("SetSrc('%s');", test_url.spec().c_str())); |
866 string16 actual_title = title_watcher.WaitAndGetTitle(); | 873 string16 actual_title = title_watcher.WaitAndGetTitle(); |
867 EXPECT_EQ(expected_title, actual_title); | 874 EXPECT_EQ(expected_title, actual_title); |
868 } | 875 } |
869 | 876 |
870 { | 877 { |
871 // Navigate the guest to an illegal file:// URL. | 878 // Navigate the guest to an illegal file:// URL. |
872 const string16 expected_title = ASCIIToUTF16("ERR_ABORTED"); | 879 const string16 expected_title = ASCIIToUTF16("ERR_ABORTED"); |
873 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 880 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 const string16 expected_title = ASCIIToUTF16("AutoSize(640, 480)"); | 1409 const string16 expected_title = ASCIIToUTF16("AutoSize(640, 480)"); |
1403 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 1410 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
1404 expected_title); | 1411 expected_title); |
1405 RemoveAttributes(rvh, "maxwidth"); | 1412 RemoveAttributes(rvh, "maxwidth"); |
1406 string16 actual_title = title_watcher.WaitAndGetTitle(); | 1413 string16 actual_title = title_watcher.WaitAndGetTitle(); |
1407 EXPECT_EQ(expected_title, actual_title); | 1414 EXPECT_EQ(expected_title, actual_title); |
1408 } | 1415 } |
1409 } | 1416 } |
1410 | 1417 |
1411 } // namespace content | 1418 } // namespace content |
OLD | NEW |