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 1167313002: Merge page serializers [3/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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 if (!line.find("Content-Transfer-Encoding:")) { 356 if (!line.find("Content-Transfer-Encoding:")) {
357 ASSERT_TRUE(expectedEncoding); 357 ASSERT_TRUE(expectedEncoding);
358 EXPECT_TRUE(line.find(expectedEncoding) != std::string::npos); 358 EXPECT_TRUE(line.find(expectedEncoding) != std::string::npos);
359 expectedEncoding = 0; 359 expectedEncoding = 0;
360 sectionCheckedCount++; 360 sectionCheckedCount++;
361 } 361 }
362 } 362 }
363 EXPECT_EQ(12, sectionCheckedCount); 363 EXPECT_EQ(12, sectionCheckedCount);
364 } 364 }
365 365
366 // Test that we don't regress https://bugs.webkit.org/show_bug.cgi?id=99105
367 TEST_F(WebPageNewSerializeTest, SVGImageDontCrash)
368 {
369 WebURL pageUrl = toKURL(m_baseURL);
370 WebURL imageUrl = toTestURL("green_rectangle.svg");
371
372 registerMockedURLLoad(pageUrl, WebString::fromUTF8("page_with_svg_image.html "), WebString::fromUTF8("pageserializer/"), htmlMimeType());
373 registerMockedURLLoad(imageUrl, WebString::fromUTF8("green_rectangle.svg"), WebString::fromUTF8("pageserializer/"), svgMimeType());
374
375 loadURLInTopFrame(pageUrl);
376
377 WebCString mhtml = WebPageSerializer::serializeToMHTML(webView());
378 // We expect some data to be generated.
379 EXPECT_GT(mhtml.length(), 50U);
380 }
381
382
383 TEST_F(WebPageNewSerializeTest, NamespaceElementsDontCrash)
384 {
385 WebURL pageUrl = toKURL(m_baseURL);
386 registerMockedURLLoad(pageUrl, WebString::fromUTF8("namespace_element.html") , WebString::fromUTF8("pageserializer/"), htmlMimeType());
387
388 loadURLInTopFrame(pageUrl);
389
390 WebVector<WebURL> localLinks(static_cast<size_t>(1));
391 WebVector<WebString> localPaths(static_cast<size_t>(1));
392 localLinks[0] = pageUrl;
393 localPaths[0] = WebString("/");
394
395 size_t counter = 0;
396 LengthCountingWebPageSerializerClient client(&counter);
397
398 // We just want to make sure nothing crazy happens, namely that no
399 // assertions are hit. As a sanity check, we also make sure that some data
400 // was returned.
401 WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), true , &client, localLinks, localPaths, WebString(""));
402
403 EXPECT_GT(counter, 0U);
404 }
405
406 TEST_F(WebPageNewSerializeTest, SubFrameSerialization) 366 TEST_F(WebPageNewSerializeTest, SubFrameSerialization)
407 { 367 {
408 WebURL pageUrl = toKURL(m_baseURL); 368 WebURL pageUrl = toKURL(m_baseURL);
409 registerMockedURLLoad(pageUrl, WebString::fromUTF8("top_frame.html"), WebStr ing::fromUTF8("pageserializer/"), htmlMimeType()); 369 registerMockedURLLoad(pageUrl, WebString::fromUTF8("top_frame.html"), WebStr ing::fromUTF8("pageserializer/"), htmlMimeType());
410 registerMockedURLLoad(toTestURL("iframe.html"), WebString::fromUTF8("iframe. html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()); 370 registerMockedURLLoad(toTestURL("iframe.html"), WebString::fromUTF8("iframe. html"), WebString::fromUTF8("pageserializer/"), htmlMimeType());
411 registerMockedURLLoad(toTestURL("iframe2.html"), WebString::fromUTF8("iframe 2.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()); 371 registerMockedURLLoad(toTestURL("iframe2.html"), WebString::fromUTF8("iframe 2.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType());
412 registerMockedURLLoad(toTestURL("red_background.png"), WebString::fromUTF8(" red_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 372 registerMockedURLLoad(toTestURL("red_background.png"), WebString::fromUTF8(" red_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType());
413 registerMockedURLLoad(toTestURL("green_background.png"), WebString::fromUTF8 ("green_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()) ; 373 registerMockedURLLoad(toTestURL("green_background.png"), WebString::fromUTF8 ("green_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()) ;
414 registerMockedURLLoad(toTestURL("blue_background.png"), WebString::fromUTF8( "blue_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 374 registerMockedURLLoad(toTestURL("blue_background.png"), WebString::fromUTF8( "blue_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType());
415 375
(...skipping 12 matching lines...) Expand all
428 // We just want to make sure nothing crazy happens, namely that no 388 // 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 389 // assertions are hit. As a sanity check, we also make sure that some data
430 // was returned. 390 // was returned.
431 WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), true , &client, localLinks, localPaths, WebString("")); 391 WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), true , &client, localLinks, localPaths, WebString(""));
432 392
433 // Subframe src 393 // Subframe src
434 EXPECT_TRUE(static_cast<String>(serializedData).contains("src=\"SavedFiles/i frame.html\"")); 394 EXPECT_TRUE(static_cast<String>(serializedData).contains("src=\"SavedFiles/i frame.html\""));
435 } 395 }
436 396
437 } 397 }
OLDNEW
« no previous file with comments | « Source/web/tests/WebFrameTest.cpp ('k') | Source/web/tests/data/pageserializer/green_rectangle.svg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698