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

Unified Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2743053003: [Reland #1] Don't create layout objects for children of display-none iframes. (Closed)
Patch Set: rebaseline. Created 3 years, 9 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: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index b32fcc1acb9da6242273a65169a6841ba8c3610c..146f8e217958b470fd382db5997a64925a30600d 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -150,6 +150,9 @@
#include "web/WebRemoteFrameImpl.h"
#include "web/WebViewImpl.h"
#include "web/tests/FrameTestHelpers.h"
+#include "web/tests/sim/SimDisplayItemList.h"
+#include "web/tests/sim/SimRequest.h"
+#include "web/tests/sim/SimTest.h"
#include "wtf/Forward.h"
#include "wtf/PtrUtil.h"
#include "wtf/dtoa/utils.h"
@@ -11306,6 +11309,63 @@ TEST_F(WebFrameTest, TestNonCompositedOverlayScrollbarsFade) {
mockOverlayTheme.setOverlayScrollbarFadeOutDelay(0.0);
}
+class WebFrameSimTest : public SimTest {};
+
+TEST_F(WebFrameSimTest, DisplayNoneIFrameHasNoLayoutObjects) {
+ SimRequest mainResource("https://example.com/test.html", "text/html");
+ SimRequest frameResource("https://example.com/frame.html", "text/html");
+
+ loadURL("https://example.com/test.html");
+ mainResource.complete(
+ "<!DOCTYPE html>"
+ "<iframe src=frame.html style='display: none'></iframe>");
+ frameResource.complete(
+ "<!DOCTYPE html>"
+ "<html><body>This is a visible iframe.</body></html>");
+
+ Element* element = document().querySelector("iframe");
+ HTMLFrameOwnerElement* frameOwnerElement = toHTMLFrameOwnerElement(element);
+ Document* iframeDoc = frameOwnerElement->contentDocument();
+ EXPECT_FALSE(iframeDoc->documentElement()->layoutObject());
+
+ // Changing the display from 'none' -> 'block' should cause layout objects to
+ // appear.
+ element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueBlock);
+ compositor().beginFrame();
+ EXPECT_TRUE(iframeDoc->documentElement()->layoutObject());
+
+ // Changing the display from 'block' -> 'none' should cause layout objects to
+ // disappear.
+ element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
+
+ compositor().beginFrame();
+ EXPECT_FALSE(iframeDoc->documentElement()->layoutObject());
+}
+
+TEST_F(WebFrameSimTest, NormalIFrameHasLayoutObjects) {
+ SimRequest mainResource("https://example.com/test.html", "text/html");
+ SimRequest frameResource("https://example.com/frame.html", "text/html");
+
+ loadURL("https://example.com/test.html");
+ mainResource.complete(
+ "<!DOCTYPE html>"
+ "<iframe src=frame.html style='display: block'></iframe>");
+ frameResource.complete(
+ "<!DOCTYPE html>"
+ "<html><body>This is a visible iframe.</body></html>");
+
+ Element* element = document().querySelector("iframe");
+ HTMLFrameOwnerElement* frameOwnerElement = toHTMLFrameOwnerElement(element);
+ Document* iframeDoc = frameOwnerElement->contentDocument();
+ EXPECT_TRUE(iframeDoc->documentElement()->layoutObject());
+
+ // Changing the display from 'block' -> 'none' should cause layout objects to
+ // disappear.
+ element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
+ compositor().beginFrame();
+ EXPECT_FALSE(iframeDoc->documentElement()->layoutObject());
+}
+
TEST_F(WebFrameTest, NoLoadingCompletionCallbacksInDetach) {
class LoadingObserverFrameClient
: public FrameTestHelpers::TestWebFrameClient {
« 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