OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "build/build_config.h" | |
6 #include "content/common/site_isolation_policy.h" | |
7 #include "content/public/test/render_view_test.h" | |
8 #include "content/renderer/history_controller.h" | |
9 #include "content/renderer/render_frame_impl.h" | |
10 #include "content/renderer/render_view_impl.h" | |
11 #include "testing/gtest/include/gtest/gtest.h" | |
12 #include "third_party/WebKit/public/web/WebHistoryItem.h" | |
13 | |
14 namespace content { | |
15 | |
16 class HistoryControllerTest : public RenderViewTest { | |
17 public: | |
18 ~HistoryControllerTest() override {} | |
19 | |
20 // Create a main frame with a single child frame. | |
21 void SetUp() override { | |
22 RenderViewTest::SetUp(); | |
23 LoadHTML("Parent frame <iframe name='frame'></iframe>"); | |
24 } | |
25 | |
26 void TearDown() override { RenderViewTest::TearDown(); } | |
27 | |
28 HistoryController* history_controller() { | |
29 return static_cast<RenderViewImpl*>(view_)->history_controller(); | |
30 } | |
31 }; | |
32 | |
33 #if defined(OS_ANDROID) | |
34 // See https://crbug.com/472717 | |
35 #define MAYBE_InertCommitRemovesChildren DISABLED_InertCommitRemovesChildren | |
36 #else | |
37 #define MAYBE_InertCommitRemovesChildren InertCommitRemovesChildren | |
38 #endif | |
39 | |
40 TEST_F(HistoryControllerTest, MAYBE_InertCommitRemovesChildren) { | |
Charlie Reis
2017/01/24 17:34:24
This one seems more like a unit test, and we have
| |
41 // This test is moot when subframe FrameNavigationEntries are enabled, since | |
42 // we don't use HistoryController in that case. | |
43 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | |
44 return; | |
45 | |
46 HistoryEntry* entry = history_controller()->GetCurrentEntry(); | |
47 ASSERT_TRUE(entry); | |
48 ASSERT_EQ(1ul, entry->root_history_node()->children().size()); | |
49 | |
50 blink::WebHistoryItem item; | |
51 item.initialize(); | |
52 RenderFrameImpl* main_frame = | |
53 static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame()); | |
54 | |
55 // Don't clear children for in-page navigations. | |
56 history_controller()->UpdateForCommit(main_frame, item, | |
57 blink::WebHistoryInertCommit, true); | |
58 EXPECT_EQ(1ul, entry->root_history_node()->children().size()); | |
59 | |
60 // Clear children for cross-page navigations. | |
61 history_controller()->UpdateForCommit(main_frame, item, | |
62 blink::WebHistoryInertCommit, false); | |
63 EXPECT_EQ(0ul, entry->root_history_node()->children().size()); | |
64 } | |
65 | |
66 } // namespace | |
OLD | NEW |