blob: 31f0981cd38e15548f84cc41fa6c63da4831cd78 [file] [log] [blame]
[email protected]f8f93eb2012-09-25 03:06:241// 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
3// found in the LICENSE file.
4
[email protected]2ee3da9d62012-12-05 20:17:195#include "base/command_line.h"
[email protected]59253a652012-11-20 00:17:266#include "chrome/browser/ui/browser.h"
[email protected]59253a652012-11-20 00:17:267#include "chrome/browser/ui/tabs/tab_strip_model.h"
[email protected]231dba22013-07-25 23:53:038#include "chrome/common/chrome_switches.h"
[email protected]f8f93eb2012-09-25 03:06:249#include "chrome/test/base/in_process_browser_test.h"
10#include "chrome/test/base/ui_test_utils.h"
[email protected]f8f93eb2012-09-25 03:06:2411#include "content/public/browser/navigation_controller.h"
12#include "content/public/browser/navigation_entry.h"
13#include "content/public/browser/web_contents.h"
[email protected]2ee3da9d62012-12-05 20:17:1914#include "content/public/common/content_switches.h"
[email protected]761fa4702013-07-02 15:25:1515#include "url/gurl.h"
[email protected]f8f93eb2012-09-25 03:06:2416
17namespace content {
18
19class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest {
20 public:
21 // Returns the last committed navigation entry of the first tab. May be NULL
22 // if there is no such entry.
23 NavigationEntry* GetLastCommittedEntry() {
[email protected]59253a652012-11-20 00:17:2624 return browser()->tab_strip_model()->GetWebContentsAt(0)->
25 GetController().GetLastCommittedEntry();
[email protected]f8f93eb2012-09-25 03:06:2426 }
27};
28
29IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
30 UberURLHandler_SettingsPage) {
[email protected]44e8add2013-06-13 17:29:1531 const GURL url_short("chrome://settings/");
32 const GURL url_long("chrome://chrome/settings/");
[email protected]f8f93eb2012-09-25 03:06:2433
34 ui_test_utils::NavigateToURL(browser(), url_short);
35 NavigationEntry* entry = GetLastCommittedEntry();
36
37 ASSERT_TRUE(entry != NULL);
38 EXPECT_EQ(url_long, entry->GetURL());
39 EXPECT_EQ(url_short, entry->GetVirtualURL());
40}
41
42IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
43 UberURLHandler_ContentSettingsPage) {
[email protected]44e8add2013-06-13 17:29:1544 const GURL url_short("chrome://settings/content");
45 const GURL url_long("chrome://chrome/settings/content");
[email protected]f8f93eb2012-09-25 03:06:2446
47 ui_test_utils::NavigateToURL(browser(), url_short);
48 NavigationEntry* entry = GetLastCommittedEntry();
49
50 ASSERT_TRUE(entry != NULL);
51 EXPECT_EQ(url_long, entry->GetURL());
52 EXPECT_EQ(url_short, entry->GetVirtualURL());
53}
54
[email protected]045bf7c2012-09-28 20:27:3655IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
56 UberURLHandler_AboutPage) {
[email protected]44e8add2013-06-13 17:29:1557 const GURL url("chrome://chrome/");
[email protected]045bf7c2012-09-28 20:27:3658
59 ui_test_utils::NavigateToURL(browser(), url);
60 NavigationEntry* entry = GetLastCommittedEntry();
61
62 ASSERT_TRUE(entry != NULL);
63 EXPECT_EQ(url, entry->GetURL());
64 EXPECT_EQ(url, entry->GetVirtualURL());
65}
66
[email protected]44e8add2013-06-13 17:29:1567IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
68 UberURLHandler_EmptyHost) {
69 const GURL url("chrome://chrome//foo");
70
71 ui_test_utils::NavigateToURL(browser(), url);
72 NavigationEntry* entry = GetLastCommittedEntry();
73
74 ASSERT_TRUE(entry != NULL);
75 EXPECT_TRUE(entry->GetVirtualURL().is_valid());
76 EXPECT_EQ(url, entry->GetVirtualURL());
77}
78
[email protected]2ee3da9d62012-12-05 20:17:1979// Test that a basic navigation works in --site-per-process mode. This prevents
80// regressions when that mode calls out into the ChromeContentBrowserClient,
81// such as http://crbug.com/164223.
82IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
83 SitePerProcessNavigation) {
84 CommandLine::ForCurrentProcess()->AppendSwitch(
85 switches::kSitePerProcess);
[email protected]bbdd1b20b2012-12-11 21:24:1386 ASSERT_TRUE(test_server()->Start());
87 const GURL url(test_server()->GetURL("files/title1.html"));
[email protected]2ee3da9d62012-12-05 20:17:1988
89 ui_test_utils::NavigateToURL(browser(), url);
90 NavigationEntry* entry = GetLastCommittedEntry();
91
92 ASSERT_TRUE(entry != NULL);
93 EXPECT_EQ(url, entry->GetURL());
94 EXPECT_EQ(url, entry->GetVirtualURL());
95}
96
[email protected]f8f93eb2012-09-25 03:06:2497} // namespace content