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_split.h" | 8 #include "base/string_split.h" |
9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 11 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
12 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | 12 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
13 #include "content/browser/browser_plugin/test_browser_plugin_embedder.h" | 13 #include "content/browser/browser_plugin/test_browser_plugin_embedder.h" |
14 #include "content/browser/browser_plugin/test_browser_plugin_guest.h" | 14 #include "content/browser/browser_plugin/test_browser_plugin_guest.h" |
15 #include "content/browser/child_process_security_policy_impl.h" | |
15 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
16 #include "content/browser/web_contents/web_contents_impl.h" | 17 #include "content/browser/web_contents/web_contents_impl.h" |
17 #include "content/common/view_messages.h" | 18 #include "content/common/view_messages.h" |
18 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/notification_types.h" | 20 #include "content/public/browser/notification_types.h" |
20 #include "content/public/browser/render_view_host_observer.h" | 21 #include "content/public/browser/render_view_host_observer.h" |
21 #include "content/public/browser/render_widget_host_view.h" | 22 #include "content/public/browser/render_widget_host_view.h" |
22 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
23 #include "content/public/test/browser_test_utils.h" | 24 #include "content/public/test/browser_test_utils.h" |
24 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
829 test_embedder()->web_contents()->GetRenderViewHost()); | 830 test_embedder()->web_contents()->GetRenderViewHost()); |
830 GURL test_url = test_server()->GetURL("close-socket"); | 831 GURL test_url = test_server()->GetURL("close-socket"); |
831 ExecuteSyncJSFunction( | 832 ExecuteSyncJSFunction( |
832 rvh, StringPrintf("SetSrc('%s');", test_url.spec().c_str())); | 833 rvh, StringPrintf("SetSrc('%s');", test_url.spec().c_str())); |
833 string16 actual_title = title_watcher.WaitAndGetTitle(); | 834 string16 actual_title = title_watcher.WaitAndGetTitle(); |
834 EXPECT_EQ(expected_title, actual_title); | 835 EXPECT_EQ(expected_title, actual_title); |
835 } | 836 } |
836 | 837 |
837 { | 838 { |
838 // Navigate the guest to an illegal chrome:// URL. | 839 // Navigate the guest to an illegal chrome:// URL. |
840 GURL test_url("chrome://newtab"); | |
841 ChildProcessSecurityPolicyImpl* policy = | |
842 ChildProcessSecurityPolicyImpl::GetInstance(); | |
843 // Register chrome:// as a safe scheme so as to bypass | |
844 // ChildProcessSecurityPolicyImpl::CanRequestURL(). | |
845 if (!policy->IsWebSafeScheme(test_url.scheme())) | |
846 policy->RegisterWebSafeScheme(test_url.scheme()); | |
mmenke
2013/02/19 17:26:15
Why wasn't this needed before?
pauljensen
2013/02/20 15:13:27
The two argument version of
ChildProcessSecurityPo
| |
839 const string16 expected_title = ASCIIToUTF16("ERR_INVALID_URL"); | 847 const string16 expected_title = ASCIIToUTF16("ERR_INVALID_URL"); |
840 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 848 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
841 expected_title); | 849 expected_title); |
842 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 850 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
843 test_embedder()->web_contents()->GetRenderViewHost()); | 851 test_embedder()->web_contents()->GetRenderViewHost()); |
844 GURL test_url("chrome://newtab"); | |
845 ExecuteSyncJSFunction( | 852 ExecuteSyncJSFunction( |
846 rvh, StringPrintf("SetSrc('%s');", test_url.spec().c_str())); | 853 rvh, StringPrintf("SetSrc('%s');", test_url.spec().c_str())); |
847 string16 actual_title = title_watcher.WaitAndGetTitle(); | 854 string16 actual_title = title_watcher.WaitAndGetTitle(); |
848 EXPECT_EQ(expected_title, actual_title); | 855 EXPECT_EQ(expected_title, actual_title); |
849 } | 856 } |
850 | 857 |
851 { | 858 { |
852 // Navigate the guest to an illegal file:// URL. | 859 // Navigate the guest to an illegal file:// URL. |
853 const string16 expected_title = ASCIIToUTF16("ERR_ABORTED"); | 860 const string16 expected_title = ASCIIToUTF16("ERR_ABORTED"); |
854 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 861 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1364 const string16 expected_title = ASCIIToUTF16("AutoSize(640, 480)"); | 1371 const string16 expected_title = ASCIIToUTF16("AutoSize(640, 480)"); |
1365 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 1372 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
1366 expected_title); | 1373 expected_title); |
1367 RemoveAttributes(rvh, "maxwidth"); | 1374 RemoveAttributes(rvh, "maxwidth"); |
1368 string16 actual_title = title_watcher.WaitAndGetTitle(); | 1375 string16 actual_title = title_watcher.WaitAndGetTitle(); |
1369 EXPECT_EQ(expected_title, actual_title); | 1376 EXPECT_EQ(expected_title, actual_title); |
1370 } | 1377 } |
1371 } | 1378 } |
1372 | 1379 |
1373 } // namespace content | 1380 } // namespace content |
OLD | NEW |