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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "chrome/browser/browser_about_handler.h" | 8 #include "chrome/browser/browser_about_handler.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| 11 #include "content/public/browser/navigation_controller.h" |
| 12 #include "content/public/browser/navigation_entry.h" |
| 13 #include "content/public/common/referrer.h" |
11 #include "content/public/test/test_browser_thread.h" | 14 #include "content/public/test/test_browser_thread.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "url/gurl.h" | 16 #include "url/gurl.h" |
14 | 17 |
15 using content::BrowserThread; | 18 using content::BrowserThread; |
| 19 using content::NavigationController; |
| 20 using content::NavigationEntry; |
| 21 using content::Referrer; |
16 | 22 |
17 typedef testing::Test BrowserAboutHandlerTest; | 23 typedef testing::Test BrowserAboutHandlerTest; |
18 | 24 |
19 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) { | 25 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) { |
20 std::string chrome_prefix(content::kChromeUIScheme); | 26 std::string chrome_prefix(content::kChromeUIScheme); |
21 chrome_prefix.append(url::kStandardSchemeSeparator); | 27 chrome_prefix.append(url::kStandardSchemeSeparator); |
22 struct AboutURLTestData { | 28 struct AboutURLTestData { |
23 GURL test_url; | 29 GURL test_url; |
24 GURL result_url; | 30 GURL result_url; |
25 } test_data[] = { | 31 } test_data[] = { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 base::MessageLoopForUI message_loop; | 73 base::MessageLoopForUI message_loop; |
68 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 74 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
69 TestingProfile profile; | 75 TestingProfile profile; |
70 | 76 |
71 for (size_t i = 0; i < arraysize(test_data); ++i) { | 77 for (size_t i = 0; i < arraysize(test_data); ++i) { |
72 GURL url(test_data[i].test_url); | 78 GURL url(test_data[i].test_url); |
73 WillHandleBrowserAboutURL(&url, &profile); | 79 WillHandleBrowserAboutURL(&url, &profile); |
74 EXPECT_EQ(test_data[i].result_url, url); | 80 EXPECT_EQ(test_data[i].result_url, url); |
75 } | 81 } |
76 } | 82 } |
| 83 |
| 84 // Ensure that minor BrowserAboutHandler fixup to a URL does not cause us to |
| 85 // keep a separate virtual URL, which would not be updated on redirects. |
| 86 // See https://crbug.com/449829. |
| 87 TEST_F(BrowserAboutHandlerTest, NoVirtualURLForFixup) { |
| 88 GURL url("view-source:http://.foo"); |
| 89 |
| 90 // Fixup will remove the dot and add a slash. |
| 91 GURL fixed_url("view-source:http://foo/"); |
| 92 |
| 93 // Rewriters will remove the view-source prefix and expect it to stay in the |
| 94 // virtual URL. |
| 95 GURL rewritten_url("http://foo/"); |
| 96 |
| 97 TestingProfile profile; |
| 98 scoped_ptr<NavigationEntry> entry(NavigationController::CreateNavigationEntry( |
| 99 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), |
| 100 &profile)); |
| 101 EXPECT_EQ(fixed_url, entry->GetVirtualURL()); |
| 102 EXPECT_EQ(rewritten_url, entry->GetURL()); |
| 103 } |
OLD | NEW |