| 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
| 9 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 void NavigateAndCheckTitle(const char* filename, | 68 void NavigateAndCheckTitle(const char* filename, |
| 69 const std::string& expected_title) { | 69 const std::string& expected_title) { |
| 70 string16 expected_title16(ASCIIToUTF16(expected_title)); | 70 string16 expected_title16(ASCIIToUTF16(expected_title)); |
| 71 ui_test_utils::TitleWatcher title_watcher( | 71 ui_test_utils::TitleWatcher title_watcher( |
| 72 chrome::GetActiveWebContents(browser()), expected_title16); | 72 chrome::GetActiveWebContents(browser()), expected_title16); |
| 73 ui_test_utils::NavigateToURL(browser(), GetURL(filename)); | 73 ui_test_utils::NavigateToURL(browser(), GetURL(filename)); |
| 74 ASSERT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 74 ASSERT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void GoBack() { | 77 void GoBack() { |
| 78 ui_test_utils::WindowedNotificationObserver load_stop_observer( | 78 content::WindowedNotificationObserver load_stop_observer( |
| 79 content::NOTIFICATION_LOAD_STOP, | 79 content::NOTIFICATION_LOAD_STOP, |
| 80 content::NotificationService::AllSources()); | 80 content::NotificationService::AllSources()); |
| 81 chrome::GoBack(browser(), CURRENT_TAB); | 81 chrome::GoBack(browser(), CURRENT_TAB); |
| 82 load_stop_observer.Wait(); | 82 load_stop_observer.Wait(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void GoForward() { | 85 void GoForward() { |
| 86 ui_test_utils::WindowedNotificationObserver load_stop_observer( | 86 content::WindowedNotificationObserver load_stop_observer( |
| 87 content::NOTIFICATION_LOAD_STOP, | 87 content::NOTIFICATION_LOAD_STOP, |
| 88 content::NotificationService::AllSources()); | 88 content::NotificationService::AllSources()); |
| 89 chrome::GoForward(browser(), CURRENT_TAB); | 89 chrome::GoForward(browser(), CURRENT_TAB); |
| 90 load_stop_observer.Wait(); | 90 load_stop_observer.Wait(); |
| 91 } | 91 } |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 // If this flakes, use http://crbug.com/61619 on windows and | 94 // If this flakes, use http://crbug.com/61619 on windows and |
| 95 // http://crbug.com/102094 on mac. | 95 // http://crbug.com/102094 on mac. |
| 96 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, BasicBackForward) { | 96 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, BasicBackForward) { |
| 97 // about:blank should be loaded first. | 97 // about:blank should be loaded first. |
| 98 ASSERT_FALSE(chrome::CanGoBack(browser())); | 98 ASSERT_FALSE(chrome::CanGoBack(browser())); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 GoBack(); | 457 GoBack(); |
| 458 | 458 |
| 459 // Ensure history.length is properly truncated. | 459 // Ensure history.length is properly truncated. |
| 460 ui_test_utils::NavigateToURL(browser(), GetURL("title2.html")); | 460 ui_test_utils::NavigateToURL(browser(), GetURL("title2.html")); |
| 461 | 461 |
| 462 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( | 462 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( |
| 463 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 463 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 464 L"", L"domAutomationController.send(history.length)", &length)); | 464 L"", L"domAutomationController.send(history.length)", &length)); |
| 465 EXPECT_EQ(2, length); | 465 EXPECT_EQ(2, length); |
| 466 } | 466 } |
| OLD | NEW |