OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/platform_thread.h" | 5 #include "base/platform_thread.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "chrome/common/url_constants.h" | 7 #include "chrome/common/url_constants.h" |
8 #include "chrome/test/automation/tab_proxy.h" | 8 #include "chrome/test/automation/tab_proxy.h" |
9 #include "chrome/test/automation/browser_proxy.h" | 9 #include "chrome/test/automation/browser_proxy.h" |
10 #include "chrome/test/ui/ui_test.h" | 10 #include "chrome/test/ui/ui_test.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return url; | 73 return url; |
74 } | 74 } |
75 | 75 |
76 protected: | 76 protected: |
77 scoped_refptr<BrowserProxy> window_; | 77 scoped_refptr<BrowserProxy> window_; |
78 scoped_refptr<TabProxy> tab_; | 78 scoped_refptr<TabProxy> tab_; |
79 | 79 |
80 net::TestServer test_server_; | 80 net::TestServer test_server_; |
81 }; | 81 }; |
82 | 82 |
83 TEST_F(SessionHistoryTest, BasicBackForward) { | 83 #if defined(OS_WIN) |
| 84 // See http://crbug.com/61619 |
| 85 #define MAYBE_BasicBackForward FLAKY_BasicBackForward |
| 86 #else |
| 87 #define MAYBE_BasicBackForward BasicBackForward |
| 88 #endif |
| 89 |
| 90 TEST_F(SessionHistoryTest, MAYBE_BasicBackForward) { |
84 ASSERT_TRUE(test_server_.Start()); | 91 ASSERT_TRUE(test_server_.Start()); |
85 | 92 |
86 // about:blank should be loaded first. | 93 // about:blank should be loaded first. |
87 ASSERT_FALSE(tab_->GoBack()); | 94 ASSERT_FALSE(tab_->GoBack()); |
88 EXPECT_EQ(L"", GetTabTitle()); | 95 EXPECT_EQ(L"", GetTabTitle()); |
89 | 96 |
90 ASSERT_TRUE(tab_->NavigateToURL( | 97 ASSERT_TRUE(tab_->NavigateToURL( |
91 test_server_.GetURL("files/session_history/bot1.html"))); | 98 test_server_.GetURL("files/session_history/bot1.html"))); |
92 EXPECT_EQ(L"bot1", GetTabTitle()); | 99 EXPECT_EQ(L"bot1", GetTabTitle()); |
93 | 100 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 ASSERT_FALSE(tab_->GoBack()); | 138 ASSERT_FALSE(tab_->GoBack()); |
132 EXPECT_EQ(L"", GetTabTitle()); | 139 EXPECT_EQ(L"", GetTabTitle()); |
133 | 140 |
134 ASSERT_TRUE(tab_->GoForward()); | 141 ASSERT_TRUE(tab_->GoForward()); |
135 EXPECT_EQ(L"bot1", GetTabTitle()); | 142 EXPECT_EQ(L"bot1", GetTabTitle()); |
136 | 143 |
137 ASSERT_TRUE(tab_->GoForward()); | 144 ASSERT_TRUE(tab_->GoForward()); |
138 EXPECT_EQ(L"bot3", GetTabTitle()); | 145 EXPECT_EQ(L"bot3", GetTabTitle()); |
139 } | 146 } |
140 | 147 |
| 148 #if defined(OS_WIN) |
| 149 // See http://crbug.com/61619 |
| 150 #define MAYBE_FrameBackForward FLAKY_FrameBackForward |
| 151 #else |
| 152 #define MAYBE_FrameBackForward FrameBackForward |
| 153 #endif |
| 154 |
141 // Test that back/forward works when navigating in subframes. | 155 // Test that back/forward works when navigating in subframes. |
142 TEST_F(SessionHistoryTest, FrameBackForward) { | 156 TEST_F(SessionHistoryTest, MAYBE_FrameBackForward) { |
143 ASSERT_TRUE(test_server_.Start()); | 157 ASSERT_TRUE(test_server_.Start()); |
144 | 158 |
145 // about:blank should be loaded first. | 159 // about:blank should be loaded first. |
146 GURL home(homepage_); | 160 GURL home(homepage_); |
147 ASSERT_FALSE(tab_->GoBack()); | 161 ASSERT_FALSE(tab_->GoBack()); |
148 EXPECT_EQ(L"", GetTabTitle()); | 162 EXPECT_EQ(L"", GetTabTitle()); |
149 EXPECT_EQ(home, GetTabURL()); | 163 EXPECT_EQ(home, GetTabURL()); |
150 | 164 |
151 GURL frames(test_server_.GetURL("files/session_history/frames.html")); | 165 GURL frames(test_server_.GetURL("files/session_history/frames.html")); |
152 ASSERT_TRUE(tab_->NavigateToURL(frames)); | 166 ASSERT_TRUE(tab_->NavigateToURL(frames)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 209 |
196 ASSERT_TRUE(tab_->GoBack()); | 210 ASSERT_TRUE(tab_->GoBack()); |
197 EXPECT_EQ(L"bot2", GetTabTitle()); | 211 EXPECT_EQ(L"bot2", GetTabTitle()); |
198 EXPECT_EQ(frames, GetTabURL()); | 212 EXPECT_EQ(frames, GetTabURL()); |
199 | 213 |
200 ASSERT_TRUE(tab_->GoBack()); | 214 ASSERT_TRUE(tab_->GoBack()); |
201 EXPECT_EQ(L"bot1", GetTabTitle()); | 215 EXPECT_EQ(L"bot1", GetTabTitle()); |
202 EXPECT_EQ(frames, GetTabURL()); | 216 EXPECT_EQ(frames, GetTabURL()); |
203 } | 217 } |
204 | 218 |
| 219 #if defined(OS_WIN) |
| 220 // See http://crbug.com/61619 |
| 221 #define MAYBE_FrameFormBackForward FLAKY_FrameFormBackForward |
| 222 #else |
| 223 #define MAYBE_FrameFormBackForward FrameFormBackForward |
| 224 #endif |
| 225 |
205 // Test that back/forward preserves POST data and document state in subframes. | 226 // Test that back/forward preserves POST data and document state in subframes. |
206 TEST_F(SessionHistoryTest, FrameFormBackForward) { | 227 TEST_F(SessionHistoryTest, MAYBE_FrameFormBackForward) { |
207 ASSERT_TRUE(test_server_.Start()); | 228 ASSERT_TRUE(test_server_.Start()); |
208 | 229 |
209 // about:blank should be loaded first. | 230 // about:blank should be loaded first. |
210 ASSERT_FALSE(tab_->GoBack()); | 231 ASSERT_FALSE(tab_->GoBack()); |
211 EXPECT_EQ(L"", GetTabTitle()); | 232 EXPECT_EQ(L"", GetTabTitle()); |
212 | 233 |
213 GURL frames(test_server_.GetURL("files/session_history/frames.html")); | 234 GURL frames(test_server_.GetURL("files/session_history/frames.html")); |
214 ASSERT_TRUE(tab_->NavigateToURL(frames)); | 235 ASSERT_TRUE(tab_->NavigateToURL(frames)); |
215 EXPECT_EQ(L"bot1", GetTabTitle()); | 236 EXPECT_EQ(L"bot1", GetTabTitle()); |
216 | 237 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 319 |
299 ASSERT_TRUE(tab_->GoBack()); | 320 ASSERT_TRUE(tab_->GoBack()); |
300 EXPECT_EQ(L"form", GetTabTitle()); | 321 EXPECT_EQ(L"form", GetTabTitle()); |
301 EXPECT_EQ(frames, GetTabURL()); | 322 EXPECT_EQ(frames, GetTabURL()); |
302 | 323 |
303 SubmitForm("isubmit"); | 324 SubmitForm("isubmit"); |
304 EXPECT_EQ(L"text=&select=a", GetTabTitle()); | 325 EXPECT_EQ(L"text=&select=a", GetTabTitle()); |
305 EXPECT_EQ(frames, GetTabURL()); | 326 EXPECT_EQ(frames, GetTabURL()); |
306 } | 327 } |
307 | 328 |
| 329 |
| 330 #if defined(OS_WIN) |
| 331 // See http://crbug.com/61619 |
| 332 #define MAYBE_FragmentBackForward FLAKY_FragmentBackForward |
| 333 #else |
| 334 #define MAYBE_FragmentBackForward FragmentBackForward |
| 335 #endif |
| 336 |
308 // Test that back/forward entries are created for reference fragment | 337 // Test that back/forward entries are created for reference fragment |
309 // navigations. Bug 730379. | 338 // navigations. Bug 730379. |
310 TEST_F(SessionHistoryTest, FragmentBackForward) { | 339 TEST_F(SessionHistoryTest, MAYBE_FragmentBackForward) { |
311 ASSERT_TRUE(test_server_.Start()); | 340 ASSERT_TRUE(test_server_.Start()); |
312 | 341 |
313 // about:blank should be loaded first. | 342 // about:blank should be loaded first. |
314 ASSERT_FALSE(tab_->GoBack()); | 343 ASSERT_FALSE(tab_->GoBack()); |
315 EXPECT_EQ(L"", GetTabTitle()); | 344 EXPECT_EQ(L"", GetTabTitle()); |
316 | 345 |
317 GURL fragment(test_server_.GetURL("files/session_history/fragment.html")); | 346 GURL fragment(test_server_.GetURL("files/session_history/fragment.html")); |
318 ASSERT_TRUE(tab_->NavigateToURL(fragment)); | 347 ASSERT_TRUE(tab_->NavigateToURL(fragment)); |
319 EXPECT_EQ(L"fragment", GetTabTitle()); | 348 EXPECT_EQ(L"fragment", GetTabTitle()); |
320 EXPECT_EQ(fragment, GetTabURL()); | 349 EXPECT_EQ(fragment, GetTabURL()); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 "#q=%3Cimg%20src%3Dx%3Ax%20onerror%3D%22document.title%3D'XSS'%22%3E"); | 507 "#q=%3Cimg%20src%3Dx%3Ax%20onerror%3D%22document.title%3D'XSS'%22%3E"); |
479 ASSERT_TRUE(tab_->NavigateToURL(url)); | 508 ASSERT_TRUE(tab_->NavigateToURL(url)); |
480 // Mainly, this is to ensure we send a synchronous message to the renderer | 509 // Mainly, this is to ensure we send a synchronous message to the renderer |
481 // so that we're not susceptible (less susceptible?) to a race condition. | 510 // so that we're not susceptible (less susceptible?) to a race condition. |
482 // Should a race condition ever trigger, it won't result in flakiness. | 511 // Should a race condition ever trigger, it won't result in flakiness. |
483 int num = tab_->FindInPage(L"<img", FWD, CASE_SENSITIVE, false, NULL); | 512 int num = tab_->FindInPage(L"<img", FWD, CASE_SENSITIVE, false, NULL); |
484 EXPECT_GT(num, 0); | 513 EXPECT_GT(num, 0); |
485 EXPECT_EQ(L"History", GetTabTitle()); | 514 EXPECT_EQ(L"History", GetTabTitle()); |
486 } | 515 } |
487 | 516 |
488 TEST_F(SessionHistoryTest, LocationChangeInSubframe) { | 517 #if defined(OS_WIN) |
| 518 // See http://crbug.com/61619 |
| 519 #define MAYBE_LocationChangeInSubframe FLAKY_LocationChangeInSubframe |
| 520 #else |
| 521 #define MAYBE_LocationChangeInSubframe LocationChangeInSubframe |
| 522 #endif |
| 523 |
| 524 TEST_F(SessionHistoryTest, MAYBE_LocationChangeInSubframe) { |
489 ASSERT_TRUE(test_server_.Start()); | 525 ASSERT_TRUE(test_server_.Start()); |
490 | 526 |
491 ASSERT_TRUE(tab_->NavigateToURL(test_server_.GetURL( | 527 ASSERT_TRUE(tab_->NavigateToURL(test_server_.GetURL( |
492 "files/session_history/location_redirect.html"))); | 528 "files/session_history/location_redirect.html"))); |
493 EXPECT_EQ(L"Default Title", GetTabTitle()); | 529 EXPECT_EQ(L"Default Title", GetTabTitle()); |
494 | 530 |
495 ASSERT_TRUE(tab_->NavigateToURL(GURL( | 531 ASSERT_TRUE(tab_->NavigateToURL(GURL( |
496 "javascript:void(frames[0].navigate())"))); | 532 "javascript:void(frames[0].navigate())"))); |
497 EXPECT_EQ(L"foo", GetTabTitle()); | 533 EXPECT_EQ(L"foo", GetTabTitle()); |
498 | 534 |
(...skipping 30 matching lines...) Expand all Loading... |
529 ASSERT_TRUE(tab_->GoBack()); | 565 ASSERT_TRUE(tab_->GoBack()); |
530 | 566 |
531 // Ensure history.length is properly truncated. | 567 // Ensure history.length is properly truncated. |
532 ASSERT_TRUE(tab_->NavigateToURL(test_server_.GetURL("files/title2.html"))); | 568 ASSERT_TRUE(tab_->NavigateToURL(test_server_.GetURL("files/title2.html"))); |
533 ASSERT_TRUE(tab_->ExecuteAndExtractInt( | 569 ASSERT_TRUE(tab_->ExecuteAndExtractInt( |
534 L"", L"domAutomationController.send(history.length)", &length)); | 570 L"", L"domAutomationController.send(history.length)", &length)); |
535 EXPECT_EQ(2, length); | 571 EXPECT_EQ(2, length); |
536 } | 572 } |
537 | 573 |
538 } // namespace | 574 } // namespace |
OLD | NEW |