Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(851)

Unified Diff: content/renderer/render_frame_impl_browsertest.cc

Issue 2114213002: Fix loading placeholders for Lo-Fi (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: whitespace fix and rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 61fd6b341e98ecebb015e99d9ea658ef2b1d19e5..f56d6ce914aaaace97cc1f9f33b1cf9d636d2a76 100644
--- a/content/renderer/render_frame_impl_browsertest.cc
+++ b/content/renderer/render_frame_impl_browsertest.cc
@@ -235,6 +235,52 @@ TEST_F(RenderFrameImplTest, LoFiNotUpdatedOnSubframeCommits) {
// frame detach.
}
+// Test that LoFi state updates on all frames on image load.
+TEST_F(RenderFrameImplTest, LoFiStateUpdatedOnImageLoad) {
+ SetIsUsingLoFi(GetMainRenderFrame(), true);
+ SetIsUsingLoFi(frame(), true);
+ EXPECT_TRUE(GetMainRenderFrame()->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, true);
+ EXPECT_TRUE(frame()->IsUsingLoFi());
+ GetMainRenderFrame()->didNavigateWithinPage(
+ GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit,
+ true);
+ EXPECT_TRUE(GetMainRenderFrame()->IsUsingLoFi());
+
+ // The subframe's LoFi state should not be reset on commit.
+ DocumentState* document_state =
+ DocumentState::FromDataSource(frame()->GetWebFrame()->dataSource());
+ static_cast<NavigationStateImpl*>(document_state->navigation_state())
+ ->set_was_within_same_page(false);
+
+ frame()->didCommitProvisionalLoad(frame()->GetWebFrame(), item,
+ blink::WebStandardCommit);
+ EXPECT_TRUE(frame()->IsUsingLoFi());
+
+ // The main frame's LoFi state should be reset to off on commit.
+ document_state = DocumentState::FromDataSource(
+ GetMainRenderFrame()->GetWebFrame()->dataSource());
+ static_cast<NavigationStateImpl*>(document_state->navigation_state())
+ ->set_was_within_same_page(false);
+
+ // Calling didCommitProvisionalLoad is not representative of a full navigation
+ // but serves the purpose of testing the LoFi state logic.
+ GetMainRenderFrame()->didCommitProvisionalLoad(
+ GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit);
+ EXPECT_FALSE(GetMainRenderFrame()->IsUsingLoFi());
+ // The subframe would be deleted here after a cross-document navigation. It
+ // happens to be left around in this test because this does not simulate the
+ // frame detach.
+}
+
// Test that effective connection type only updates for new main frame
// documents.
TEST_F(RenderFrameImplTest, EffectiveConnectionType) {

Powered by Google App Engine
This is Rietveld 408576698