| 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 registerMockedURLLoad(imageUrl, WebString::fromUTF8("green_rectangle.svg"),
WebString::fromUTF8("pageserializer/"), svgMimeType()); | 373 registerMockedURLLoad(imageUrl, WebString::fromUTF8("green_rectangle.svg"),
WebString::fromUTF8("pageserializer/"), svgMimeType()); |
| 374 | 374 |
| 375 loadURLInTopFrame(pageUrl); | 375 loadURLInTopFrame(pageUrl); |
| 376 | 376 |
| 377 WebCString mhtml = WebPageSerializer::serializeToMHTML(webView()); | 377 WebCString mhtml = WebPageSerializer::serializeToMHTML(webView()); |
| 378 // We expect some data to be generated. | 378 // We expect some data to be generated. |
| 379 EXPECT_GT(mhtml.length(), 50U); | 379 EXPECT_GT(mhtml.length(), 50U); |
| 380 } | 380 } |
| 381 | 381 |
| 382 | 382 |
| 383 TEST_F(WebPageNewSerializeTest, DontIncludeErrorImage) | |
| 384 { | |
| 385 WebURL pageUrl = toKURL(m_baseURL); | |
| 386 WebURL imageUrl = toTestURL("error_image.png"); | |
| 387 | |
| 388 registerMockedURLLoad(pageUrl, WebString::fromUTF8("page_with_img_error.html
"), WebString::fromUTF8("pageserializer/"), htmlMimeType()); | |
| 389 registerMockedURLLoad(imageUrl, WebString::fromUTF8("error_image.png"), WebS
tring::fromUTF8("pageserializer/"), pngMimeType()); | |
| 390 | |
| 391 loadURLInTopFrame(pageUrl); | |
| 392 | |
| 393 WebCString mhtmlData = WebPageSerializer::serializeToMHTML(webView()); | |
| 394 ASSERT_FALSE(mhtmlData.isEmpty()); | |
| 395 | |
| 396 // Sniff the MHTML data to make sure image content is excluded. | |
| 397 LineReader lineReader(std::string(mhtmlData.data())); | |
| 398 std::string line; | |
| 399 while (lineReader.getNextLine(&line)) { | |
| 400 if (line.find("image/") != std::string::npos) | |
| 401 FAIL() << "Error Image was not excluded " << line; | |
| 402 } | |
| 403 } | |
| 404 | |
| 405 | |
| 406 TEST_F(WebPageNewSerializeTest, NamespaceElementsDontCrash) | 383 TEST_F(WebPageNewSerializeTest, NamespaceElementsDontCrash) |
| 407 { | 384 { |
| 408 WebURL pageUrl = toKURL(m_baseURL); | 385 WebURL pageUrl = toKURL(m_baseURL); |
| 409 registerMockedURLLoad(pageUrl, WebString::fromUTF8("namespace_element.html")
, WebString::fromUTF8("pageserializer/"), htmlMimeType()); | 386 registerMockedURLLoad(pageUrl, WebString::fromUTF8("namespace_element.html")
, WebString::fromUTF8("pageserializer/"), htmlMimeType()); |
| 410 | 387 |
| 411 loadURLInTopFrame(pageUrl); | 388 loadURLInTopFrame(pageUrl); |
| 412 | 389 |
| 413 WebVector<WebURL> localLinks(static_cast<size_t>(1)); | 390 WebVector<WebURL> localLinks(static_cast<size_t>(1)); |
| 414 WebVector<WebString> localPaths(static_cast<size_t>(1)); | 391 WebVector<WebString> localPaths(static_cast<size_t>(1)); |
| 415 localLinks[0] = pageUrl; | 392 localLinks[0] = pageUrl; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 // exactly two times. | 473 // exactly two times. |
| 497 size_t nbDataURLs = 0; | 474 size_t nbDataURLs = 0; |
| 498 LineReader lineReader(std::string(mhtmlData.data())); | 475 LineReader lineReader(std::string(mhtmlData.data())); |
| 499 std::string line; | 476 std::string line; |
| 500 while (lineReader.getNextLine(&line)) { | 477 while (lineReader.getNextLine(&line)) { |
| 501 if (line.find("data:text") != std::string::npos) | 478 if (line.find("data:text") != std::string::npos) |
| 502 nbDataURLs++; | 479 nbDataURLs++; |
| 503 } | 480 } |
| 504 EXPECT_EQ(2u, nbDataURLs); | 481 EXPECT_EQ(2u, nbDataURLs); |
| 505 } | 482 } |
| OLD | NEW |