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

Side by Side Diff: content/browser/browser_side_navigation_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: Add layout and browser 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
11 #include "content/common/site_isolation_policy.h" 11 #include "content/common/site_isolation_policy.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/public/common/url_constants.h"
14 #include "content/public/test/browser_test_utils.h" 15 #include "content/public/test/browser_test_utils.h"
15 #include "content/public/test/content_browser_test.h" 16 #include "content/public/test/content_browser_test.h"
16 #include "content/public/test/content_browser_test_utils.h" 17 #include "content/public/test/content_browser_test_utils.h"
17 #include "content/public/test/test_navigation_observer.h" 18 #include "content/public/test/test_navigation_observer.h"
18 #include "content/shell/browser/shell.h" 19 #include "content/shell/browser/shell.h"
19 #include "net/dns/mock_host_resolver.h" 20 #include "net/dns/mock_host_resolver.h"
20 #include "net/test/embedded_test_server/embedded_test_server.h" 21 #include "net/test/embedded_test_server/embedded_test_server.h"
21 #include "net/test/url_request/url_request_failed_job.h" 22 #include "net/test/url_request/url_request_failed_job.h"
22 #include "url/gurl.h" 23 #include "url/gurl.h"
23 24
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 EXPECT_EQ("text=&select=a", 222 EXPECT_EQ("text=&select=a",
222 base::UTF16ToASCII(shell()->web_contents()->GetTitle())); 223 base::UTF16ToASCII(shell()->web_contents()->GetTitle()));
223 EXPECT_EQ(post_url, shell()->web_contents()->GetLastCommittedURL()); 224 EXPECT_EQ(post_url, shell()->web_contents()->GetLastCommittedURL());
224 EXPECT_TRUE(shell() 225 EXPECT_TRUE(shell()
225 ->web_contents() 226 ->web_contents()
226 ->GetController() 227 ->GetController()
227 .GetActiveEntry() 228 .GetActiveEntry()
228 ->GetHasPostData()); 229 ->GetHasPostData());
229 } 230 }
230 231
232 // Ensure that browser side navigation handles view-source URLs correctly.
233 IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest, ViewSourceNavigation) {
234 TestNavigationObserver observer(shell()->web_contents());
235 GURL url(embedded_test_server()->GetURL("/title1.html"));
236 GURL view_source_url(content::kViewSourceScheme + std::string(":") +
237 url.spec());
238 NavigateToURL(shell(), view_source_url);
239 EXPECT_EQ(url, observer.last_navigation_url());
240 EXPECT_TRUE(observer.last_navigation_succeeded());
241 }
Charlie Reis 2016/05/24 22:54:16 Thanks for proactively testing the PlzNavigate cas
meacer 2016/05/31 23:57:54 Done.
242
231 } // namespace content 243 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698