| 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 "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
| 9 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 browser(), GURL("javascript:void(frames[0].navigate())")); | 427 browser(), GURL("javascript:void(frames[0].navigate())")); |
| 428 EXPECT_EQ("foo", GetTabTitle()); | 428 EXPECT_EQ("foo", GetTabTitle()); |
| 429 | 429 |
| 430 GoBack(); | 430 GoBack(); |
| 431 EXPECT_EQ("Default Title", GetTabTitle()); | 431 EXPECT_EQ("Default Title", GetTabTitle()); |
| 432 } | 432 } |
| 433 | 433 |
| 434 // http://code.google.com/p/chromium/issues/detail?id=56267 | 434 // http://code.google.com/p/chromium/issues/detail?id=56267 |
| 435 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, HistoryLength) { | 435 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, HistoryLength) { |
| 436 int length; | 436 int length; |
| 437 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( | 437 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractInt( |
| 438 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 438 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 439 L"", L"domAutomationController.send(history.length)", &length)); | 439 L"", L"domAutomationController.send(history.length)", &length)); |
| 440 EXPECT_EQ(1, length); | 440 EXPECT_EQ(1, length); |
| 441 | 441 |
| 442 ui_test_utils::NavigateToURL(browser(), GetURL("title1.html")); | 442 ui_test_utils::NavigateToURL(browser(), GetURL("title1.html")); |
| 443 | 443 |
| 444 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( | 444 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractInt( |
| 445 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 445 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 446 L"", L"domAutomationController.send(history.length)", &length)); | 446 L"", L"domAutomationController.send(history.length)", &length)); |
| 447 EXPECT_EQ(2, length); | 447 EXPECT_EQ(2, length); |
| 448 | 448 |
| 449 // Now test that history.length is updated when the navigation is committed. | 449 // Now test that history.length is updated when the navigation is committed. |
| 450 ui_test_utils::NavigateToURL(browser(), GetURL("record_length.html")); | 450 ui_test_utils::NavigateToURL(browser(), GetURL("record_length.html")); |
| 451 | 451 |
| 452 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( | 452 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractInt( |
| 453 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 453 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 454 L"", L"domAutomationController.send(history.length)", &length)); | 454 L"", L"domAutomationController.send(history.length)", &length)); |
| 455 EXPECT_EQ(3, length); | 455 EXPECT_EQ(3, length); |
| 456 | 456 |
| 457 GoBack(); | 457 GoBack(); |
| 458 GoBack(); | 458 GoBack(); |
| 459 | 459 |
| 460 // Ensure history.length is properly truncated. | 460 // Ensure history.length is properly truncated. |
| 461 ui_test_utils::NavigateToURL(browser(), GetURL("title2.html")); | 461 ui_test_utils::NavigateToURL(browser(), GetURL("title2.html")); |
| 462 | 462 |
| 463 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( | 463 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractInt( |
| 464 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 464 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 465 L"", L"domAutomationController.send(history.length)", &length)); | 465 L"", L"domAutomationController.send(history.length)", &length)); |
| 466 EXPECT_EQ(2, length); | 466 EXPECT_EQ(2, length); |
| 467 } | 467 } |
| OLD | NEW |