| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1683 // Now simulate the corresponding up event which should display the menu | 1683 // Now simulate the corresponding up event which should display the menu |
| 1684 mouse_event.type = WebInputEvent::MouseUp; | 1684 mouse_event.type = WebInputEvent::MouseUp; |
| 1685 SendWebMouseEvent(mouse_event); | 1685 SendWebMouseEvent(mouse_event); |
| 1686 | 1686 |
| 1687 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( | 1687 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( |
| 1688 FrameHostMsg_ContextMenu::ID)); | 1688 FrameHostMsg_ContextMenu::ID)); |
| 1689 } | 1689 } |
| 1690 | 1690 |
| 1691 TEST_F(RenderViewImplTest, TestBackForward) { | 1691 TEST_F(RenderViewImplTest, TestBackForward) { |
| 1692 LoadHTML("<div id=pagename>Page A</div>"); | 1692 LoadHTML("<div id=pagename>Page A</div>"); |
| 1693 PageState page_a_state = | 1693 PageState page_a_state = GetCurrentPageState(); |
| 1694 HistoryEntryToPageState(view()->history_controller()->GetCurrentEntry()); | |
| 1695 int was_page_a = -1; | 1694 int was_page_a = -1; |
| 1696 base::string16 check_page_a = | 1695 base::string16 check_page_a = |
| 1697 base::ASCIIToUTF16( | 1696 base::ASCIIToUTF16( |
| 1698 "Number(document.getElementById('pagename').innerHTML == 'Page A')"); | 1697 "Number(document.getElementById('pagename').innerHTML == 'Page A')"); |
| 1699 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_a, &was_page_a)); | 1698 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_a, &was_page_a)); |
| 1700 EXPECT_EQ(1, was_page_a); | 1699 EXPECT_EQ(1, was_page_a); |
| 1701 | 1700 |
| 1702 LoadHTML("<div id=pagename>Page B</div>"); | 1701 LoadHTML("<div id=pagename>Page B</div>"); |
| 1703 int was_page_b = -1; | 1702 int was_page_b = -1; |
| 1704 base::string16 check_page_b = | 1703 base::string16 check_page_b = |
| 1705 base::ASCIIToUTF16( | 1704 base::ASCIIToUTF16( |
| 1706 "Number(document.getElementById('pagename').innerHTML == 'Page B')"); | 1705 "Number(document.getElementById('pagename').innerHTML == 'Page B')"); |
| 1707 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); | 1706 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); |
| 1708 EXPECT_EQ(1, was_page_b); | 1707 EXPECT_EQ(1, was_page_b); |
| 1709 | 1708 |
| 1710 PageState back_state = | 1709 PageState back_state = GetCurrentPageState(); |
| 1711 HistoryEntryToPageState(view()->history_controller()->GetCurrentEntry()); | |
| 1712 | 1710 |
| 1713 LoadHTML("<div id=pagename>Page C</div>"); | 1711 LoadHTML("<div id=pagename>Page C</div>"); |
| 1714 int was_page_c = -1; | 1712 int was_page_c = -1; |
| 1715 base::string16 check_page_c = | 1713 base::string16 check_page_c = |
| 1716 base::ASCIIToUTF16( | 1714 base::ASCIIToUTF16( |
| 1717 "Number(document.getElementById('pagename').innerHTML == 'Page C')"); | 1715 "Number(document.getElementById('pagename').innerHTML == 'Page C')"); |
| 1718 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c)); | 1716 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c)); |
| 1719 EXPECT_EQ(1, was_page_c); | 1717 EXPECT_EQ(1, was_page_c); |
| 1720 | 1718 |
| 1721 PageState forward_state = | 1719 PageState forward_state = GetCurrentPageState(); |
| 1722 HistoryEntryToPageState(view()->history_controller()->GetCurrentEntry()); | |
| 1723 GoBack(back_state); | 1720 GoBack(back_state); |
| 1724 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); | 1721 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); |
| 1725 EXPECT_EQ(1, was_page_b); | 1722 EXPECT_EQ(1, was_page_b); |
| 1726 | 1723 |
| 1727 PageState back_state2 = | 1724 PageState back_state2 = GetCurrentPageState(); |
| 1728 HistoryEntryToPageState(view()->history_controller()->GetCurrentEntry()); | |
| 1729 | 1725 |
| 1730 GoForward(forward_state); | 1726 GoForward(forward_state); |
| 1731 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c)); | 1727 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c)); |
| 1732 EXPECT_EQ(1, was_page_c); | 1728 EXPECT_EQ(1, was_page_c); |
| 1733 | 1729 |
| 1734 GoBack(back_state2); | 1730 GoBack(back_state2); |
| 1735 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); | 1731 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); |
| 1736 EXPECT_EQ(1, was_page_b); | 1732 EXPECT_EQ(1, was_page_b); |
| 1737 | 1733 |
| 1738 forward_state = | 1734 forward_state = GetCurrentPageState(); |
| 1739 HistoryEntryToPageState(view()->history_controller()->GetCurrentEntry()); | |
| 1740 GoBack(page_a_state); | 1735 GoBack(page_a_state); |
| 1741 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_a, &was_page_a)); | 1736 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_a, &was_page_a)); |
| 1742 EXPECT_EQ(1, was_page_a); | 1737 EXPECT_EQ(1, was_page_a); |
| 1743 | 1738 |
| 1744 GoForward(forward_state); | 1739 GoForward(forward_state); |
| 1745 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); | 1740 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); |
| 1746 EXPECT_EQ(1, was_page_b); | 1741 EXPECT_EQ(1, was_page_b); |
| 1747 } | 1742 } |
| 1748 | 1743 |
| 1749 #if defined(OS_MACOSX) || defined(USE_AURA) | 1744 #if defined(OS_MACOSX) || defined(USE_AURA) |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2382 FROM_HERE, | 2377 FROM_HERE, |
| 2383 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); | 2378 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); |
| 2384 ExecuteJavaScriptForTests("debugger;"); | 2379 ExecuteJavaScriptForTests("debugger;"); |
| 2385 | 2380 |
| 2386 // CloseWhilePaused should resume execution and continue here. | 2381 // CloseWhilePaused should resume execution and continue here. |
| 2387 EXPECT_FALSE(IsPaused()); | 2382 EXPECT_FALSE(IsPaused()); |
| 2388 Detach(); | 2383 Detach(); |
| 2389 } | 2384 } |
| 2390 | 2385 |
| 2391 } // namespace content | 2386 } // namespace content |
| OLD | NEW |