| 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 // Navigates the browser to server and client redirect pages and makes sure | 5 // Navigates the browser to server and client redirect pages and makes sure |
| 6 // that the correct redirects are reflected in the history database. Errors | 6 // that the correct redirects are reflected in the history database. Errors |
| 7 // here might indicate that WebKit changed the calls our glue layer gets in | 7 // here might indicate that WebKit changed the calls our glue layer gets in |
| 8 // the case of redirects. It may also mean problems with the history system. | 8 // the case of redirects. It may also mean problems with the history system. |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/scoped_temp_dir.h" | |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
| 18 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "chrome/browser/history/history.h" | 20 #include "chrome/browser/history/history.h" |
| 21 #include "chrome/browser/history/history_service_factory.h" | 21 #include "chrome/browser/history/history_service_factory.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 GURL final_url = test_server()->GetURL(std::string()); | 121 GURL final_url = test_server()->GetURL(std::string()); |
| 122 ASSERT_TRUE(final_url.is_valid()); | 122 ASSERT_TRUE(final_url.is_valid()); |
| 123 std::string file_redirect_contents = StringPrintf( | 123 std::string file_redirect_contents = StringPrintf( |
| 124 "<html>" | 124 "<html>" |
| 125 "<head></head>" | 125 "<head></head>" |
| 126 "<body onload=\"document.location='%s'\"></body>" | 126 "<body onload=\"document.location='%s'\"></body>" |
| 127 "</html>", | 127 "</html>", |
| 128 final_url.spec().c_str()); | 128 final_url.spec().c_str()); |
| 129 | 129 |
| 130 // Write the contents to a temporary file. | 130 // Write the contents to a temporary file. |
| 131 ScopedTempDir temp_directory; | 131 base::ScopedTempDir temp_directory; |
| 132 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); | 132 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
| 133 FilePath temp_file; | 133 FilePath temp_file; |
| 134 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_directory.path(), | 134 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_directory.path(), |
| 135 &temp_file)); | 135 &temp_file)); |
| 136 ASSERT_EQ(static_cast<int>(file_redirect_contents.size()), | 136 ASSERT_EQ(static_cast<int>(file_redirect_contents.size()), |
| 137 file_util::WriteFile(temp_file, | 137 file_util::WriteFile(temp_file, |
| 138 file_redirect_contents.data(), | 138 file_redirect_contents.data(), |
| 139 file_redirect_contents.size())); | 139 file_redirect_contents.size())); |
| 140 | 140 |
| 141 // Navigate to the file through the browser. The client redirect will appear | 141 // Navigate to the file through the browser. The client redirect will appear |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 // as a client redirect from the first (/client-redirect?) page. | 297 // as a client redirect from the first (/client-redirect?) page. |
| 298 for (std::vector<GURL>::iterator it = redirects.begin(); | 298 for (std::vector<GURL>::iterator it = redirects.begin(); |
| 299 it != redirects.end(); ++it) { | 299 it != redirects.end(); ++it) { |
| 300 if (final_url.spec() == it->spec()) { | 300 if (final_url.spec() == it->spec()) { |
| 301 final_navigation_not_redirect = false; | 301 final_navigation_not_redirect = false; |
| 302 break; | 302 break; |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 EXPECT_TRUE(final_navigation_not_redirect); | 305 EXPECT_TRUE(final_navigation_not_redirect); |
| 306 } | 306 } |
| OLD | NEW |