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

Side by Side Diff: Source/web/tests/WebPageNewSerializerTest.cpp

Issue 1162833007: Merge page serializers [2/12] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698