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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2696283003: Revert of Don't create layout objects for children of display-none iframes. (Closed)
Patch Set: Created 3 years, 10 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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 #include "public/web/WebTextCheckingCompletion.h" 138 #include "public/web/WebTextCheckingCompletion.h"
139 #include "public/web/WebTextCheckingResult.h" 139 #include "public/web/WebTextCheckingResult.h"
140 #include "public/web/WebViewClient.h" 140 #include "public/web/WebViewClient.h"
141 #include "testing/gmock/include/gmock/gmock.h" 141 #include "testing/gmock/include/gmock/gmock.h"
142 #include "testing/gtest/include/gtest/gtest.h" 142 #include "testing/gtest/include/gtest/gtest.h"
143 #include "web/TextFinder.h" 143 #include "web/TextFinder.h"
144 #include "web/WebLocalFrameImpl.h" 144 #include "web/WebLocalFrameImpl.h"
145 #include "web/WebRemoteFrameImpl.h" 145 #include "web/WebRemoteFrameImpl.h"
146 #include "web/WebViewImpl.h" 146 #include "web/WebViewImpl.h"
147 #include "web/tests/FrameTestHelpers.h" 147 #include "web/tests/FrameTestHelpers.h"
148 #include "web/tests/sim/SimDisplayItemList.h"
149 #include "web/tests/sim/SimRequest.h"
150 #include "web/tests/sim/SimTest.h"
151 #include "wtf/Forward.h" 148 #include "wtf/Forward.h"
152 #include "wtf/PtrUtil.h" 149 #include "wtf/PtrUtil.h"
153 #include "wtf/dtoa/utils.h" 150 #include "wtf/dtoa/utils.h"
154 151
155 using blink::URLTestHelpers::toKURL; 152 using blink::URLTestHelpers::toKURL;
156 using blink::testing::runPendingTasks; 153 using blink::testing::runPendingTasks;
157 using testing::ElementsAre; 154 using testing::ElementsAre;
158 using testing::Mock; 155 using testing::Mock;
159 using testing::_; 156 using testing::_;
160 157
(...skipping 11137 matching lines...) Expand 10 before | Expand all | Expand 10 after
11298 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); 11295 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html");
11299 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); 11296 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame();
11300 HashSet<AtomicString> names; 11297 HashSet<AtomicString> names;
11301 for (Frame* frame = mainFrame->tree().firstChild(); frame; 11298 for (Frame* frame = mainFrame->tree().firstChild(); frame;
11302 frame = frame->tree().traverseNext()) { 11299 frame = frame->tree().traverseNext()) {
11303 EXPECT_TRUE(names.insert(frame->tree().uniqueName()).isNewEntry); 11300 EXPECT_TRUE(names.insert(frame->tree().uniqueName()).isNewEntry);
11304 } 11301 }
11305 EXPECT_EQ(10u, names.size()); 11302 EXPECT_EQ(10u, names.size());
11306 } 11303 }
11307 11304
11308 class WebFrameSimTest : public SimTest {};
11309
11310 TEST_F(WebFrameSimTest, DisplayNoneIFrameHasNoLayoutObjects) {
11311 SimRequest mainResource("https://example.com/test.html", "text/html");
11312 SimRequest frameResource("https://example.com/frame.html", "text/html");
11313
11314 loadURL("https://example.com/test.html");
11315 mainResource.complete(
11316 "<!DOCTYPE html>"
11317 "<iframe src=frame.html style='display: none'></iframe>");
11318 frameResource.complete(
11319 "<!DOCTYPE html>"
11320 "<html><body>This is a visible iframe.</body></html>");
11321
11322 Element* element = document().querySelector("iframe");
11323 HTMLFrameOwnerElement* frameOwnerElement = toHTMLFrameOwnerElement(element);
11324 Document* iframeDoc = frameOwnerElement->contentDocument();
11325 EXPECT_FALSE(iframeDoc->documentElement()->layoutObject());
11326
11327 // Changing the display from 'none' -> 'block' should cause layout objects to
11328 // appear.
11329 element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueBlock);
11330 compositor().beginFrame();
11331 EXPECT_TRUE(iframeDoc->documentElement()->layoutObject());
11332
11333 // Changing the display from 'block' -> 'none' should cause layout objects to
11334 // disappear.
11335 element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
11336
11337 compositor().beginFrame();
11338 EXPECT_FALSE(iframeDoc->documentElement()->layoutObject());
11339 }
11340
11341 TEST_F(WebFrameSimTest, NormalIFrameHasLayoutObjects) {
11342 SimRequest mainResource("https://example.com/test.html", "text/html");
11343 SimRequest frameResource("https://example.com/frame.html", "text/html");
11344
11345 loadURL("https://example.com/test.html");
11346 mainResource.complete(
11347 "<!DOCTYPE html>"
11348 "<iframe src=frame.html style='display: block'></iframe>");
11349 frameResource.complete(
11350 "<!DOCTYPE html>"
11351 "<html><body>This is a visible iframe.</body></html>");
11352
11353 Element* element = document().querySelector("iframe");
11354 HTMLFrameOwnerElement* frameOwnerElement = toHTMLFrameOwnerElement(element);
11355 Document* iframeDoc = frameOwnerElement->contentDocument();
11356 EXPECT_TRUE(iframeDoc->documentElement()->layoutObject());
11357
11358 // Changing the display from 'block' -> 'none' should cause layout objects to
11359 // disappear.
11360 element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
11361 compositor().beginFrame();
11362 EXPECT_FALSE(iframeDoc->documentElement()->layoutObject());
11363 }
11364
11365 TEST_F(WebFrameTest, NoLoadingCompletionCallbacksInDetach) { 11305 TEST_F(WebFrameTest, NoLoadingCompletionCallbacksInDetach) {
11366 class LoadingObserverFrameClient 11306 class LoadingObserverFrameClient
11367 : public FrameTestHelpers::TestWebFrameClient { 11307 : public FrameTestHelpers::TestWebFrameClient {
11368 public: 11308 public:
11369 void frameDetached(WebLocalFrame*, DetachType) override { 11309 void frameDetached(WebLocalFrame*, DetachType) override {
11370 m_didCallFrameDetached = true; 11310 m_didCallFrameDetached = true;
11371 } 11311 }
11372 11312
11373 void didStopLoading() override { 11313 void didStopLoading() override {
11374 // TODO(dcheng): Investigate not calling this as well during frame detach. 11314 // TODO(dcheng): Investigate not calling this as well during frame detach.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
11448 11388
11449 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); 11389 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached());
11450 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); 11390 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading());
11451 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); 11391 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad());
11452 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); 11392 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents());
11453 11393
11454 webViewHelper.reset(); 11394 webViewHelper.reset();
11455 } 11395 }
11456 11396
11457 } // namespace blink 11397 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebLocalFrameImpl.cpp ('k') | third_party/WebKit/public/web/WebFrameOwnerProperties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698