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 "content/public/browser/navigation_controller.h" | 7 #include "content/public/browser/navigation_controller.h" |
8 #include "content/public/browser/notification_service.h" | 8 #include "content/public/browser/notification_service.h" |
9 #include "content/public/browser/notification_types.h" | 9 #include "content/public/browser/notification_types.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 424 |
425 GoBack(); | 425 GoBack(); |
426 EXPECT_EQ("Default Title", GetTabTitle()); | 426 EXPECT_EQ("Default Title", GetTabTitle()); |
427 } | 427 } |
428 | 428 |
429 // http://code.google.com/p/chromium/issues/detail?id=56267 | 429 // http://code.google.com/p/chromium/issues/detail?id=56267 |
430 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, HistoryLength) { | 430 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, HistoryLength) { |
431 int length; | 431 int length; |
432 ASSERT_TRUE(ExecuteJavaScriptAndExtractInt( | 432 ASSERT_TRUE(ExecuteJavaScriptAndExtractInt( |
433 shell()->web_contents()->GetRenderViewHost(), | 433 shell()->web_contents()->GetRenderViewHost(), |
434 "", | 434 L"", L"domAutomationController.send(history.length)", &length)); |
435 "domAutomationController.send(history.length)", | |
436 &length)); | |
437 EXPECT_EQ(1, length); | 435 EXPECT_EQ(1, length); |
438 | 436 |
439 NavigateToURL(shell(), GetURL("title1.html")); | 437 NavigateToURL(shell(), GetURL("title1.html")); |
440 | 438 |
441 ASSERT_TRUE(ExecuteJavaScriptAndExtractInt( | 439 ASSERT_TRUE(ExecuteJavaScriptAndExtractInt( |
442 shell()->web_contents()->GetRenderViewHost(), | 440 shell()->web_contents()->GetRenderViewHost(), |
443 "", | 441 L"", L"domAutomationController.send(history.length)", &length)); |
444 "domAutomationController.send(history.length)", | |
445 &length)); | |
446 EXPECT_EQ(2, length); | 442 EXPECT_EQ(2, length); |
447 | 443 |
448 // Now test that history.length is updated when the navigation is committed. | 444 // Now test that history.length is updated when the navigation is committed. |
449 NavigateToURL(shell(), GetURL("record_length.html")); | 445 NavigateToURL(shell(), GetURL("record_length.html")); |
450 | 446 |
451 ASSERT_TRUE(ExecuteJavaScriptAndExtractInt( | 447 ASSERT_TRUE(ExecuteJavaScriptAndExtractInt( |
452 shell()->web_contents()->GetRenderViewHost(), | 448 shell()->web_contents()->GetRenderViewHost(), |
453 "", | 449 L"", L"domAutomationController.send(history.length)", &length)); |
454 "domAutomationController.send(history.length)", | |
455 &length)); | |
456 EXPECT_EQ(3, length); | 450 EXPECT_EQ(3, length); |
457 | 451 |
458 GoBack(); | 452 GoBack(); |
459 GoBack(); | 453 GoBack(); |
460 | 454 |
461 // Ensure history.length is properly truncated. | 455 // Ensure history.length is properly truncated. |
462 NavigateToURL(shell(), GetURL("title2.html")); | 456 NavigateToURL(shell(), GetURL("title2.html")); |
463 | 457 |
464 ASSERT_TRUE(ExecuteJavaScriptAndExtractInt( | 458 ASSERT_TRUE(ExecuteJavaScriptAndExtractInt( |
465 shell()->web_contents()->GetRenderViewHost(), | 459 shell()->web_contents()->GetRenderViewHost(), |
466 "", | 460 L"", L"domAutomationController.send(history.length)", &length)); |
467 "domAutomationController.send(history.length)", | |
468 &length)); | |
469 EXPECT_EQ(2, length); | 461 EXPECT_EQ(2, length); |
470 } | 462 } |
471 | 463 |
472 } // namespace content | 464 } // namespace content |
OLD | NEW |