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 "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" |
11 #include "chrome/test/automation/browser_proxy.h" | 11 #include "chrome/test/automation/browser_proxy.h" |
12 #include "chrome/test/ui/ui_test.h" | 12 #include "chrome/test/ui/ui_test.h" |
13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
14 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
15 #include "net/url_request/url_request_unittest.h" | 15 #include "net/url_request/url_request_unittest.h" |
16 | 16 |
17 using std::wstring; | 17 using std::wstring; |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const wchar_t kDocRoot[] = L"chrome/test/data"; | 21 const wchar_t kDocRoot[] = L"chrome/test/data"; |
22 | 22 |
23 class SessionHistoryTest : public UITest { | 23 class SessionHistoryTest : public UITest { |
24 protected: | 24 protected: |
25 SessionHistoryTest() : UITest() { | 25 SessionHistoryTest() : UITest() { |
| 26 dom_automation_enabled_ = true; |
26 } | 27 } |
27 | 28 |
28 virtual void SetUp() { | 29 virtual void SetUp() { |
29 UITest::SetUp(); | 30 UITest::SetUp(); |
30 | 31 |
31 window_ = automation()->GetBrowserWindow(0); | 32 window_ = automation()->GetBrowserWindow(0); |
32 ASSERT_TRUE(window_.get()); | 33 ASSERT_TRUE(window_.get()); |
33 | 34 |
34 int active_tab_index = -1; | 35 int active_tab_index = -1; |
35 ASSERT_TRUE(window_->GetActiveTabIndex(&active_tab_index)); | 36 ASSERT_TRUE(window_->GetActiveTabIndex(&active_tab_index)); |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 EXPECT_EQ(L"Default Title", GetTabTitle()); | 509 EXPECT_EQ(L"Default Title", GetTabTitle()); |
509 | 510 |
510 ASSERT_TRUE(tab_->NavigateToURL(GURL( | 511 ASSERT_TRUE(tab_->NavigateToURL(GURL( |
511 "javascript:void(frames[0].navigate())"))); | 512 "javascript:void(frames[0].navigate())"))); |
512 EXPECT_EQ(L"foo", GetTabTitle()); | 513 EXPECT_EQ(L"foo", GetTabTitle()); |
513 | 514 |
514 ASSERT_TRUE(tab_->GoBack()); | 515 ASSERT_TRUE(tab_->GoBack()); |
515 EXPECT_EQ(L"Default Title", GetTabTitle()); | 516 EXPECT_EQ(L"Default Title", GetTabTitle()); |
516 } | 517 } |
517 | 518 |
| 519 TEST_F(SessionHistoryTest, HistoryLength) { |
| 520 scoped_refptr<HTTPTestServer> server = |
| 521 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 522 ASSERT_TRUE(server.get()); |
| 523 |
| 524 int length; |
| 525 ASSERT_TRUE(tab_->ExecuteAndExtractInt( |
| 526 L"", L"domAutomationController.send(history.length)", &length)); |
| 527 EXPECT_EQ(1, length); |
| 528 |
| 529 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage("files/title1.html"))); |
| 530 |
| 531 ASSERT_TRUE(tab_->ExecuteAndExtractInt( |
| 532 L"", L"domAutomationController.send(history.length)", &length)); |
| 533 EXPECT_EQ(2, length); |
| 534 |
| 535 // Now test that history.length is updated when the navigation is committed. |
| 536 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage( |
| 537 "files/session_history/record_length.html"))); |
| 538 ASSERT_TRUE(tab_->ExecuteAndExtractInt( |
| 539 L"", L"domAutomationController.send(history.length)", &length)); |
| 540 EXPECT_EQ(3, length); |
| 541 ASSERT_TRUE(tab_->ExecuteAndExtractInt( |
| 542 L"", L"domAutomationController.send(history_length)", &length)); |
| 543 EXPECT_EQ(3, length); |
| 544 |
| 545 ASSERT_TRUE(tab_->GoBack()); |
| 546 ASSERT_TRUE(tab_->GoBack()); |
| 547 |
| 548 // Ensure history.length is properly truncated. |
| 549 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage("files/title2.html"))); |
| 550 ASSERT_TRUE(tab_->ExecuteAndExtractInt( |
| 551 L"", L"domAutomationController.send(history.length)", &length)); |
| 552 EXPECT_EQ(2, length); |
| 553 } |
| 554 |
518 } // namespace | 555 } // namespace |
OLD | NEW |