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

Side by Side Diff: content/browser/web_contents/web_contents_impl_browsertest.cc

Issue 1917073002: Block webpages from navigating to view-source URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ChildProcessSecurityPolicy and tests Created 4 years, 7 months 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/macros.h" 5 #include "base/macros.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/browser/frame_host/navigation_entry_impl.h" 9 #include "content/browser/frame_host/navigation_entry_impl.h"
10 #include "content/browser/renderer_host/render_widget_host_impl.h" 10 #include "content/browser/renderer_host/render_widget_host_impl.h"
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 shell()->web_contents()->SetPageScale(1.5); 763 shell()->web_contents()->SetPageScale(1.5);
764 EXPECT_CALL(observer, OnPageScaleFactorChanged(::testing::FloatEq(1.5))); 764 EXPECT_CALL(observer, OnPageScaleFactorChanged(::testing::FloatEq(1.5)));
765 observer.WaitForPageScaleUpdate(); 765 observer.WaitForPageScaleUpdate();
766 766
767 // Navigate to reset the page scale factor. 767 // Navigate to reset the page scale factor.
768 shell()->LoadURL(embedded_test_server()->GetURL("/title2.html")); 768 shell()->LoadURL(embedded_test_server()->GetURL("/title2.html"));
769 EXPECT_CALL(observer, OnPageScaleFactorChanged(::testing::_)); 769 EXPECT_CALL(observer, OnPageScaleFactorChanged(::testing::_));
770 observer.WaitForPageScaleUpdate(); 770 observer.WaitForPageScaleUpdate();
771 } 771 }
772 772
773 // Test view source mode for a webui page.
774 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, WebUIViewSource) {
Charlie Reis 2016/05/16 22:22:18 Seems like a nice test. Was this behavior at risk
meacer 2016/05/19 01:13:54 I didn't run into this case in my attempts, but I
775 const char kUrl[] = "view-source:chrome://chrome/settings";
776 const GURL kGURL(kUrl);
777 NavigateToURL(shell(), kGURL);
778 EXPECT_EQ(base::ASCIIToUTF16(kUrl), shell()->web_contents()->GetTitle());
779 }
780
773 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, NewNamedWindow) { 781 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, NewNamedWindow) {
774 ASSERT_TRUE(embedded_test_server()->Start()); 782 ASSERT_TRUE(embedded_test_server()->Start());
775 783
776 GURL url = embedded_test_server()->GetURL("/click-noreferrer-links.html"); 784 GURL url = embedded_test_server()->GetURL("/click-noreferrer-links.html");
777 EXPECT_TRUE(NavigateToURL(shell(), url)); 785 EXPECT_TRUE(NavigateToURL(shell(), url));
778 786
779 { 787 {
780 ShellAddedObserver new_shell_observer; 788 ShellAddedObserver new_shell_observer;
781 789
782 // Open a new, named window. 790 // Open a new, named window.
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 content::ExecuteScript(root->current_frame_host(), alert_location)); 1013 content::ExecuteScript(root->current_frame_host(), alert_location));
1006 dialog_manager.Wait(); 1014 dialog_manager.Wait();
1007 EXPECT_EQ(GURL("http://a.com/title1.html"), 1015 EXPECT_EQ(GURL("http://a.com/title1.html"),
1008 GURL(dialog_manager.last_message()).ReplaceComponents(clear_port)); 1016 GURL(dialog_manager.last_message()).ReplaceComponents(clear_port));
1009 1017
1010 wc->SetDelegate(nullptr); 1018 wc->SetDelegate(nullptr);
1011 wc->SetJavaScriptDialogManagerForTesting(nullptr); 1019 wc->SetJavaScriptDialogManagerForTesting(nullptr);
1012 } 1020 }
1013 1021
1014 } // namespace content 1022 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698