Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: chrome/browser/session_history_uitest.cc

Issue 2881028: GTTF: test server cleanup: (Closed)
Patch Set: final Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "app/l10n_util.h" 5 #include "app/l10n_util.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/platform_thread.h" 7 #include "base/platform_thread.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "chrome/test/automation/tab_proxy.h" 10 #include "chrome/test/automation/tab_proxy.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 EXPECT_TRUE(tab_->GetCurrentURL(&url)); 74 EXPECT_TRUE(tab_->GetCurrentURL(&url));
75 return url; 75 return url;
76 } 76 }
77 77
78 protected: 78 protected:
79 scoped_refptr<BrowserProxy> window_; 79 scoped_refptr<BrowserProxy> window_;
80 scoped_refptr<TabProxy> tab_; 80 scoped_refptr<TabProxy> tab_;
81 }; 81 };
82 82
83 TEST_F(SessionHistoryTest, BasicBackForward) { 83 TEST_F(SessionHistoryTest, BasicBackForward) {
84 scoped_refptr<HTTPTestServer> server = 84 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot));
85 HTTPTestServer::CreateServer(kDocRoot, NULL);
86 ASSERT_TRUE(NULL != server.get()); 85 ASSERT_TRUE(NULL != server.get());
87 86
88 // about:blank should be loaded first. 87 // about:blank should be loaded first.
89 ASSERT_FALSE(tab_->GoBack()); 88 ASSERT_FALSE(tab_->GoBack());
90 EXPECT_EQ(L"", GetTabTitle()); 89 EXPECT_EQ(L"", GetTabTitle());
91 90
92 ASSERT_TRUE(tab_->NavigateToURL( 91 ASSERT_TRUE(tab_->NavigateToURL(
93 server->TestServerPage("files/session_history/bot1.html"))); 92 server->TestServerPage("files/session_history/bot1.html")));
94 EXPECT_EQ(L"bot1", GetTabTitle()); 93 EXPECT_EQ(L"bot1", GetTabTitle());
95 94
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 140 }
142 141
143 // Test that back/forward works when navigating in subframes. 142 // Test that back/forward works when navigating in subframes.
144 // Fails on Windows. See crbug.com/TODO 143 // Fails on Windows. See crbug.com/TODO
145 #if defined(OS_WIN) 144 #if defined(OS_WIN)
146 #define MAYBE_FrameBackForward FLAKY_FrameBackForward 145 #define MAYBE_FrameBackForward FLAKY_FrameBackForward
147 #else 146 #else
148 #define MAYBE_FrameBackForward FrameBackForward 147 #define MAYBE_FrameBackForward FrameBackForward
149 #endif 148 #endif
150 TEST_F(SessionHistoryTest, MAYBE_FrameBackForward) { 149 TEST_F(SessionHistoryTest, MAYBE_FrameBackForward) {
151 scoped_refptr<HTTPTestServer> server = 150 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot));
152 HTTPTestServer::CreateServer(kDocRoot, NULL);
153 ASSERT_TRUE(NULL != server.get()); 151 ASSERT_TRUE(NULL != server.get());
154 152
155 // about:blank should be loaded first. 153 // about:blank should be loaded first.
156 GURL home(WideToUTF8(homepage_)); 154 GURL home(WideToUTF8(homepage_));
157 ASSERT_FALSE(tab_->GoBack()); 155 ASSERT_FALSE(tab_->GoBack());
158 EXPECT_EQ(L"", GetTabTitle()); 156 EXPECT_EQ(L"", GetTabTitle());
159 EXPECT_EQ(home, GetTabURL()); 157 EXPECT_EQ(home, GetTabURL());
160 158
161 GURL frames(server->TestServerPage("files/session_history/frames.html")); 159 GURL frames(server->TestServerPage("files/session_history/frames.html"));
162 ASSERT_TRUE(tab_->NavigateToURL(frames)); 160 ASSERT_TRUE(tab_->NavigateToURL(frames));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 EXPECT_EQ(L"bot2", GetTabTitle()); 205 EXPECT_EQ(L"bot2", GetTabTitle());
208 EXPECT_EQ(frames, GetTabURL()); 206 EXPECT_EQ(frames, GetTabURL());
209 207
210 ASSERT_TRUE(tab_->GoBack()); 208 ASSERT_TRUE(tab_->GoBack());
211 EXPECT_EQ(L"bot1", GetTabTitle()); 209 EXPECT_EQ(L"bot1", GetTabTitle());
212 EXPECT_EQ(frames, GetTabURL()); 210 EXPECT_EQ(frames, GetTabURL());
213 } 211 }
214 212
215 // Test that back/forward preserves POST data and document state in subframes. 213 // Test that back/forward preserves POST data and document state in subframes.
216 TEST_F(SessionHistoryTest, FrameFormBackForward) { 214 TEST_F(SessionHistoryTest, FrameFormBackForward) {
217 scoped_refptr<HTTPTestServer> server = 215 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot));
218 HTTPTestServer::CreateServer(kDocRoot, NULL);
219 ASSERT_TRUE(NULL != server.get()); 216 ASSERT_TRUE(NULL != server.get());
220 217
221 // about:blank should be loaded first. 218 // about:blank should be loaded first.
222 ASSERT_FALSE(tab_->GoBack()); 219 ASSERT_FALSE(tab_->GoBack());
223 EXPECT_EQ(L"", GetTabTitle()); 220 EXPECT_EQ(L"", GetTabTitle());
224 221
225 GURL frames(server->TestServerPage("files/session_history/frames.html")); 222 GURL frames(server->TestServerPage("files/session_history/frames.html"));
226 ASSERT_TRUE(tab_->NavigateToURL(frames)); 223 ASSERT_TRUE(tab_->NavigateToURL(frames));
227 EXPECT_EQ(L"bot1", GetTabTitle()); 224 EXPECT_EQ(L"bot1", GetTabTitle());
228 225
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 266 }
270 } 267 }
271 268
272 // TODO(mpcomplete): enable this when Bug 734372 is fixed: 269 // TODO(mpcomplete): enable this when Bug 734372 is fixed:
273 // "Doing a session history navigation does not restore newly-created subframe 270 // "Doing a session history navigation does not restore newly-created subframe
274 // document state" 271 // document state"
275 // Test that back/forward preserves POST data and document state when navigating 272 // Test that back/forward preserves POST data and document state when navigating
276 // across frames (ie, from frame -> nonframe). 273 // across frames (ie, from frame -> nonframe).
277 // Hangs, see http://crbug.com/45058. 274 // Hangs, see http://crbug.com/45058.
278 TEST_F(SessionHistoryTest, DISABLED_CrossFrameFormBackForward) { 275 TEST_F(SessionHistoryTest, DISABLED_CrossFrameFormBackForward) {
279 scoped_refptr<HTTPTestServer> server = 276 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot));
280 HTTPTestServer::CreateServer(kDocRoot, NULL);
281 ASSERT_TRUE(NULL != server.get()); 277 ASSERT_TRUE(NULL != server.get());
282 278
283 // about:blank should be loaded first. 279 // about:blank should be loaded first.
284 ASSERT_FALSE(tab_->GoBack()); 280 ASSERT_FALSE(tab_->GoBack());
285 EXPECT_EQ(L"", GetTabTitle()); 281 EXPECT_EQ(L"", GetTabTitle());
286 282
287 GURL frames(server->TestServerPage("files/session_history/frames.html")); 283 GURL frames(server->TestServerPage("files/session_history/frames.html"));
288 ASSERT_TRUE(tab_->NavigateToURL(frames)); 284 ASSERT_TRUE(tab_->NavigateToURL(frames));
289 EXPECT_EQ(L"bot1", GetTabTitle()); 285 EXPECT_EQ(L"bot1", GetTabTitle());
290 286
(...skipping 24 matching lines...) Expand all
315 EXPECT_EQ(frames, GetTabURL()); 311 EXPECT_EQ(frames, GetTabURL());
316 312
317 SubmitForm("isubmit"); 313 SubmitForm("isubmit");
318 EXPECT_EQ(L"text=&select=a", GetTabTitle()); 314 EXPECT_EQ(L"text=&select=a", GetTabTitle());
319 EXPECT_EQ(frames, GetTabURL()); 315 EXPECT_EQ(frames, GetTabURL());
320 } 316 }
321 317
322 // Test that back/forward entries are created for reference fragment 318 // Test that back/forward entries are created for reference fragment
323 // navigations. Bug 730379. 319 // navigations. Bug 730379.
324 TEST_F(SessionHistoryTest, FragmentBackForward) { 320 TEST_F(SessionHistoryTest, FragmentBackForward) {
325 scoped_refptr<HTTPTestServer> server = 321 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot));
326 HTTPTestServer::CreateServer(kDocRoot, NULL);
327 ASSERT_TRUE(NULL != server.get()); 322 ASSERT_TRUE(NULL != server.get());
328 323
329 // about:blank should be loaded first. 324 // about:blank should be loaded first.
330 ASSERT_FALSE(tab_->GoBack()); 325 ASSERT_FALSE(tab_->GoBack());
331 EXPECT_EQ(L"", GetTabTitle()); 326 EXPECT_EQ(L"", GetTabTitle());
332 327
333 GURL fragment(server->TestServerPage("files/session_history/fragment.html")); 328 GURL fragment(server->TestServerPage("files/session_history/fragment.html"));
334 ASSERT_TRUE(tab_->NavigateToURL(fragment)); 329 ASSERT_TRUE(tab_->NavigateToURL(fragment));
335 EXPECT_EQ(L"fragment", GetTabTitle()); 330 EXPECT_EQ(L"fragment", GetTabTitle());
336 EXPECT_EQ(fragment, GetTabURL()); 331 EXPECT_EQ(fragment, GetTabURL());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 ASSERT_TRUE(tab_->GoBack()); 380 ASSERT_TRUE(tab_->GoBack());
386 EXPECT_EQ(fragment, GetTabURL()); 381 EXPECT_EQ(fragment, GetTabURL());
387 } 382 }
388 383
389 // Test that the javascript window.history object works. 384 // Test that the javascript window.history object works.
390 // NOTE: history.go(N) does not do anything if N is outside the bounds of the 385 // NOTE: history.go(N) does not do anything if N is outside the bounds of the
391 // back/forward list (such as trigger our start/stop loading events). This 386 // back/forward list (such as trigger our start/stop loading events). This
392 // means the test will hang if it attempts to navigate too far forward or back, 387 // means the test will hang if it attempts to navigate too far forward or back,
393 // since we'll be waiting forever for a load stop event. 388 // since we'll be waiting forever for a load stop event.
394 TEST_F(SessionHistoryTest, JavascriptHistory) { 389 TEST_F(SessionHistoryTest, JavascriptHistory) {
395 scoped_refptr<HTTPTestServer> server = 390 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot));
396 HTTPTestServer::CreateServer(kDocRoot, NULL);
397 ASSERT_TRUE(NULL != server.get()); 391 ASSERT_TRUE(NULL != server.get());
398 392
399 // about:blank should be loaded first. 393 // about:blank should be loaded first.
400 ASSERT_FALSE(tab_->GoBack()); 394 ASSERT_FALSE(tab_->GoBack());
401 EXPECT_EQ(L"", GetTabTitle()); 395 EXPECT_EQ(L"", GetTabTitle());
402 396
403 ASSERT_TRUE(tab_->NavigateToURL( 397 ASSERT_TRUE(tab_->NavigateToURL(
404 server->TestServerPage("files/session_history/bot1.html"))); 398 server->TestServerPage("files/session_history/bot1.html")));
405 EXPECT_EQ(L"bot1", GetTabTitle()); 399 EXPECT_EQ(L"bot1", GetTabTitle());
406 400
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 // try to go back and forward with JavaScript. Bug 1136715. 463 // try to go back and forward with JavaScript. Bug 1136715.
470 // (Hard to test right now, because pages like about:network cause the 464 // (Hard to test right now, because pages like about:network cause the
471 // TabProxy to hang. This is because they do not appear to use the 465 // TabProxy to hang. This is because they do not appear to use the
472 // NotificationService.) 466 // NotificationService.)
473 } 467 }
474 468
475 // This test is failing consistently. See http://crbug.com/22560 469 // This test is failing consistently. See http://crbug.com/22560
476 TEST_F(SessionHistoryTest, FAILS_LocationReplace) { 470 TEST_F(SessionHistoryTest, FAILS_LocationReplace) {
477 // Test that using location.replace doesn't leave the title of the old page 471 // Test that using location.replace doesn't leave the title of the old page
478 // visible. 472 // visible.
479 scoped_refptr<HTTPTestServer> server = 473 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot));
480 HTTPTestServer::CreateServer(kDocRoot, NULL);
481 ASSERT_TRUE(NULL != server.get()); 474 ASSERT_TRUE(NULL != server.get());
482 475
483 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage( 476 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage(
484 "files/session_history/replace.html?no-title.html"))); 477 "files/session_history/replace.html?no-title.html")));
485 EXPECT_EQ(L"", GetTabTitle()); 478 EXPECT_EQ(L"", GetTabTitle());
486 } 479 }
487 480
488 // This test is flaky. See bug 22111. 481 // This test is flaky. See bug 22111.
489 TEST_F(SessionHistoryTest, FLAKY_HistorySearchXSS) { 482 TEST_F(SessionHistoryTest, FLAKY_HistorySearchXSS) {
490 // about:blank should be loaded first. 483 // about:blank should be loaded first.
491 ASSERT_FALSE(tab_->GoBack()); 484 ASSERT_FALSE(tab_->GoBack());
492 EXPECT_EQ(L"", GetTabTitle()); 485 EXPECT_EQ(L"", GetTabTitle());
493 486
494 GURL url(std::string(chrome::kChromeUIHistoryURL) + 487 GURL url(std::string(chrome::kChromeUIHistoryURL) +
495 "#q=%3Cimg%20src%3Dx%3Ax%20onerror%3D%22document.title%3D'XSS'%22%3E"); 488 "#q=%3Cimg%20src%3Dx%3Ax%20onerror%3D%22document.title%3D'XSS'%22%3E");
496 ASSERT_TRUE(tab_->NavigateToURL(url)); 489 ASSERT_TRUE(tab_->NavigateToURL(url));
497 // Mainly, this is to ensure we send a synchronous message to the renderer 490 // Mainly, this is to ensure we send a synchronous message to the renderer
498 // so that we're not susceptible (less susceptible?) to a race condition. 491 // so that we're not susceptible (less susceptible?) to a race condition.
499 // Should a race condition ever trigger, it won't result in flakiness. 492 // Should a race condition ever trigger, it won't result in flakiness.
500 int num = tab_->FindInPage(L"<img", FWD, CASE_SENSITIVE, false, NULL); 493 int num = tab_->FindInPage(L"<img", FWD, CASE_SENSITIVE, false, NULL);
501 EXPECT_GT(num, 0); 494 EXPECT_GT(num, 0);
502 EXPECT_EQ(L"History", GetTabTitle()); 495 EXPECT_EQ(L"History", GetTabTitle());
503 } 496 }
504 497
505 TEST_F(SessionHistoryTest, LocationChangeInSubframe) { 498 TEST_F(SessionHistoryTest, LocationChangeInSubframe) {
506 scoped_refptr<HTTPTestServer> server = 499 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot));
507 HTTPTestServer::CreateServer(kDocRoot, NULL);
508 ASSERT_TRUE(server.get()); 500 ASSERT_TRUE(server.get());
509 501
510 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage( 502 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage(
511 "files/session_history/location_redirect.html"))); 503 "files/session_history/location_redirect.html")));
512 EXPECT_EQ(L"Default Title", GetTabTitle()); 504 EXPECT_EQ(L"Default Title", GetTabTitle());
513 505
514 ASSERT_TRUE(tab_->NavigateToURL(GURL( 506 ASSERT_TRUE(tab_->NavigateToURL(GURL(
515 "javascript:void(frames[0].navigate())"))); 507 "javascript:void(frames[0].navigate())")));
516 EXPECT_EQ(L"foo", GetTabTitle()); 508 EXPECT_EQ(L"foo", GetTabTitle());
517 509
518 ASSERT_TRUE(tab_->GoBack()); 510 ASSERT_TRUE(tab_->GoBack());
519 EXPECT_EQ(L"Default Title", GetTabTitle()); 511 EXPECT_EQ(L"Default Title", GetTabTitle());
520 } 512 }
521 513
522 // Hangs, see http://crbug.com/38583. 514 // Hangs, see http://crbug.com/38583.
523 #if defined(OS_WIN) 515 #if defined(OS_WIN)
524 #define HistoryLength DISABLED_HistoryLength 516 #define HistoryLength DISABLED_HistoryLength
525 #endif // defined(OS_WIN) 517 #endif // defined(OS_WIN)
526 TEST_F(SessionHistoryTest, HistoryLength) { 518 TEST_F(SessionHistoryTest, HistoryLength) {
527 scoped_refptr<HTTPTestServer> server = 519 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot));
528 HTTPTestServer::CreateServer(kDocRoot, NULL);
529 ASSERT_TRUE(server.get()); 520 ASSERT_TRUE(server.get());
530 521
531 int length; 522 int length;
532 ASSERT_TRUE(tab_->ExecuteAndExtractInt( 523 ASSERT_TRUE(tab_->ExecuteAndExtractInt(
533 L"", L"domAutomationController.send(history.length)", &length)); 524 L"", L"domAutomationController.send(history.length)", &length));
534 EXPECT_EQ(1, length); 525 EXPECT_EQ(1, length);
535 526
536 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage("files/title1.html"))); 527 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage("files/title1.html")));
537 528
538 ASSERT_TRUE(tab_->ExecuteAndExtractInt( 529 ASSERT_TRUE(tab_->ExecuteAndExtractInt(
(...skipping 14 matching lines...) Expand all
553 ASSERT_TRUE(tab_->GoBack()); 544 ASSERT_TRUE(tab_->GoBack());
554 545
555 // Ensure history.length is properly truncated. 546 // Ensure history.length is properly truncated.
556 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage("files/title2.html"))); 547 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage("files/title2.html")));
557 ASSERT_TRUE(tab_->ExecuteAndExtractInt( 548 ASSERT_TRUE(tab_->ExecuteAndExtractInt(
558 L"", L"domAutomationController.send(history.length)", &length)); 549 L"", L"domAutomationController.send(history.length)", &length));
559 EXPECT_EQ(2, length); 550 EXPECT_EQ(2, length);
560 } 551 }
561 552
562 } // namespace 553 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/repost_form_warning_uitest.cc ('k') | chrome/browser/sessions/session_restore_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698