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

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

Issue 2261403004: ImageDocumentParser should stop sending data to ImageResource once decoding fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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 914463ffe762c6ca0ed2198d2c850c74719a9632..8cfb002787d51fd1a114a7b432ef9af83133fbe8 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -8923,4 +8923,30 @@ TEST_F(WebFrameTest, ScriptPriority)
client.verifyAllRequests();
}
+class MultipleDataChunkDelegate : public WebURLLoaderTestDelegate {
+public:
+ void didReceiveData(WebURLLoaderClient* originalClient, WebURLLoader* loader, const char* data, int dataLength, int encodedDataLength) override
+ {
+ EXPECT_GT(dataLength, 16);
+ originalClient->didReceiveData(loader, data, 16, 16, 16);
+ // This didReceiveData call shouldn't crash due to a failed assertion.
+ originalClient->didReceiveData(loader, data + 16, dataLength - 16, encodedDataLength - 16, dataLength - 16);
+ }
+};
+
+TEST_F(WebFrameTest, ImageDocumentDecodeError)
+{
+ std::string url = m_baseURL + "not_an_image.ico";
+ URLTestHelpers::registerMockedURLLoad(toKURL(url), "not_an_image.ico", "image/x-icon");
+ MultipleDataChunkDelegate delegate;
+ Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(&delegate);
+ FrameTestHelpers::WebViewHelper helper;
+ helper.initializeAndLoad(url, true);
+ Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr);
+
+ Document* document = toLocalFrame(helper.webView()->page()->mainFrame())->document();
+ EXPECT_TRUE(document->isImageDocument());
+ EXPECT_EQ(Resource::DecodeError, toImageDocument(document)->cachedImage()->getStatus());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/ImageDocument.cpp ('k') | third_party/WebKit/Source/web/tests/data/not_an_image.ico » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698