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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "chrome/common/url_constants.h" |
6 #include "chrome/test/automation/browser_proxy.h" | 7 #include "chrome/test/automation/browser_proxy.h" |
7 #include "chrome/test/automation/tab_proxy.h" | 8 #include "chrome/test/automation/tab_proxy.h" |
8 #include "chrome/test/ui/ui_test.h" | 9 #include "chrome/test/ui/ui_test.h" |
9 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 typedef UITest CrashRecoveryUITest; | 13 typedef UITest CrashRecoveryUITest; |
13 | 14 |
14 TEST_F(CrashRecoveryUITest, Reload) { | 15 TEST_F(CrashRecoveryUITest, Reload) { |
15 // Test that reload works after a crash. | 16 // Test that reload works after a crash. |
16 | 17 |
17 // This test only works in multi-process mode | 18 // This test only works in multi-process mode |
18 if (in_process_renderer()) | 19 if (in_process_renderer()) |
19 return; | 20 return; |
20 | 21 |
21 // The title of the active tab should change each time this URL is loaded. | 22 // The title of the active tab should change each time this URL is loaded. |
22 GURL url( | 23 GURL url( |
23 "data:text/html,<script>document.title=new Date().valueOf()</script>"); | 24 "data:text/html,<script>document.title=new Date().valueOf()</script>"); |
24 | 25 |
25 NavigateToURL(url); | 26 NavigateToURL(url); |
26 | 27 |
27 std::wstring title1 = GetActiveTabTitle(); | 28 std::wstring title1 = GetActiveTabTitle(); |
28 | 29 |
29 scoped_ptr<TabProxy> tab(GetActiveTab()); | 30 scoped_ptr<TabProxy> tab(GetActiveTab()); |
30 | 31 |
31 // Cause the renderer to crash. | 32 // Cause the renderer to crash. |
32 expected_crashes_ = 1; | 33 expected_crashes_ = 1; |
33 tab->NavigateToURLAsync(GURL("about:crash")); | 34 tab->NavigateToURLAsync(GURL(chrome::kAboutCrashURL)); |
34 | 35 |
35 Sleep(1000); // Wait for the browser to notice the renderer crash. | 36 Sleep(1000); // Wait for the browser to notice the renderer crash. |
36 | 37 |
37 tab->Reload(); | 38 tab->Reload(); |
38 | 39 |
39 std::wstring title2 = GetActiveTabTitle(); | 40 std::wstring title2 = GetActiveTabTitle(); |
40 EXPECT_NE(title1, title2); | 41 EXPECT_NE(title1, title2); |
41 } | 42 } |
42 | 43 |
43 // Tests that loading a crashed page in a new tab correctly updates the title. | 44 // Tests that loading a crashed page in a new tab correctly updates the title. |
(...skipping 12 matching lines...) Expand all Loading... |
56 | 57 |
57 NavigateToURL(url); | 58 NavigateToURL(url); |
58 | 59 |
59 const std::wstring title(L"Title Of Awesomeness"); | 60 const std::wstring title(L"Title Of Awesomeness"); |
60 EXPECT_EQ(title, GetActiveTabTitle()); | 61 EXPECT_EQ(title, GetActiveTabTitle()); |
61 | 62 |
62 scoped_ptr<TabProxy> tab(GetActiveTab()); | 63 scoped_ptr<TabProxy> tab(GetActiveTab()); |
63 | 64 |
64 // Cause the renderer to crash. | 65 // Cause the renderer to crash. |
65 expected_crashes_ = 1; | 66 expected_crashes_ = 1; |
66 tab->NavigateToURLAsync(GURL("about:crash")); | 67 tab->NavigateToURLAsync(GURL(chrome::kAboutCrashURL)); |
67 | 68 |
68 Sleep(1000); // Wait for the browser to notice the renderer crash. | 69 Sleep(1000); // Wait for the browser to notice the renderer crash. |
69 | 70 |
70 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 71 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
71 ASSERT_TRUE(browser_proxy->AppendTab(url)); | 72 ASSERT_TRUE(browser_proxy->AppendTab(url)); |
72 | 73 |
73 // Ensure the title of the new tab is updated, indicating that the navigation | 74 // Ensure the title of the new tab is updated, indicating that the navigation |
74 // entry was properly committed. | 75 // entry was properly committed. |
75 EXPECT_EQ(title, GetActiveTabTitle()); | 76 EXPECT_EQ(title, GetActiveTabTitle()); |
76 } | 77 } |
77 | 78 |
OLD | NEW |