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 de33e961a03548295218c2f21abfe695490b1a45..91bbd7ff313ee9aff5da807d2345e68fa07c58f1 100644 |
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
@@ -61,6 +61,7 @@ |
#include "core/html/HTMLDocument.h" |
#include "core/html/HTMLFormElement.h" |
#include "core/html/HTMLMediaElement.h" |
+#include "core/html/ImageDocument.h" |
#include "core/input/EventHandler.h" |
#include "core/layout/HitTestResult.h" |
#include "core/layout/LayoutFullScreen.h" |
@@ -207,6 +208,11 @@ protected: |
URLTestHelpers::registerMockedURLLoadWithCustomResponse(toKURL(fullString.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(""), response); |
} |
+ void registerMockedHttpURLLoadWithMimeType(const std::string& fileName, const std::string& mimeType) |
+ { |
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(mimeType)); |
+ } |
+ |
void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelper) |
{ |
RefPtrWillBeRawPtr<StyleSheetContents> styleSheet = StyleSheetContents::create(CSSParserContext(UASheetMode, 0)); |
@@ -8222,4 +8228,32 @@ TEST_F(WebFrameTest, MaxFramesDetach) |
webViewImpl->mainFrameImpl()->collectGarbage(); |
} |
+TEST_F(WebFrameTest, ImageDocumentLoadFinishTime) |
+{ |
+ // Loading an image resource directly generates an ImageDocument with |
+ // the document loader feeding image data into the resource of a generated |
+ // img tag. We expect the load finish time to be the same for the document |
+ // and the image resource. |
+ |
+ registerMockedHttpURLLoadWithMimeType("white-1x1.png", "image/png"); |
+ FrameTestHelpers::WebViewHelper webViewHelper; |
+ webViewHelper.initializeAndLoad(m_baseURL + "white-1x1.png"); |
+ WebView* webView = webViewHelper.webView(); |
+ Document* document = toWebLocalFrameImpl(webView->mainFrame())->frame()->document(); |
+ |
+ EXPECT_TRUE(document); |
+ EXPECT_TRUE(document->isImageDocument()); |
+ |
+ ImageDocument* imgDocument = toImageDocument(document); |
+ ImageResource* resource = imgDocument->cachedImage(); |
+ |
+ EXPECT_TRUE(resource); |
+ EXPECT_NE(0, resource->loadFinishTime()); |
+ |
+ DocumentLoader* loader = document->loader(); |
+ |
+ EXPECT_TRUE(loader); |
+ EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime()); |
+} |
+ |
} // namespace blink |