Index: content/renderer/render_frame_impl_browsertest.cc |
diff --git a/content/renderer/render_frame_impl_browsertest.cc b/content/renderer/render_frame_impl_browsertest.cc |
index 311a4556e6ca49db85d3b38bdc8c48d56e4e817b..57381290710c15f249f8ed98167daaf33c1b72c8 100644 |
--- a/content/renderer/render_frame_impl_browsertest.cc |
+++ b/content/renderer/render_frame_impl_browsertest.cc |
@@ -9,15 +9,18 @@ |
#include "build/build_config.h" |
#include "content/common/frame_messages.h" |
#include "content/common/view_messages.h" |
+#include "content/public/renderer/document_state.h" |
#include "content/public/test/frame_load_waiter.h" |
#include "content/public/test/render_view_test.h" |
#include "content/public/test/test_utils.h" |
+#include "content/renderer/navigation_state_impl.h" |
#include "content/renderer/render_frame_impl.h" |
#include "content/renderer/render_view_impl.h" |
#include "content/test/fake_compositor_dependencies.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "third_party/WebKit/public/platform/WebURLRequest.h" |
#include "third_party/WebKit/public/web/WebFrameOwnerProperties.h" |
+#include "third_party/WebKit/public/web/WebHistoryItem.h" |
#include "third_party/WebKit/public/web/WebLocalFrame.h" |
namespace { |
@@ -71,6 +74,14 @@ class RenderFrameImplTest : public RenderViewTest { |
RenderViewTest::TearDown(); |
} |
+ void SetIsUsingLoFi(RenderFrameImpl* frame, bool is_using_lofi) { |
+ frame->is_using_lofi_ = is_using_lofi; |
+ } |
+ |
+ RenderFrameImpl* main_frame() { |
Charlie Reis
2016/02/04 19:30:30
Style nit: GetMainRenderFrame()
(hacker_case is f
megjablon
2016/02/04 20:02:31
Done.
|
+ return static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame()); |
+ } |
+ |
RenderFrameImpl* frame() { return frame_; } |
content::RenderWidget* frame_widget() const { |
@@ -177,4 +188,35 @@ TEST_F(RenderFrameImplTest, MAYBE_FrameWasShownAfterWidgetClose) { |
EXPECT_TRUE(observer.visible()); |
} |
+// Test that LoFi state only updates for new main frame documents. Subframes |
+// inherit from the main frame and should not change at commit time. |
+TEST_F(RenderFrameImplTest, LoFiNotUpdatedOnSubframeCommits) { |
+ SetIsUsingLoFi(main_frame(), true); |
+ SetIsUsingLoFi(frame(), true); |
+ EXPECT_TRUE(main_frame()->IsUsingLoFi()); |
+ EXPECT_TRUE(frame()->IsUsingLoFi()); |
+ |
+ blink::WebHistoryItem item; |
+ item.initialize(); |
+ |
+ // The main frame's and subframe's LoFi states should stay the same on |
+ // navigations within the page. |
+ frame()->didNavigateWithinPage(frame()->GetWebFrame(), item, |
+ blink::WebStandardCommit); |
+ EXPECT_TRUE(frame()->IsUsingLoFi()); |
+ main_frame()->didNavigateWithinPage(main_frame()->GetWebFrame(), item, |
+ blink::WebStandardCommit); |
+ EXPECT_TRUE(main_frame()->IsUsingLoFi()); |
Charlie Reis
2016/02/04 19:30:30
Can you add a test for the subframe doing a didCom
megjablon
2016/02/04 20:02:31
Done.
|
+ |
+ // The main frame's LoFi state should be reset to off on commit. |
+ DocumentState* document_state = |
+ DocumentState::FromDataSource(main_frame()->GetWebFrame()->dataSource()); |
+ static_cast<NavigationStateImpl*>(document_state->navigation_state()) |
+ ->set_was_within_same_page(false); |
+ |
+ main_frame()->didCommitProvisionalLoad(main_frame()->GetWebFrame(), item, |
Charlie Reis
2016/02/04 19:30:30
It's a little surprising to me that these work wit
megjablon
2016/02/04 20:02:31
Done. Comment added as discussed offline.
|
+ blink::WebStandardCommit); |
+ EXPECT_FALSE(main_frame()->IsUsingLoFi()); |
+} |
+ |
} // namespace |