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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp

Issue 1808353003: Make multipart/x-mixed-replace parser more robust (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multipart-3
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/MultipartImageResourceParser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 ASSERT_FALSE(cachedImage->resourceBuffer()); 116 ASSERT_FALSE(cachedImage->resourceBuffer());
117 ASSERT_FALSE(cachedImage->hasImage()); 117 ASSERT_FALSE(cachedImage->hasImage());
118 ASSERT_EQ(client.imageChangedCount(), 0); 118 ASSERT_EQ(client.imageChangedCount(), 0);
119 ASSERT_FALSE(client.notifyFinishedCalled()); 119 ASSERT_FALSE(client.notifyFinishedCalled());
120 EXPECT_EQ("image/svg+xml", cachedImage->response().mimeType()); 120 EXPECT_EQ("image/svg+xml", cachedImage->response().mimeType());
121 121
122 const char secondPart[] = "<svg xmlns='http://www.w3.org/2000/svg' width='1' height='1'><rect width='1' height='1' fill='green'/></svg>\n"; 122 const char secondPart[] = "<svg xmlns='http://www.w3.org/2000/svg' width='1' height='1'><rect width='1' height='1' fill='green'/></svg>\n";
123 // The first bytes arrive. The data buffer is created, but no image is creat ed. 123 // The first bytes arrive. The data buffer is created, but no image is creat ed.
124 cachedImage->appendData(secondPart, strlen(secondPart)); 124 cachedImage->appendData(secondPart, strlen(secondPart));
125 ASSERT_TRUE(cachedImage->resourceBuffer()); 125 ASSERT_TRUE(cachedImage->resourceBuffer());
126 ASSERT_EQ(cachedImage->resourceBuffer()->size(), strlen(secondPart));
127 ASSERT_FALSE(cachedImage->hasImage()); 126 ASSERT_FALSE(cachedImage->hasImage());
128 ASSERT_EQ(client.imageChangedCount(), 0); 127 ASSERT_EQ(client.imageChangedCount(), 0);
129 ASSERT_FALSE(client.notifyFinishedCalled()); 128 ASSERT_FALSE(client.notifyFinishedCalled());
130 129
130 const char thirdPart[] = "--boundary";
131 cachedImage->appendData(thirdPart, strlen(thirdPart));
132 ASSERT_TRUE(cachedImage->resourceBuffer());
133 ASSERT_EQ(cachedImage->resourceBuffer()->size(), strlen(secondPart) - 1);
134
131 // This part finishes. The image is created, callbacks are sent, and the dat a buffer is cleared. 135 // This part finishes. The image is created, callbacks are sent, and the dat a buffer is cleared.
132 cachedImage->finish(); 136 cachedImage->finish();
133 ASSERT_FALSE(cachedImage->resourceBuffer()); 137 ASSERT_FALSE(cachedImage->resourceBuffer());
134 ASSERT_FALSE(cachedImage->errorOccurred()); 138 ASSERT_FALSE(cachedImage->errorOccurred());
135 ASSERT_TRUE(cachedImage->hasImage()); 139 ASSERT_TRUE(cachedImage->hasImage());
136 ASSERT_FALSE(cachedImage->getImage()->isNull()); 140 ASSERT_FALSE(cachedImage->getImage()->isNull());
137 ASSERT_EQ(cachedImage->getImage()->width(), 1); 141 ASSERT_EQ(cachedImage->getImage()->width(), 1);
138 ASSERT_EQ(cachedImage->getImage()->height(), 1); 142 ASSERT_EQ(cachedImage->getImage()->height(), 1);
139 ASSERT_EQ(client.imageChangedCount(), 1); 143 ASSERT_EQ(client.imageChangedCount(), 1);
140 ASSERT_TRUE(client.notifyFinishedCalled()); 144 ASSERT_TRUE(client.notifyFinishedCalled());
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), jpeg.siz e()); 262 cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), jpeg.siz e());
259 cachedImage->finish(); 263 cachedImage->finish();
260 ASSERT_FALSE(cachedImage->errorOccurred()); 264 ASSERT_FALSE(cachedImage->errorOccurred());
261 ASSERT_TRUE(cachedImage->hasImage()); 265 ASSERT_TRUE(cachedImage->hasImage());
262 ASSERT_FALSE(cachedImage->getImage()->isNull()); 266 ASSERT_FALSE(cachedImage->getImage()->isNull());
263 ASSERT_TRUE(client.notifyFinishedCalled()); 267 ASSERT_TRUE(client.notifyFinishedCalled());
264 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage()); 268 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage());
265 } 269 }
266 270
267 } // namespace blink 271 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/MultipartImageResourceParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698