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

Side by Side 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 unified diff | Download patch
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/leak_annotations.h" 8 #include "base/debug/leak_annotations.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "content/common/frame_messages.h" 10 #include "content/common/frame_messages.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // Calling didCommitProvisionalLoad is not representative of a full navigation 228 // Calling didCommitProvisionalLoad is not representative of a full navigation
229 // but serves the purpose of testing the LoFi state logic. 229 // but serves the purpose of testing the LoFi state logic.
230 GetMainRenderFrame()->didCommitProvisionalLoad( 230 GetMainRenderFrame()->didCommitProvisionalLoad(
231 GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit); 231 GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit);
232 EXPECT_FALSE(GetMainRenderFrame()->IsUsingLoFi()); 232 EXPECT_FALSE(GetMainRenderFrame()->IsUsingLoFi());
233 // The subframe would be deleted here after a cross-document navigation. It 233 // The subframe would be deleted here after a cross-document navigation. It
234 // happens to be left around in this test because this does not simulate the 234 // happens to be left around in this test because this does not simulate the
235 // frame detach. 235 // frame detach.
236 } 236 }
237 237
238 // Test that LoFi state updates on all frames on image load.
239 TEST_F(RenderFrameImplTest, LoFiStateUpdatedOnImageLoad) {
240 SetIsUsingLoFi(GetMainRenderFrame(), true);
241 SetIsUsingLoFi(frame(), true);
242 EXPECT_TRUE(GetMainRenderFrame()->IsUsingLoFi());
243 EXPECT_TRUE(frame()->IsUsingLoFi());
244
245 blink::WebHistoryItem item;
246 item.initialize();
247
248 // The main frame's and subframe's LoFi states should stay the same on
249 // navigations within the page.
250 frame()->didNavigateWithinPage(frame()->GetWebFrame(), item,
251 blink::WebStandardCommit, true);
252 EXPECT_TRUE(frame()->IsUsingLoFi());
253 GetMainRenderFrame()->didNavigateWithinPage(
254 GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit,
255 true);
256 EXPECT_TRUE(GetMainRenderFrame()->IsUsingLoFi());
257
258 // The subframe's LoFi state should not be reset on commit.
259 DocumentState* document_state =
260 DocumentState::FromDataSource(frame()->GetWebFrame()->dataSource());
261 static_cast<NavigationStateImpl*>(document_state->navigation_state())
262 ->set_was_within_same_page(false);
263
264 frame()->didCommitProvisionalLoad(frame()->GetWebFrame(), item,
265 blink::WebStandardCommit);
266 EXPECT_TRUE(frame()->IsUsingLoFi());
267
268 // The main frame's LoFi state should be reset to off on commit.
269 document_state = DocumentState::FromDataSource(
270 GetMainRenderFrame()->GetWebFrame()->dataSource());
271 static_cast<NavigationStateImpl*>(document_state->navigation_state())
272 ->set_was_within_same_page(false);
273
274 // Calling didCommitProvisionalLoad is not representative of a full navigation
275 // but serves the purpose of testing the LoFi state logic.
276 GetMainRenderFrame()->didCommitProvisionalLoad(
277 GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit);
278 EXPECT_FALSE(GetMainRenderFrame()->IsUsingLoFi());
279 // The subframe would be deleted here after a cross-document navigation. It
280 // happens to be left around in this test because this does not simulate the
281 // frame detach.
282 }
283
238 // Test that effective connection type only updates for new main frame 284 // Test that effective connection type only updates for new main frame
239 // documents. 285 // documents.
240 TEST_F(RenderFrameImplTest, EffectiveConnectionType) { 286 TEST_F(RenderFrameImplTest, EffectiveConnectionType) {
241 EXPECT_EQ(blink::WebEffectiveConnectionType::TypeUnknown, 287 EXPECT_EQ(blink::WebEffectiveConnectionType::TypeUnknown,
242 frame()->getEffectiveConnectionType()); 288 frame()->getEffectiveConnectionType());
243 EXPECT_EQ(blink::WebEffectiveConnectionType::TypeUnknown, 289 EXPECT_EQ(blink::WebEffectiveConnectionType::TypeUnknown,
244 GetMainRenderFrame()->getEffectiveConnectionType()); 290 GetMainRenderFrame()->getEffectiveConnectionType());
245 291
246 const struct { 292 const struct {
247 blink::WebEffectiveConnectionType type; 293 blink::WebEffectiveConnectionType type;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 const std::string exceeded_data_url(1024 * 1024 * 20 + 1, 'd'); 383 const std::string exceeded_data_url(1024 * 1024 * 20 + 1, 'd');
338 384
339 frame()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url)); 385 frame()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url));
340 ProcessPendingMessages(); 386 ProcessPendingMessages();
341 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching( 387 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching(
342 FrameHostMsg_SaveImageFromDataURL::ID); 388 FrameHostMsg_SaveImageFromDataURL::ID);
343 EXPECT_FALSE(msg4); 389 EXPECT_FALSE(msg4);
344 } 390 }
345 391
346 } // namespace 392 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698