| Index: Source/web/tests/DocumentLoadingRenderingTest.cpp
|
| diff --git a/Source/web/tests/DocumentLoadingRenderingTest.cpp b/Source/web/tests/DocumentLoadingRenderingTest.cpp
|
| index 0f64c43a4e6c29fb8d459d5e6c755a7a834b3812..c06e688b27edfa26eedd8d8bc3f3709726231dbc 100644
|
| --- a/Source/web/tests/DocumentLoadingRenderingTest.cpp
|
| +++ b/Source/web/tests/DocumentLoadingRenderingTest.cpp
|
| @@ -5,8 +5,10 @@
|
| #include "config.h"
|
|
|
| #include "core/dom/Document.h"
|
| +#include "core/frame/FrameView.h"
|
| #include "web/WebLocalFrameImpl.h"
|
| #include "web/tests/FrameTestHelpers.h"
|
| +#include "web/tests/sim/SimCompositor.h"
|
| #include "web/tests/sim/SimLayerTreeView.h"
|
| #include "web/tests/sim/SimNetwork.h"
|
| #include "web/tests/sim/SimRequest.h"
|
| @@ -19,8 +21,10 @@ class DocumentLoadingRenderingTest : public ::testing::Test {
|
| protected:
|
| DocumentLoadingRenderingTest()
|
| : m_webViewClient(m_layerTreeView)
|
| + , m_compositor(m_layerTreeView)
|
| {
|
| m_webViewHelper.initialize(true, nullptr, &m_webViewClient);
|
| + m_compositor.setWebViewImpl(webView());
|
| Document::setThreadedParsingEnabledForUnitTestsOnly(false);
|
| }
|
|
|
| @@ -34,12 +38,18 @@ protected:
|
| WebURLRequest request;
|
| request.initialize();
|
| request.setURL(KURL(ParsedURLString, url));
|
| - m_webViewHelper.webViewImpl()->mainFrameImpl()->loadRequest(request);
|
| + webView().mainFrameImpl()->loadRequest(request);
|
| + }
|
| +
|
| + WebViewImpl& webView()
|
| + {
|
| + return *m_webViewHelper.webViewImpl();
|
| }
|
|
|
| SimNetwork m_network;
|
| SimLayerTreeView m_layerTreeView;
|
| SimWebViewClient m_webViewClient;
|
| + SimCompositor m_compositor;
|
| FrameTestHelpers::WebViewHelper m_webViewHelper;
|
| };
|
|
|
| @@ -160,4 +170,71 @@ TEST_F(DocumentLoadingRenderingTest, ShouldResumeCommitsAfterParsingSvg)
|
| EXPECT_FALSE(m_layerTreeView.deferCommits());
|
| }
|
|
|
| +TEST_F(DocumentLoadingRenderingTest, ShouldNotPaintIframeContentWithPendingSheets)
|
| +{
|
| + SimRequest mainResource("https://example.com/test.html", "text/html");
|
| + SimRequest frameResource("https://example.com/frame.html", "text/html");
|
| + SimRequest cssResource("https://example.com/test.css", "text/css");
|
| +
|
| + loadURL("https://example.com/test.html");
|
| +
|
| + webView().resize(WebSize(800, 600));
|
| +
|
| + mainResource.start();
|
| + mainResource.write(
|
| + "<!DOCTYPE html>"
|
| + "<iframe src=frame.html></iframe>"
|
| + "<p style='transform: translateZ(0)'>Hello World</p>"
|
| + );
|
| + mainResource.finish();
|
| +
|
| + // Main page is ready to begin painting as there's no pending sheets.
|
| + // The frame is not yet loaded, so we only paint the top level page.
|
| + SimCompositor::BeginFrameResult frame1 = m_compositor.beginFrame();
|
| + EXPECT_TRUE(frame1.didDrawText);
|
| +
|
| + frameResource.start();
|
| + frameResource.write(
|
| + "<!DOCTYPE html>"
|
| + "<style>html { background: pink }</style>"
|
| + "<link rel=stylesheet href=test.css>"
|
| + "<p style='background: yellow'>Hello World</p>"
|
| + "<div style='transform: translateZ(0); background: green;'>"
|
| + " <p style='background: blue'>Hello Layer</p>"
|
| + " <div style='position: relative; background: red;'>Hello World</div>"
|
| + "</div>"
|
| + );
|
| + frameResource.finish();
|
| +
|
| + // Trigger a layout with pending sheets. For example a page could trigger this
|
| + // by doing offsetTop in a setTimeout, or by a parent frame executing script
|
| + // that touched offsetTop in the child frame.
|
| + LocalFrame* childFrame = toLocalFrame(webView().mainFrameImpl()->frame()->tree().firstChild());
|
| + childFrame->document()->updateLayoutIgnorePendingStylesheets();
|
| +
|
| + SimCompositor::BeginFrameResult frame2 = m_compositor.beginFrame();
|
| +
|
| + // The child frame still has pending sheets, and the parent frame has no
|
| + // invalid paint so we shouldn't draw any text.
|
| + EXPECT_FALSE(frame2.didDrawText);
|
| +
|
| + // One per DeprecatedPaintLayer, 2 in the main frame and 3 in the iframe = 5.
|
| + // 1 for the background of the iframe.
|
| + // 1 for the background of the composited transform layer.
|
| + // TODO(esprehn): Why FOUC the background (borders, etc.) of iframes and
|
| + // composited layers? Seems like a bug.
|
| + EXPECT_EQ(7, frame2.drawCount);
|
| +
|
| + // Finish loading the sheets in the child frame. After it should issue a
|
| + // paint invalidation for every layer since frame2 painted them but skipped
|
| + // painting the real content to avoid FOUC.
|
| + cssResource.start();
|
| + cssResource.finish();
|
| +
|
| + // First frame where all frames are loaded, should paint the text in the
|
| + // child frame.
|
| + SimCompositor::BeginFrameResult frame3 = m_compositor.beginFrame();
|
| + EXPECT_TRUE(frame3.didDrawText);
|
| +}
|
| +
|
| } // namespace blink
|
|
|