| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
| 7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 8 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
| 9 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
| 10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
| 11 #include "content/browser/tab_contents/tab_contents.h" | 11 #include "content/browser/tab_contents/tab_contents.h" |
| 12 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 13 #include "content/public/browser/notification_types.h" | 13 #include "content/public/browser/notification_types.h" |
| 14 #include "content/public/common/page_transition_types.h" | 14 #include "content/public/common/page_transition_types.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 using content::NavigationController; |
| 17 using content::OpenURLParams; | 18 using content::OpenURLParams; |
| 18 using content::Referrer; | 19 using content::Referrer; |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 void SimulateRendererCrash(Browser* browser) { | 23 void SimulateRendererCrash(Browser* browser) { |
| 23 ui_test_utils::WindowedNotificationObserver observer( | 24 ui_test_utils::WindowedNotificationObserver observer( |
| 24 content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, | 25 content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, |
| 25 content::NotificationService::AllSources()); | 26 content::NotificationService::AllSources()); |
| 26 browser->OpenURL(OpenURLParams( | 27 browser->OpenURL(OpenURLParams( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 43 ui_test_utils::NavigateToURL(browser(), url); | 44 ui_test_utils::NavigateToURL(browser(), url); |
| 44 | 45 |
| 45 string16 title_before_crash; | 46 string16 title_before_crash; |
| 46 string16 title_after_crash; | 47 string16 title_after_crash; |
| 47 | 48 |
| 48 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), | 49 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), |
| 49 &title_before_crash)); | 50 &title_before_crash)); |
| 50 SimulateRendererCrash(browser()); | 51 SimulateRendererCrash(browser()); |
| 51 ui_test_utils::WindowedNotificationObserver observer( | 52 ui_test_utils::WindowedNotificationObserver observer( |
| 52 content::NOTIFICATION_LOAD_STOP, | 53 content::NOTIFICATION_LOAD_STOP, |
| 53 content::Source<content::NavigationController>( | 54 content::Source<NavigationController>( |
| 54 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 55 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
| 55 GetController())); | 56 GetController())); |
| 56 browser()->Reload(CURRENT_TAB); | 57 browser()->Reload(CURRENT_TAB); |
| 57 observer.Wait(); | 58 observer.Wait(); |
| 58 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), | 59 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), |
| 59 &title_after_crash)); | 60 &title_after_crash)); |
| 60 EXPECT_NE(title_before_crash, title_after_crash); | 61 EXPECT_NE(title_before_crash, title_after_crash); |
| 61 } | 62 } |
| 62 | 63 |
| 63 // Tests that loading a crashed page in a new tab correctly updates the title. | 64 // Tests that loading a crashed page in a new tab correctly updates the title. |
| 64 // There was an earlier bug (1270510) in process-per-site in which the max page | 65 // There was an earlier bug (1270510) in process-per-site in which the max page |
| 65 // ID of the RenderProcessHost was stale, so the NavigationEntry in the new tab | 66 // ID of the RenderProcessHost was stale, so the NavigationEntry in the new tab |
| 66 // was not committed. This prevents regression of that bug. | 67 // was not committed. This prevents regression of that bug. |
| 67 // http://crbug.com/57158 - Times out sometimes on all platforms. | 68 // http://crbug.com/57158 - Times out sometimes on all platforms. |
| 68 IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, LoadInNewTab) { | 69 IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, LoadInNewTab) { |
| 69 const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html"); | 70 const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html"); |
| 70 | 71 |
| 71 ui_test_utils::NavigateToURL(browser(), | 72 ui_test_utils::NavigateToURL(browser(), |
| 72 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 73 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 73 FilePath(kTitle2File))); | 74 FilePath(kTitle2File))); |
| 74 | 75 |
| 75 string16 title_before_crash; | 76 string16 title_before_crash; |
| 76 string16 title_after_crash; | 77 string16 title_after_crash; |
| 77 | 78 |
| 78 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), | 79 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), |
| 79 &title_before_crash)); | 80 &title_before_crash)); |
| 80 SimulateRendererCrash(browser()); | 81 SimulateRendererCrash(browser()); |
| 81 ui_test_utils::WindowedNotificationObserver observer( | 82 ui_test_utils::WindowedNotificationObserver observer( |
| 82 content::NOTIFICATION_LOAD_STOP, | 83 content::NOTIFICATION_LOAD_STOP, |
| 83 content::Source<content::NavigationController>( | 84 content::Source<NavigationController>( |
| 84 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 85 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
| 85 GetController())); | 86 GetController())); |
| 86 browser()->Reload(CURRENT_TAB); | 87 browser()->Reload(CURRENT_TAB); |
| 87 observer.Wait(); | 88 observer.Wait(); |
| 88 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), | 89 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), |
| 89 &title_after_crash)); | 90 &title_after_crash)); |
| 90 EXPECT_EQ(title_before_crash, title_after_crash); | 91 EXPECT_EQ(title_before_crash, title_after_crash); |
| 91 } | 92 } |
| OLD | NEW |