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

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

Issue 2564633002: Don't create layout objects for children of display-none iframes. (Closed)
Patch Set: Comments from esprehn. Created 4 years 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 1a5df9e1694116fe3d7a8000063f7a83cc057b89..5007dbf5dd23938c6ff409a2746fe6ba79b785d0 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -141,6 +141,8 @@
#include "web/WebRemoteFrameImpl.h"
#include "web/WebViewImpl.h"
#include "web/tests/FrameTestHelpers.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"
@@ -11009,6 +11011,72 @@ TEST_F(WebFrameTest, UniqueNames) {
EXPECT_EQ(10u, names.size());
}
+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>");
+
+ WebLocalFrameImpl* frame = webView().mainFrameImpl();
+ Element* element = frame->frame()->document()->querySelector("iframe");
+ HTMLFrameOwnerElement* frameOwnerElement =
+ static_cast<HTMLFrameOwnerElement*>(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);
+ frame->view()->updateAllLifecyclePhases();
+ runPendingTasks();
+ EXPECT_TRUE(iframeDoc->documentElement()->layoutObject());
+
+ // Changing the display from 'block' -> 'none' should cause layout objects to
+ // disappear.
+ element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
+
+ frame->view()->updateAllLifecyclePhases();
+ runPendingTasks();
esprehn 2016/12/16 21:29:44 compositor().beginFrame(), no need to do updateAll
erikchen 2016/12/16 22:42:11 Done.
+ 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>");
+
+ WebLocalFrameImpl* frame = webView().mainFrameImpl();
+ Element* element = frame->frame()->document()->querySelector("iframe");
esprehn 2016/12/16 21:29:44 document().querySelector("iframe"); no need to go
erikchen 2016/12/16 22:42:11 Done.
+ HTMLFrameOwnerElement* frameOwnerElement =
+ static_cast<HTMLFrameOwnerElement*>(element);
esprehn 2016/12/16 21:29:44 toHTMLFrameOwnerElement(element)
erikchen 2016/12/16 22:42:11 Done.
+
+ 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);
+ frame->view()->updateAllLifecyclePhases();
+ runPendingTasks();
esprehn 2016/12/16 21:29:44 ditto
erikchen 2016/12/16 22:42:11 Done.
+ EXPECT_FALSE(iframeDoc->documentElement()->layoutObject());
+}
+
TEST_F(WebFrameTest, NoLoadingCompletionCallbacksInDetach) {
class LoadingObserverFrameClient
: public FrameTestHelpers::TestWebFrameClient {

Powered by Google App Engine
This is Rietveld 408576698