| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <sstream> | 5 #include <sstream> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 tab->NavigateToURL( | 141 tab->NavigateToURL( |
| 142 server->TestServerPageW(L"files/sync_xmlhttprequest_during_unload.html")); | 142 server->TestServerPageW(L"files/sync_xmlhttprequest_during_unload.html")); |
| 143 | 143 |
| 144 // Confirm that the page has loaded (since it changes its title during load). | 144 // Confirm that the page has loaded (since it changes its title during load). |
| 145 std::wstring tab_title; | 145 std::wstring tab_title; |
| 146 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); | 146 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); |
| 147 EXPECT_EQ(L"sync xhr on unload", tab_title); | 147 EXPECT_EQ(L"sync xhr on unload", tab_title); |
| 148 | 148 |
| 149 // Navigate to a new page, to dispatch unload event and trigger xhr. | 149 // Navigate to a new page, to dispatch unload event and trigger xhr. |
| 150 // (the bug would make this step hang the renderer). | 150 // (the bug would make this step hang the renderer). |
| 151 bool timed_out = false; | 151 tab->NavigateToURL(server->TestServerPageW(L"files/title2.html")); |
| 152 tab->NavigateToURLWithTimeout(server->TestServerPageW(L"files/title2.html"), | |
| 153 action_max_timeout_ms(), | |
| 154 &timed_out); | |
| 155 EXPECT_FALSE(timed_out); | |
| 156 | 152 |
| 157 // Check that the new page got loaded, and that no download was triggered. | 153 // Check that the new page got loaded, and that no download was triggered. |
| 158 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); | 154 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); |
| 159 EXPECT_EQ(L"Title Of Awesomeness", tab_title); | 155 EXPECT_EQ(L"Title Of Awesomeness", tab_title); |
| 160 | 156 |
| 161 bool shelf_is_visible = false; | 157 bool shelf_is_visible = false; |
| 162 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 158 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 163 EXPECT_TRUE(browser->IsShelfVisible(&shelf_is_visible)); | 159 EXPECT_TRUE(browser->IsShelfVisible(&shelf_is_visible)); |
| 164 EXPECT_FALSE(shelf_is_visible); | 160 EXPECT_FALSE(shelf_is_visible); |
| 165 } | 161 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 ASSERT_TRUE(tab.get()); | 237 ASSERT_TRUE(tab.get()); |
| 242 | 238 |
| 243 // Start with an HTTP page. | 239 // Start with an HTTP page. |
| 244 CheckTitleTest(L"content-sniffer-test0.html", | 240 CheckTitleTest(L"content-sniffer-test0.html", |
| 245 L"Content Sniffer Test 0"); | 241 L"Content Sniffer Test 0"); |
| 246 | 242 |
| 247 // Now load a file:// page, which does not use the BufferedEventHandler. | 243 // Now load a file:// page, which does not use the BufferedEventHandler. |
| 248 // Make sure that the page loads and displays a title, and doesn't get stuck. | 244 // Make sure that the page loads and displays a title, and doesn't get stuck. |
| 249 FilePath test_file(test_data_directory_); | 245 FilePath test_file(test_data_directory_); |
| 250 test_file = test_file.AppendASCII("title2.html"); | 246 test_file = test_file.AppendASCII("title2.html"); |
| 251 bool timed_out = false; | 247 tab->NavigateToURL(net::FilePathToFileURL(test_file)); |
| 252 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(test_file), | |
| 253 action_max_timeout_ms(), | |
| 254 &timed_out); | |
| 255 EXPECT_FALSE(timed_out); | |
| 256 EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle()); | 248 EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle()); |
| 257 } | 249 } |
| 258 | 250 |
| 259 // Tests that a cross-site navigation to an error page (resulting in the link | 251 // Tests that a cross-site navigation to an error page (resulting in the link |
| 260 // doctor page) still runs the onunload handler and can support navigations | 252 // doctor page) still runs the onunload handler and can support navigations |
| 261 // away from the link doctor page. (Bug 1235537) | 253 // away from the link doctor page. (Bug 1235537) |
| 262 TEST_F(ResourceDispatcherTest, CrossSiteNavigationErrorPage) { | 254 TEST_F(ResourceDispatcherTest, CrossSiteNavigationErrorPage) { |
| 263 const wchar_t kDocRoot[] = L"chrome/test/data"; | 255 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 264 scoped_refptr<HTTPTestServer> server = | 256 scoped_refptr<HTTPTestServer> server = |
| 265 HTTPTestServer::CreateServer(kDocRoot, NULL); | 257 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 // 2- http://mock.http/redirect-to-title2.html | 317 // 2- http://mock.http/redirect-to-title2.html |
| 326 // 3- http://mock.http/title2.html | 318 // 3- http://mock.http/title2.html |
| 327 // | 319 // |
| 328 // If the redirect in #2 were not blocked, we'd also see a request | 320 // If the redirect in #2 were not blocked, we'd also see a request |
| 329 // for http://mock.http:4000/title2.html. | 321 // for http://mock.http:4000/title2.html. |
| 330 // | 322 // |
| 331 EXPECT_EQ(3, after - before); | 323 EXPECT_EQ(3, after - before); |
| 332 } | 324 } |
| 333 | 325 |
| 334 } // namespace | 326 } // namespace |
| OLD | NEW |