Unreviewed, rolling out r189908.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Sep 2015 04:48:54 +0000 (04:48 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Sep 2015 04:48:54 +0000 (04:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149368

Broke run-webkit-tests --pixel (Requested by ap on #webkit).

Reverted changeset:

"printing does not use minimum page zoom factor"
https://bugs.webkit.org/show_bug.cgi?id=108507
http://trac.webkit.org/changeset/189908

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190009 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/page/PrintContext.cpp
Source/WebCore/page/PrintContext.h
Source/WebCore/testing/Internals.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Misc/WebCoreStatistics.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/c/WKImage.h
Source/WebKit2/Shared/API/c/WKSharedAPICast.h
Source/WebKit2/Shared/ImageOptions.h
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/TestInvocation.h
Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp
Tools/WebKitTestRunner/cg/TestInvocationCG.cpp

index 92204f0..d44f7c2 100644 (file)
@@ -1,3 +1,16 @@
+2015-09-18  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r189908.
+        https://bugs.webkit.org/show_bug.cgi?id=149368
+
+        Broke run-webkit-tests --pixel (Requested by ap on #webkit).
+
+        Reverted changeset:
+
+        "printing does not use minimum page zoom factor"
+        https://bugs.webkit.org/show_bug.cgi?id=108507
+        http://trac.webkit.org/changeset/189908
+
 2015-09-18  Ryosuke Niwa  <rniwa@webkit.org>
 
         Inserting or removing slot elements can cause a crash
index dc8de11..5c6bf79 100644 (file)
@@ -2406,6 +2406,10 @@ webkit.org/b/143871 svg/W3C-SVG-1.1-SE/linking-uri-01-b.svg [ Failure ]
 
 webkit.org/b/143924 fast/text/hyphen-min-preferred-width.html [ Skip ]
 
+webkit.org/b/144494 printing/quirks-percentage-height-body.html [ ImageOnlyFailure ]
+webkit.org/b/144494 printing/quirks-percentage-height.html [ ImageOnlyFailure ]
+webkit.org/b/144494 printing/standards-percentage-heights.html [ ImageOnlyFailure ]
+
 webkit.org/b/144575 http/tests/loading/promote-img-preload-priority.html [ Failure ]
 
 webkit.org/b/144673 fast/forms/button-line-height.html [ ImageOnlyFailure ]
index 4a776f8..9ff054e 100644 (file)
@@ -196,6 +196,10 @@ webkit.org/b/105954 http/tests/navigation/reload-subframe-object.html [ Failure
 
 webkit.org/b/105960 plugins/navigator-plugins.html [ Failure ]
 
+webkit.org/b/108507 printing/quirks-percentage-height-body.html [ Skip ]
+webkit.org/b/108507 printing/quirks-percentage-height.html [ Skip ]
+webkit.org/b/108507 printing/standards-percentage-heights.html [ Skip ]
+
 webkit.org/b/104954 http/tests/canvas/canvas-slow-font-loading.html [ ImageOnlyFailure ]
 
 # Flaky everywhere.
index 0a28200..56b4c80 100644 (file)
@@ -1,3 +1,16 @@
+2015-09-18  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r189908.
+        https://bugs.webkit.org/show_bug.cgi?id=149368
+
+        Broke run-webkit-tests --pixel (Requested by ap on #webkit).
+
+        Reverted changeset:
+
+        "printing does not use minimum page zoom factor"
+        https://bugs.webkit.org/show_bug.cgi?id=108507
+        http://trac.webkit.org/changeset/189908
+
 2015-09-18  Ryosuke Niwa  <rniwa@webkit.org>
 
         Inserting or removing slot elements can cause a crash
index 2637511..f62dfa6 100644 (file)
@@ -301,37 +301,33 @@ String PrintContext::pageSizeAndMarginsInPixels(Frame* frame, int pageNumber, in
            String::number(marginTop) + ' ' + String::number(marginRight) + ' ' + String::number(marginBottom) + ' ' + String::number(marginLeft);
 }
 
-bool PrintContext::beginAndComputePageRectsWithPageSize(Frame& frame, const FloatSize& pageSizeInPixels)
+int PrintContext::numberOfPages(Frame* frame, const FloatSize& pageSizeInPixels)
 {
-    if (!frame.document() || !frame.view() || !frame.document()->renderView())
-        return false;
+    frame->document()->updateLayout();
 
-    frame.document()->updateLayout();
-
-    begin(pageSizeInPixels.width(), pageSizeInPixels.height());
+    FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
+    PrintContext printContext(frame);
+    printContext.begin(pageRect.width(), pageRect.height());
     // Account for shrink-to-fit.
     FloatSize scaledPageSize = pageSizeInPixels;
-    scaledPageSize.scale(frame.view()->contentsSize().width() / pageSizeInPixels.width());
-    computePageRectsWithPageSize(scaledPageSize, false);
-
-    return true;
-}
-
-int PrintContext::numberOfPages(Frame& frame, const FloatSize& pageSizeInPixels)
-{
-    PrintContext printContext(&frame);
-    if (!printContext.beginAndComputePageRectsWithPageSize(frame, pageSizeInPixels))
-        return -1;
-
+    scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width());
+    printContext.computePageRectsWithPageSize(scaledPageSize, false);
     return printContext.pageCount();
 }
 
-void PrintContext::spoolAllPagesWithBoundaries(Frame& frame, GraphicsContext& graphicsContext, const FloatSize& pageSizeInPixels)
+void PrintContext::spoolAllPagesWithBoundaries(Frame* frame, GraphicsContext& graphicsContext, const FloatSize& pageSizeInPixels)
 {
-    PrintContext printContext(&frame);
-    if (!printContext.beginAndComputePageRectsWithPageSize(frame, pageSizeInPixels))
+    if (!frame->document() || !frame->view() || !frame->document()->renderView())
         return;
 
+    frame->document()->updateLayout();
+
+    PrintContext printContext(frame);
+    printContext.begin(pageSizeInPixels.width(), pageSizeInPixels.height());
+
+    float pageHeight;
+    printContext.computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1, pageHeight);
+
     const float pageWidth = pageSizeInPixels.width();
     const Vector<IntRect>& pageRects = printContext.pageRects();
     int totalHeight = pageRects.size() * (pageSizeInPixels.height() + 1) - 1;
@@ -341,24 +337,18 @@ void PrintContext::spoolAllPagesWithBoundaries(Frame& frame, GraphicsContext& gr
     graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight));
 
     graphicsContext.save();
-#if PLATFORM(COCOA)
     graphicsContext.translate(0, totalHeight);
     graphicsContext.scale(FloatSize(1, -1));
-#endif
 
     int currentHeight = 0;
     for (size_t pageIndex = 0; pageIndex < pageRects.size(); pageIndex++) {
         // Draw a line for a page boundary if this isn't the first page.
         if (pageIndex > 0) {
-#if PLATFORM(COCOA)
-            int boundaryLineY = currentHeight;
-#else
-            int boundaryLineY = currentHeight - 1;
-#endif
             graphicsContext.save();
             graphicsContext.setStrokeColor(Color(0, 0, 255), ColorSpaceDeviceRGB);
             graphicsContext.setFillColor(Color(0, 0, 255), ColorSpaceDeviceRGB);
-            graphicsContext.drawLine(IntPoint(0, boundaryLineY), IntPoint(pageWidth, boundaryLineY));
+            graphicsContext.drawLine(IntPoint(0, currentHeight),
+                                     IntPoint(pageWidth, currentHeight));
             graphicsContext.restore();
         }
 
index d3d3eae..7c51ca4 100644 (file)
@@ -73,11 +73,11 @@ public:
     WEBCORE_EXPORT static String pageProperty(Frame*, const char* propertyName, int pageNumber);
     WEBCORE_EXPORT static bool isPageBoxVisible(Frame*, int pageNumber);
     WEBCORE_EXPORT static String pageSizeAndMarginsInPixels(Frame*, int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft);
-    WEBCORE_EXPORT static int numberOfPages(Frame&, const FloatSize& pageSizeInPixels);
+    WEBCORE_EXPORT static int numberOfPages(Frame*, const FloatSize& pageSizeInPixels);
     // Draw all pages into a graphics context with lines which mean page boundaries.
     // The height of the graphics context should be
     // (pageSizeInPixels.height() + 1) * number-of-pages - 1
-    WEBCORE_EXPORT static void spoolAllPagesWithBoundaries(Frame&, GraphicsContext&, const FloatSize& pageSizeInPixels);
+    WEBCORE_EXPORT static void spoolAllPagesWithBoundaries(Frame*, GraphicsContext&, const FloatSize& pageSizeInPixels);
 
 protected:
     Frame* m_frame;
@@ -85,7 +85,6 @@ protected:
 
 private:
     void computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels, bool allowHorizontalTiling);
-    bool beginAndComputePageRectsWithPageSize(Frame&, const FloatSize& pageSizeInPixels);
 
     // Used to prevent misuses of begin() and end() (e.g., call end without begin).
     bool m_isPrinting;
index f5c07b5..73d0fe6 100644 (file)
@@ -1989,7 +1989,7 @@ int Internals::numberOfPages(float pageWidth, float pageHeight)
     if (!frame())
         return -1;
 
-    return PrintContext::numberOfPages(*frame(), FloatSize(pageWidth, pageHeight));
+    return PrintContext::numberOfPages(frame(), FloatSize(pageWidth, pageHeight));
 }
 
 String Internals::pageProperty(String propertyName, int pageNumber, ExceptionCode& ec) const
index d112c96..b0b29ec 100644 (file)
@@ -1,3 +1,16 @@
+2015-09-18  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r189908.
+        https://bugs.webkit.org/show_bug.cgi?id=149368
+
+        Broke run-webkit-tests --pixel (Requested by ap on #webkit).
+
+        Reverted changeset:
+
+        "printing does not use minimum page zoom factor"
+        https://bugs.webkit.org/show_bug.cgi?id=108507
+        http://trac.webkit.org/changeset/189908
+
 2015-09-17  Brian Burg  <bburg@apple.com>
 
         ASSERT(!m_frontendRouter->hasLocalFrontend()) when running Web Inspector tests
index c0cafed..78210ac 100644 (file)
@@ -276,11 +276,7 @@ using namespace WebCore;
 
 - (int)numberOfPagesWithPageWidth:(float)pageWidthInPixels pageHeight:(float)pageHeightInPixels
 {
-    Frame* coreFrame = _private->coreFrame;
-    if (!coreFrame)
-        return -1;
-
-    return PrintContext::numberOfPages(*coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels));
+    return PrintContext::numberOfPages(_private->coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels));
 }
 
 - (void)printToCGContext:(CGContextRef)cgContext pageWidth:(float)pageWidthInPixels pageHeight:(float)pageHeightInPixels
@@ -290,7 +286,7 @@ using namespace WebCore;
         return;
 
     GraphicsContext graphicsContext(cgContext);
-    PrintContext::spoolAllPagesWithBoundaries(*coreFrame, graphicsContext, FloatSize(pageWidthInPixels, pageHeightInPixels));
+    PrintContext::spoolAllPagesWithBoundaries(coreFrame, graphicsContext, FloatSize(pageWidthInPixels, pageHeightInPixels));
 }
 
 @end
index 6e54106..dd023dd 100644 (file)
@@ -1,3 +1,16 @@
+2015-09-18  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r189908.
+        https://bugs.webkit.org/show_bug.cgi?id=149368
+
+        Broke run-webkit-tests --pixel (Requested by ap on #webkit).
+
+        Reverted changeset:
+
+        "printing does not use minimum page zoom factor"
+        https://bugs.webkit.org/show_bug.cgi?id=108507
+        http://trac.webkit.org/changeset/189908
+
 2015-09-18  Andy Estes  <aestes@apple.com>
 
         [iOS] did{Start,Finish}LoadForQuickLookDocumentInMainFrame is never called on WKNavigationDelegate
index 27a3454..8dd56cc 100644 (file)
@@ -45,7 +45,6 @@ enum {
     kWKSnapshotOptionsPaintSelectionRectangle = 1 << 3,
     kWKSnapshotOptionsForceBlackText = 1 << 4,
     kWKSnapshotOptionsForceWhiteText = 1 << 5,
-    kWKSnapshotOptionsPrinting = 1 << 6,
 };
 typedef uint32_t WKSnapshotOptions;
 
index 4f17e37..03546c6 100644 (file)
@@ -951,8 +951,6 @@ inline SnapshotOptions toSnapshotOptions(WKSnapshotOptions wkSnapshotOptions)
         snapshotOptions |= SnapshotOptionsForceBlackText;
     if (wkSnapshotOptions & kWKSnapshotOptionsForceWhiteText)
         snapshotOptions |= SnapshotOptionsForceWhiteText;
-    if (wkSnapshotOptions & kWKSnapshotOptionsPrinting)
-        snapshotOptions |= SnapshotOptionsPrinting;
 
     return snapshotOptions;
 }
index 312ca6d..99ba79f 100644 (file)
@@ -40,7 +40,6 @@ enum {
     SnapshotOptionsExcludeDeviceScaleFactor = 1 << 5,
     SnapshotOptionsForceBlackText = 1 << 6,
     SnapshotOptionsForceWhiteText = 1 << 7,
-    SnapshotOptionsPrinting = 1 << 8,
 };
 typedef uint32_t SnapshotOptions;
 
index 244401b..0393658 100644 (file)
@@ -407,7 +407,7 @@ int InjectedBundle::numberOfPages(WebFrame* frame, double pageWidthInPixels, dou
     if (!pageHeightInPixels)
         pageHeightInPixels = coreFrame->view()->height();
 
-    return PrintContext::numberOfPages(*coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels));
+    return PrintContext::numberOfPages(coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels));
 }
 
 int InjectedBundle::pageNumberForElementById(WebFrame* frame, const String& id, double pageWidthInPixels, double pageHeightInPixels)
index a4632f3..cc06410 100644 (file)
@@ -1711,18 +1711,10 @@ PassRefPtr<WebImage> WebPage::scaledSnapshotWithOptions(const IntRect& rect, dou
 {
     IntRect snapshotRect = rect;
     IntSize bitmapSize = snapshotRect.size();
-    if (options & SnapshotOptionsPrinting) {
-        ASSERT(additionalScaleFactor == 1);
-        Frame* coreFrame = m_mainFrame->coreFrame();
-        if (!coreFrame)
-            return nullptr;
-        bitmapSize.setHeight(PrintContext::numberOfPages(*coreFrame, bitmapSize) * (bitmapSize.height() + 1) - 1);
-    } else {
-        double scaleFactor = additionalScaleFactor;
-        if (!(options & SnapshotOptionsExcludeDeviceScaleFactor))
-            scaleFactor *= corePage()->deviceScaleFactor();
-        bitmapSize.scale(scaleFactor);
-    }
+    double scaleFactor = additionalScaleFactor;
+    if (!(options & SnapshotOptionsExcludeDeviceScaleFactor))
+        scaleFactor *= corePage()->deviceScaleFactor();
+    bitmapSize.scale(scaleFactor);
 
     return snapshotAtSize(rect, bitmapSize, options);
 }
@@ -1748,11 +1740,6 @@ PassRefPtr<WebImage> WebPage::snapshotAtSize(const IntRect& rect, const IntSize&
 
     auto graphicsContext = snapshot->bitmap()->createGraphicsContext();
 
-    if (options & SnapshotOptionsPrinting) {
-        PrintContext::spoolAllPagesWithBoundaries(*coreFrame, *graphicsContext, snapshotRect.size());
-        return snapshot.release();
-    }
-
     Color documentBackgroundColor = frameView->documentBackgroundColor();
     Color backgroundColor = (coreFrame->settings().backgroundShouldExtendBeyondPage() && documentBackgroundColor.isValid()) ? documentBackgroundColor : frameView->baseBackgroundColor();
     graphicsContext->fillRect(IntRect(IntPoint(), bitmapSize), backgroundColor, ColorSpaceDeviceRGB);
index 25200e9..1b7683d 100644 (file)
@@ -1,3 +1,16 @@
+2015-09-18  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r189908.
+        https://bugs.webkit.org/show_bug.cgi?id=149368
+
+        Broke run-webkit-tests --pixel (Requested by ap on #webkit).
+
+        Reverted changeset:
+
+        "printing does not use minimum page zoom factor"
+        https://bugs.webkit.org/show_bug.cgi?id=108507
+        http://trac.webkit.org/changeset/189908
+
 2015-09-18  Andy Estes  <aestes@apple.com>
 
         [iOS] did{Start,Finish}LoadForQuickLookDocumentInMainFrame is never called on WKNavigationDelegate
index aff2a9d..cb22d6d 100644 (file)
@@ -889,26 +889,12 @@ void InjectedBundlePage::dump()
         injectedBundle.dumpBackForwardListsForAllPages(stringBuilder);
 
     if (injectedBundle.shouldDumpPixels() && injectedBundle.testRunner()->shouldDumpPixels()) {
-        WKSnapshotOptions options = kWKSnapshotOptionsShareable;
-        WKRect snapshotRect = WKBundleFrameGetVisibleContentBounds(WKBundlePageGetMainFrame(m_page));
-        bool shouldCreateSnapshot = false;
-        if (injectedBundle.testRunner()->isPrinting()) {
-            shouldCreateSnapshot = true;
-            options |= kWKSnapshotOptionsPrinting;
-        } else {
-#if PLATFORM(IOS)
-            // Only IOS needs to generate the snapshot in the web process, all other ports generate
-            // a snapshot from the web view contents in the UI process.
-            shouldCreateSnapshot = true;
-            options |= kWKSnapshotOptionsInViewCoordinates;
-            if (injectedBundle.testRunner()->shouldDumpSelectionRect())
-                options |= kWKSnapshotOptionsPaintSelectionRectangle;
-#endif
-        }
+        WKSnapshotOptions options = kWKSnapshotOptionsShareable | kWKSnapshotOptionsInViewCoordinates;
+        if (injectedBundle.testRunner()->shouldDumpSelectionRect())
+            options |= kWKSnapshotOptionsPaintSelectionRectangle;
 
-        if (shouldCreateSnapshot)
-            injectedBundle.setPixelResult(adoptWK(WKBundlePageCreateSnapshotWithOptions(m_page, snapshotRect, options)).get());
-        if (WKBundlePageIsTrackingRepaints(m_page) && !injectedBundle.testRunner()->isPrinting())
+        injectedBundle.setPixelResult(adoptWK(WKBundlePageCreateSnapshotWithOptions(m_page, WKBundleFrameGetVisibleContentBounds(WKBundlePageGetMainFrame(m_page)), options)).get());
+        if (WKBundlePageIsTrackingRepaints(m_page))
             injectedBundle.setRepaintRects(adoptWK(WKBundlePageCopyTrackedRepaintRects(m_page)).get());
     }
 
index e7f3e83..7536b61 100644 (file)
@@ -276,22 +276,16 @@ void TestInvocation::dumpResults()
     else
         dumpAudio(m_audioResult.get());
 
-    if (m_dumpPixels) {
-        if (m_pixelResult)
-            dumpPixelsAndCompareWithExpected(m_pixelResult.get(), m_repaintRects.get(), TestInvocation::SnapshotResultType::WebContents);
-        else {
-            m_gotRepaint = false;
-            WKPageForceRepaint(TestController::singleton().mainWebView()->page(), this, TestInvocation::forceRepaintDoneCallback);
-            TestController::singleton().runUntil(m_gotRepaint, TestController::shortTimeout);
-            if (!m_gotRepaint) {
-                m_errorMessage = "Timed out waiting for pre-pixel dump repaint\n";
-                m_webProcessIsUnresponsive = true;
-                return;
-            }
-            WKRetainPtr<WKImageRef> windowSnapshot = TestController::singleton().mainWebView()->windowSnapshotImage();
-            ASSERT(windowSnapshot);
-            dumpPixelsAndCompareWithExpected(windowSnapshot.get(), m_repaintRects.get(), TestInvocation::SnapshotResultType::WebView);
+    if (m_dumpPixels && m_pixelResult) {
+        m_gotRepaint = false;
+        WKPageForceRepaint(TestController::singleton().mainWebView()->page(), this, TestInvocation::forceRepaintDoneCallback);
+        TestController::singleton().runUntil(m_gotRepaint, TestController::shortTimeout);
+        if (!m_gotRepaint) {
+            m_errorMessage = "Timed out waiting for pre-pixel dump repaint\n";
+            m_webProcessIsUnresponsive = true;
+            return;
         }
+        dumpPixelsAndCompareWithExpected(m_pixelResult.get(), m_repaintRects.get());
     }
 
     fputs("#EOF\n", stdout);
index 0be002e..9baec43 100644 (file)
@@ -65,8 +65,7 @@ public:
 private:
     void dumpResults();
     static void dump(const char* textToStdout, const char* textToStderr = 0, bool seenError = false);
-    enum class SnapshotResultType { WebView, WebContents };
-    void dumpPixelsAndCompareWithExpected(WKImageRef, WKArrayRef repaintRects, SnapshotResultType);
+    void dumpPixelsAndCompareWithExpected(WKImageRef, WKArrayRef repaintRects);
     void dumpAudio(WKDataRef);
     bool compareActualHashToExpectedAndDumpResults(const char[33]);
 
index 376f319..4fafb18 100644 (file)
@@ -106,9 +106,9 @@ static void paintRepaintRectOverlay(cairo_surface_t* surface, WKArrayRef repaint
     cairo_destroy(context);
 }
 
-void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image, WKArrayRef repaintRects, SnapshotResultType)
+void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef, WKArrayRef repaintRects)
 {
-    cairo_surface_t* surface = WKImageCreateCairoSurface(image);
+    cairo_surface_t* surface = WKImageCreateCairoSurface(TestController::singleton().mainWebView()->windowSnapshotImage().get());
 
     if (repaintRects)
         paintRepaintRectOverlay(surface, repaintRects);
index 7f3f2b8..ec8392a 100644 (file)
@@ -154,9 +154,16 @@ static void paintRepaintRectOverlay(CGContextRef context, WKImageRef image, WKAr
     CGContextRestoreGState(context);
 }
 
-void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image, WKArrayRef repaintRects, SnapshotResultType snapshotType)
+void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image, WKArrayRef repaintRects)
 {
-    RetainPtr<CGContextRef> context = adoptCF(createCGContextFromImage(image, snapshotType == SnapshotResultType::WebView ? DontFlipGraphicsContext : FlipGraphicsContext));
+    PlatformWebView* webView = TestController::singleton().mainWebView();
+    WKRetainPtr<WKImageRef> windowSnapshot = webView->windowSnapshotImage();
+
+    RetainPtr<CGContextRef> context;
+    if (windowSnapshot)
+        context = adoptCF(createCGContextFromImage(windowSnapshot.get(), DontFlipGraphicsContext));
+    else
+        context = adoptCF(createCGContextFromImage(image));
 
     // A non-null repaintRects array means we're doing a repaint test.
     if (repaintRects)