OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 EXPECT_EQ("<!-- saved from url=(0030)http://www.test.com/?-%2Dx-%2D -->", | 191 EXPECT_EQ("<!-- saved from url=(0030)http://www.test.com/?-%2Dx-%2D -->", |
192 actualHTML.substring(1, 60)); | 192 actualHTML.substring(1, 60)); |
193 } | 193 } |
194 | 194 |
195 class WebFrameSerializerSanitizationTest : public WebFrameSerializerTest { | 195 class WebFrameSerializerSanitizationTest : public WebFrameSerializerTest { |
196 protected: | 196 protected: |
197 WebFrameSerializerSanitizationTest() {} | 197 WebFrameSerializerSanitizationTest() {} |
198 | 198 |
199 ~WebFrameSerializerSanitizationTest() override {} | 199 ~WebFrameSerializerSanitizationTest() override {} |
200 | 200 |
201 String generateMHTMLParts(const String& url, const String& fileName) { | 201 String generateMHTMLParts(const String& url, |
| 202 const String& fileName, |
| 203 const String& mimeType = "text/html") { |
202 KURL parsedURL(ParsedURLString, url); | 204 KURL parsedURL(ParsedURLString, url); |
203 URLTestHelpers::registerMockedURLLoad(parsedURL, fileName, | 205 URLTestHelpers::registerMockedURLLoad(parsedURL, fileName, |
204 "frameserialization/", "text/html"); | 206 "frameserialization/", mimeType); |
205 FrameTestHelpers::loadFrame(mainFrameImpl(), url.utf8().data()); | 207 FrameTestHelpers::loadFrame(mainFrameImpl(), url.utf8().data()); |
206 WebThreadSafeData result = WebFrameSerializer::generateMHTMLParts( | 208 WebThreadSafeData result = WebFrameSerializer::generateMHTMLParts( |
207 WebString("boundary"), mainFrameImpl(), &m_mhtmlDelegate); | 209 WebString("boundary"), mainFrameImpl(), &m_mhtmlDelegate); |
208 return String(result.data(), result.size()); | 210 return String(result.data(), result.size()); |
209 } | 211 } |
210 | 212 |
211 private: | 213 private: |
212 SimpleMHTMLPartsGenerationDelegate m_mhtmlDelegate; | 214 SimpleMHTMLPartsGenerationDelegate m_mhtmlDelegate; |
213 }; | 215 }; |
214 | 216 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 EXPECT_NE(WTF::kNotFound, mhtml.find("<h2")); | 269 EXPECT_NE(WTF::kNotFound, mhtml.find("<h2")); |
268 | 270 |
269 // These visible elements should remain intact. | 271 // These visible elements should remain intact. |
270 EXPECT_NE(WTF::kNotFound, mhtml.find("<h2")); | 272 EXPECT_NE(WTF::kNotFound, mhtml.find("<h2")); |
271 EXPECT_NE(WTF::kNotFound, mhtml.find("<p id=3D\"visible_id\"")); | 273 EXPECT_NE(WTF::kNotFound, mhtml.find("<p id=3D\"visible_id\"")); |
272 EXPECT_NE(WTF::kNotFound, mhtml.find("<form")); | 274 EXPECT_NE(WTF::kNotFound, mhtml.find("<form")); |
273 EXPECT_NE(WTF::kNotFound, mhtml.find("<input type=3D\"text\"")); | 275 EXPECT_NE(WTF::kNotFound, mhtml.find("<input type=3D\"text\"")); |
274 EXPECT_NE(WTF::kNotFound, mhtml.find("<div")); | 276 EXPECT_NE(WTF::kNotFound, mhtml.find("<div")); |
275 } | 277 } |
276 | 278 |
| 279 // Regression test for crbug.com/678893, where in some cases serializing an |
| 280 // image document could cause code to pick an element from an empty container. |
| 281 TEST_F(WebFrameSerializerSanitizationTest, FromBrokenImageDocument) { |
| 282 String mhtml = generateMHTMLParts("http://www.test.com", "broken-image.png", |
| 283 "image/png"); |
| 284 EXPECT_TRUE(mhtml.isEmpty()); |
| 285 } |
| 286 |
277 } // namespace blink | 287 } // namespace blink |
OLD | NEW |