| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "content/common/site_isolation_policy.h" |
| 5 #include "content/public/test/render_view_test.h" | 6 #include "content/public/test/render_view_test.h" |
| 6 #include "content/renderer/history_controller.h" | 7 #include "content/renderer/history_controller.h" |
| 7 #include "content/renderer/render_frame_impl.h" | 8 #include "content/renderer/render_frame_impl.h" |
| 8 #include "content/renderer/render_view_impl.h" | 9 #include "content/renderer/render_view_impl.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 11 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
| 11 | 12 |
| 12 namespace content { | 13 namespace content { |
| 13 | 14 |
| 14 class HistoryControllerTest : public RenderViewTest { | 15 class HistoryControllerTest : public RenderViewTest { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 #if defined(OS_ANDROID) | 32 #if defined(OS_ANDROID) |
| 32 // See https://crbug.com/472717 | 33 // See https://crbug.com/472717 |
| 33 #define MAYBE_InertCommitRemovesChildren DISABLED_InertCommitRemovesChildren | 34 #define MAYBE_InertCommitRemovesChildren DISABLED_InertCommitRemovesChildren |
| 34 #else | 35 #else |
| 35 #define MAYBE_InertCommitRemovesChildren InertCommitRemovesChildren | 36 #define MAYBE_InertCommitRemovesChildren InertCommitRemovesChildren |
| 36 #endif | 37 #endif |
| 37 | 38 |
| 38 TEST_F(HistoryControllerTest, MAYBE_InertCommitRemovesChildren) { | 39 TEST_F(HistoryControllerTest, MAYBE_InertCommitRemovesChildren) { |
| 40 // This test is moot when subframe FrameNavigationEntries are enabled, since |
| 41 // we don't use HistoryController in that case. |
| 42 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
| 43 return; |
| 44 |
| 39 HistoryEntry* entry = history_controller()->GetCurrentEntry(); | 45 HistoryEntry* entry = history_controller()->GetCurrentEntry(); |
| 40 ASSERT_TRUE(entry); | 46 ASSERT_TRUE(entry); |
| 41 ASSERT_EQ(1ul, entry->root_history_node()->children().size()); | 47 ASSERT_EQ(1ul, entry->root_history_node()->children().size()); |
| 42 | 48 |
| 43 blink::WebHistoryItem item; | 49 blink::WebHistoryItem item; |
| 44 item.initialize(); | 50 item.initialize(); |
| 45 RenderFrameImpl* main_frame = | 51 RenderFrameImpl* main_frame = |
| 46 static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame()); | 52 static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame()); |
| 47 | 53 |
| 48 // Don't clear children for in-page navigations. | 54 // Don't clear children for in-page navigations. |
| 49 history_controller()->UpdateForCommit(main_frame, item, | 55 history_controller()->UpdateForCommit(main_frame, item, |
| 50 blink::WebHistoryInertCommit, true); | 56 blink::WebHistoryInertCommit, true); |
| 51 EXPECT_EQ(1ul, entry->root_history_node()->children().size()); | 57 EXPECT_EQ(1ul, entry->root_history_node()->children().size()); |
| 52 | 58 |
| 53 // Clear children for cross-page navigations. | 59 // Clear children for cross-page navigations. |
| 54 history_controller()->UpdateForCommit(main_frame, item, | 60 history_controller()->UpdateForCommit(main_frame, item, |
| 55 blink::WebHistoryInertCommit, false); | 61 blink::WebHistoryInertCommit, false); |
| 56 EXPECT_EQ(0ul, entry->root_history_node()->children().size()); | 62 EXPECT_EQ(0ul, entry->root_history_node()->children().size()); |
| 57 } | 63 } |
| 58 | 64 |
| 59 } // namespace | 65 } // namespace |
| OLD | NEW |