Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_host_browsertest.cc

Issue 11313018: Prevent webview tags from navigating outside web-safe schemes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/browser/browser_plugin/browser_plugin_guest.h" 10 #include "content/browser/browser_plugin/browser_plugin_guest.h"
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 StringPrintf("SetSrc('%s');", kHTMLForGuest))); 736 StringPrintf("SetSrc('%s');", kHTMLForGuest)));
737 737
738 string16 actual_title = title_watcher.WaitAndGetTitle(); 738 string16 actual_title = title_watcher.WaitAndGetTitle();
739 EXPECT_EQ(expected_title, actual_title); 739 EXPECT_EQ(expected_title, actual_title);
740 } 740 }
741 741
742 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadAbort) { 742 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadAbort) {
743 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; 743 const char kEmbedderURL[] = "files/browser_plugin_embedder.html";
744 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); 744 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, "");
745 745
746 const string16 expected_title = ASCIIToUTF16("ERR_EMPTY_RESPONSE"); 746 {
747 content::TitleWatcher title_watcher(test_embedder()->web_contents(), 747 // Navigate the guest to "close-socket".
748 expected_title); 748 const string16 expected_title = ASCIIToUTF16("ERR_EMPTY_RESPONSE");
749 content::TitleWatcher title_watcher(test_embedder()->web_contents(),
750 expected_title);
751 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
752 test_embedder()->web_contents()->GetRenderViewHost());
753 GURL test_url = test_server()->GetURL("close-socket");
754 ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
755 StringPrintf("SetSrc('%s');", test_url.spec().c_str())));
756 string16 actual_title = title_watcher.WaitAndGetTitle();
757 EXPECT_EQ(expected_title, actual_title);
758 }
749 759
750 // Renavigate the guest to "close-socket". 760 {
751 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( 761 // Navigate the guest to an illegal chrome:// URL.
752 test_embedder()->web_contents()->GetRenderViewHost()); 762 const string16 expected_title = ASCIIToUTF16("ERR_FAILED");
753 GURL test_url = test_server()->GetURL("close-socket"); 763 content::TitleWatcher title_watcher(test_embedder()->web_contents(),
754 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( 764 expected_title);
755 StringPrintf("SetSrc('%s');", test_url.spec().c_str()))); 765 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
766 test_embedder()->web_contents()->GetRenderViewHost());
767 GURL test_url("chrome://newtab");
768 ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
769 StringPrintf("SetSrc('%s');", test_url.spec().c_str())));
770 string16 actual_title = title_watcher.WaitAndGetTitle();
771 EXPECT_EQ(expected_title, actual_title);
772 }
756 773
757 string16 actual_title = title_watcher.WaitAndGetTitle(); 774 {
758 EXPECT_EQ(expected_title, actual_title); 775 // Navigate the guest to an illegal file:// URL.
776 const string16 expected_title = ASCIIToUTF16("ERR_ABORTED");
777 content::TitleWatcher title_watcher(test_embedder()->web_contents(),
778 expected_title);
779 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
780 test_embedder()->web_contents()->GetRenderViewHost());
781 GURL test_url("file://foo");
782 ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
783 StringPrintf("SetSrc('%s');", test_url.spec().c_str())));
784 string16 actual_title = title_watcher.WaitAndGetTitle();
785 EXPECT_EQ(expected_title, actual_title);
786 }
759 } 787 }
760 788
761 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadRedirect) { 789 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadRedirect) {
762 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; 790 const char kEmbedderURL[] = "files/browser_plugin_embedder.html";
763 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); 791 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, "");
764 792
765 const string16 expected_title = ASCIIToUTF16("redirected"); 793 const string16 expected_title = ASCIIToUTF16("redirected");
766 content::TitleWatcher title_watcher(test_embedder()->web_contents(), 794 content::TitleWatcher title_watcher(test_embedder()->web_contents(),
767 expected_title); 795 expected_title);
768 796
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 string16 actual_title = title_watcher.WaitAndGetTitle(); 988 string16 actual_title = title_watcher.WaitAndGetTitle();
961 EXPECT_EQ(expected_title, actual_title); 989 EXPECT_EQ(expected_title, actual_title);
962 scoped_ptr<base::Value> is_top_level(rvh->ExecuteJavascriptAndGetValue( 990 scoped_ptr<base::Value> is_top_level(rvh->ExecuteJavascriptAndGetValue(
963 string16(), ASCIIToUTF16("commitIsTopLevel"))); 991 string16(), ASCIIToUTF16("commitIsTopLevel")));
964 bool top_level_bool = false; 992 bool top_level_bool = false;
965 EXPECT_TRUE(is_top_level->GetAsBoolean(&top_level_bool)); 993 EXPECT_TRUE(is_top_level->GetAsBoolean(&top_level_bool));
966 EXPECT_EQ(true, top_level_bool); 994 EXPECT_EQ(true, top_level_bool);
967 } 995 }
968 996
969 } // namespace content 997 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_embedder.cc ('k') | content/browser/renderer_host/render_view_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698