| 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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 // We just want to make sure nothing crazy happens, namely that no | 428 // We just want to make sure nothing crazy happens, namely that no |
| 429 // assertions are hit. As a sanity check, we also make sure that some data | 429 // assertions are hit. As a sanity check, we also make sure that some data |
| 430 // was returned. | 430 // was returned. |
| 431 WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), true
, &client, localLinks, localPaths, WebString("")); | 431 WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), true
, &client, localLinks, localPaths, WebString("")); |
| 432 | 432 |
| 433 // Subframe src | 433 // Subframe src |
| 434 EXPECT_TRUE(static_cast<String>(serializedData).contains("src=\"SavedFiles/i
frame.html\"")); | 434 EXPECT_TRUE(static_cast<String>(serializedData).contains("src=\"SavedFiles/i
frame.html\"")); |
| 435 } | 435 } |
| 436 | 436 |
| 437 } | 437 } |
| 438 | |
| 439 TEST_F(WebPageNewSerializeTest, TestMHTMLEncodingWithDataURL) | |
| 440 { | |
| 441 // Load a page with some data urls. | |
| 442 WebURL topFrameURL = toKURL(m_baseURL); | |
| 443 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("page_with_data.html"
), WebString::fromUTF8("pageserializer/"), htmlMimeType()); | |
| 444 loadURLInTopFrame(topFrameURL); | |
| 445 | |
| 446 WebCString mhtmlData = WebPageSerializer::serializeToMHTML(webView()); | |
| 447 ASSERT_FALSE(mhtmlData.isEmpty()); | |
| 448 | |
| 449 // Read the MHTML data line and check that the string data:image is found | |
| 450 // exactly one time. | |
| 451 size_t nbDataURLs = 0; | |
| 452 LineReader lineReader(std::string(mhtmlData.data())); | |
| 453 std::string line; | |
| 454 while (lineReader.getNextLine(&line)) { | |
| 455 if (line.find("data:image") != std::string::npos) | |
| 456 nbDataURLs++; | |
| 457 } | |
| 458 EXPECT_EQ(1u, nbDataURLs); | |
| 459 } | |
| 460 | |
| 461 | |
| 462 TEST_F(WebPageNewSerializeTest, TestMHTMLEncodingWithMorphingDataURL) | |
| 463 { | |
| 464 // Load a page with some data urls. | |
| 465 WebURL topFrameURL = toKURL(m_baseURL); | |
| 466 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("page_with_morphing_d
ata.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()); | |
| 467 loadURLInTopFrame(topFrameURL); | |
| 468 | |
| 469 WebCString mhtmlData = WebPageSerializer::serializeToMHTML(webView()); | |
| 470 ASSERT_FALSE(mhtmlData.isEmpty()); | |
| 471 | |
| 472 // Read the MHTML data line and check that the string data:image is found | |
| 473 // exactly two times. | |
| 474 size_t nbDataURLs = 0; | |
| 475 LineReader lineReader(std::string(mhtmlData.data())); | |
| 476 std::string line; | |
| 477 while (lineReader.getNextLine(&line)) { | |
| 478 if (line.find("data:text") != std::string::npos) | |
| 479 nbDataURLs++; | |
| 480 } | |
| 481 EXPECT_EQ(2u, nbDataURLs); | |
| 482 } | |
| OLD | NEW |