Update V8 to version 4.6.61.
[chromium-blink-merge.git] / content / renderer / history_controller_browsertest.cc
blob002b95af6004374823f5beb513a0d803f187e6e1
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/public/test/render_view_test.h"
6 #include "content/renderer/history_controller.h"
7 #include "content/renderer/render_frame_impl.h"
8 #include "content/renderer/render_view_impl.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/public/web/WebHistoryItem.h"
12 namespace content {
14 class HistoryControllerTest : public RenderViewTest {
15 public:
16 ~HistoryControllerTest() override {}
18 // Create a main frame with a single child frame.
19 void SetUp() override {
20 RenderViewTest::SetUp();
21 LoadHTML("Parent frame <iframe name='frame'></iframe>");
24 void TearDown() override { RenderViewTest::TearDown(); }
26 HistoryController* history_controller() {
27 return static_cast<RenderViewImpl*>(view_)->history_controller();
31 #if defined(OS_ANDROID)
32 // See https://crbug.com/472717
33 #define MAYBE_InertCommitRemovesChildren DISABLED_InertCommitRemovesChildren
34 #else
35 #define MAYBE_InertCommitRemovesChildren InertCommitRemovesChildren
36 #endif
38 TEST_F(HistoryControllerTest, MAYBE_InertCommitRemovesChildren) {
39 HistoryEntry* entry = history_controller()->GetCurrentEntry();
40 ASSERT_TRUE(entry);
41 ASSERT_EQ(1ul, entry->root_history_node()->children().size());
43 blink::WebHistoryItem item;
44 item.initialize();
45 RenderFrameImpl* main_frame =
46 static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame());
48 // Don't clear children for in-page navigations.
49 history_controller()->UpdateForCommit(main_frame, item,
50 blink::WebHistoryInertCommit, true);
51 EXPECT_EQ(1ul, entry->root_history_node()->children().size());
53 // Clear children for cross-page navigations.
54 history_controller()->UpdateForCommit(main_frame, item,
55 blink::WebHistoryInertCommit, false);
56 EXPECT_EQ(0ul, entry->root_history_node()->children().size());
59 } // namespace