OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2013, Opera Software ASA. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * 3. Neither the name of Opera Software ASA nor the names of its | |
14 * contributors may be used to endorse or promote products derived | |
15 * from this software without specific prior written permission. | |
16 * | |
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
28 * OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #include "core/page/PageSerializer.h" | |
32 | |
33 #include "bindings/core/v8/V8Binding.h" | |
34 #include "bindings/core/v8/V8BindingForTesting.h" | |
35 #include "core/page/Page.h" | |
36 #include "platform/SerializedResource.h" | |
37 #include "platform/testing/URLTestHelpers.h" | |
38 #include "public/platform/Platform.h" | |
39 #include "public/platform/WebString.h" | |
40 #include "public/platform/WebThread.h" | |
41 #include "public/platform/WebURL.h" | |
42 #include "public/platform/WebURLRequest.h" | |
43 #include "public/platform/WebURLResponse.h" | |
44 #include "public/platform/WebUnitTestSupport.h" | |
45 #include "public/web/WebSettings.h" | |
46 #include "testing/gtest/include/gtest/gtest.h" | |
47 #include "web/WebLocalFrameImpl.h" | |
48 #include "web/WebViewImpl.h" | |
49 #include "web/tests/FrameTestHelpers.h" | |
50 #include "wtf/Assertions.h" | |
51 #include "wtf/Vector.h" | |
52 | |
53 using blink::URLTestHelpers::toKURL; | |
54 using blink::URLTestHelpers::registerMockedURLLoad; | |
55 | |
56 namespace blink { | |
57 | |
58 class PageSerializerTest | |
59 : public testing::Test | |
60 , public PageSerializer::Delegate { | |
61 public: | |
62 PageSerializerTest() | |
63 : m_folder(WebString::fromUTF8("pageserializer/")) | |
64 , m_baseUrl(toKURL("http://www.test.com")) | |
65 { | |
66 } | |
67 | |
68 protected: | |
69 void SetUp() override | |
70 { | |
71 // We want the images to load and JavaScript to be on. | |
72 m_helper.initialize(true, 0, 0, &configureSettings); | |
73 } | |
74 | |
75 void TearDown() override | |
76 { | |
77 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | |
78 } | |
79 | |
80 void setBaseFolder(const char* folder) | |
81 { | |
82 m_folder = WebString::fromUTF8(folder); | |
83 } | |
84 | |
85 void setRewriteURLFolder(const char* folder) | |
86 { | |
87 m_rewriteFolder = folder; | |
88 } | |
89 | |
90 void registerURL(const char* url, const char* file, const char* mimeType) | |
91 { | |
92 registerMockedURLLoad(KURL(m_baseUrl, url), WebString::fromUTF8(file), m
_folder, WebString::fromUTF8(mimeType)); | |
93 } | |
94 | |
95 void registerURL(const char* file, const char* mimeType) | |
96 { | |
97 registerURL(file, file, mimeType); | |
98 } | |
99 | |
100 void registerErrorURL(const char* file, int statusCode) | |
101 { | |
102 WebURLError error; | |
103 error.reason = 0xdead + statusCode; | |
104 error.domain = "PageSerializerTest"; | |
105 | |
106 WebURLResponse response; | |
107 response.initialize(); | |
108 response.setMIMEType("text/html"); | |
109 response.setHTTPStatusCode(statusCode); | |
110 | |
111 Platform::current()->unitTestSupport()->registerMockedErrorURL(KURL(m_ba
seUrl, file), response, error); | |
112 } | |
113 | |
114 void registerRewriteURL(const char* fromURL, const char* toURL) | |
115 { | |
116 m_rewriteURLs.add(fromURL, toURL); | |
117 } | |
118 | |
119 void serialize(const char* url) | |
120 { | |
121 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), KURL(m_base
Url, url).string().utf8().data()); | |
122 PageSerializer serializer(m_resources, *this); | |
123 Frame* frame = m_helper.webViewImpl()->mainFrameImpl()->frame(); | |
124 for (; frame; frame = frame->tree().traverseNext()) { | |
125 // This is safe, because tests do not do cross-site navigation | |
126 // (and therefore don't have remote frames). | |
127 serializer.serializeFrame(*toLocalFrame(frame)); | |
128 } | |
129 } | |
130 | |
131 Vector<SerializedResource>& getResources() | |
132 { | |
133 return m_resources; | |
134 } | |
135 | |
136 const SerializedResource* getResource(const char* url, const char* mimeType) | |
137 { | |
138 KURL kURL = KURL(m_baseUrl, url); | |
139 String mime(mimeType); | |
140 for (size_t i = 0; i < m_resources.size(); ++i) { | |
141 const SerializedResource& resource = m_resources[i]; | |
142 if (resource.url == kURL && !resource.data->isEmpty() | |
143 && (mime.isNull() || equalIgnoringCase(resource.mimeType, mime))
) | |
144 return &resource; | |
145 } | |
146 return nullptr; | |
147 } | |
148 | |
149 bool isSerialized(const char* url, const char* mimeType = 0) | |
150 { | |
151 return getResource(url, mimeType); | |
152 } | |
153 | |
154 String getSerializedData(const char* url, const char* mimeType = 0) | |
155 { | |
156 const SerializedResource* resource = getResource(url, mimeType); | |
157 if (resource) | |
158 return String(resource->data->data(), resource->data->size()); | |
159 return String(); | |
160 } | |
161 | |
162 private: | |
163 static void configureSettings(WebSettings* settings) | |
164 { | |
165 settings->setImagesEnabled(true); | |
166 settings->setLoadsImagesAutomatically(true); | |
167 settings->setJavaScriptEnabled(true); | |
168 } | |
169 | |
170 // PageSerializer::Delegate implementation. | |
171 bool rewriteLink(const Element& element, String& rewrittenLink) | |
172 { | |
173 String completeURL; | |
174 for (const auto& attribute : element.attributes()) { | |
175 if (element.hasLegalLinkAttribute(attribute.name())) { | |
176 completeURL = element.document().completeURL(attribute.value()); | |
177 break; | |
178 } | |
179 } | |
180 | |
181 if (completeURL.isNull() || !m_rewriteURLs.contains(completeURL)) | |
182 return false; | |
183 | |
184 StringBuilder uriBuilder; | |
185 uriBuilder.append(m_rewriteFolder); | |
186 uriBuilder.appendLiteral("/"); | |
187 uriBuilder.append(m_rewriteURLs.get(completeURL)); | |
188 rewrittenLink = uriBuilder.toString(); | |
189 return true; | |
190 } | |
191 | |
192 FrameTestHelpers::WebViewHelper m_helper; | |
193 WebString m_folder; | |
194 KURL m_baseUrl; | |
195 Vector<SerializedResource> m_resources; | |
196 HashMap<String, String> m_rewriteURLs; | |
197 String m_rewriteFolder; | |
198 }; | |
199 | |
200 TEST_F(PageSerializerTest, HTMLElements) | |
201 { | |
202 setBaseFolder("pageserializer/elements/"); | |
203 | |
204 registerURL("elements.html", "text/html"); | |
205 registerURL("style.css", "style.css", "text/css"); | |
206 registerURL("copyright.html", "empty.txt", "text/html"); | |
207 registerURL("script.js", "empty.txt", "text/javascript"); | |
208 | |
209 registerURL("bodyBackground.png", "image.png", "image/png"); | |
210 | |
211 registerURL("imageSrc.png", "image.png", "image/png"); | |
212 | |
213 registerURL("inputImage.png", "image.png", "image/png"); | |
214 | |
215 registerURL("tableBackground.png", "image.png", "image/png"); | |
216 registerURL("trBackground.png", "image.png", "image/png"); | |
217 registerURL("tdBackground.png", "image.png", "image/png"); | |
218 | |
219 registerURL("blockquoteCite.html", "empty.txt", "text/html"); | |
220 registerURL("qCite.html", "empty.txt", "text/html"); | |
221 registerURL("delCite.html", "empty.txt", "text/html"); | |
222 registerURL("insCite.html", "empty.txt", "text/html"); | |
223 | |
224 registerErrorURL("nonExisting.png", 404); | |
225 | |
226 serialize("elements.html"); | |
227 | |
228 EXPECT_EQ(8U, getResources().size()); | |
229 | |
230 EXPECT_TRUE(isSerialized("elements.html", "text/html")); | |
231 EXPECT_TRUE(isSerialized("style.css", "text/css")); | |
232 EXPECT_TRUE(isSerialized("bodyBackground.png", "image/png")); | |
233 EXPECT_TRUE(isSerialized("imageSrc.png", "image/png")); | |
234 EXPECT_TRUE(isSerialized("inputImage.png", "image/png")); | |
235 EXPECT_TRUE(isSerialized("tableBackground.png", "image/png")); | |
236 EXPECT_TRUE(isSerialized("trBackground.png", "image/png")); | |
237 EXPECT_TRUE(isSerialized("tdBackground.png", "image/png")); | |
238 EXPECT_FALSE(isSerialized("nonExisting.png", "image/png")); | |
239 } | |
240 | |
241 TEST_F(PageSerializerTest, Frames) | |
242 { | |
243 setBaseFolder("pageserializer/frames/"); | |
244 | |
245 registerURL("simple_frames.html", "text/html"); | |
246 registerURL("simple_frames_top.html", "text/html"); | |
247 registerURL("simple_frames_1.html", "text/html"); | |
248 registerURL("simple_frames_3.html", "text/html"); | |
249 | |
250 registerURL("frame_1.png", "image.png", "image/png"); | |
251 registerURL("frame_2.png", "image.png", "image/png"); | |
252 registerURL("frame_3.png", "image.png", "image/png"); | |
253 registerURL("frame_4.png", "image.png", "image/png"); | |
254 | |
255 serialize("simple_frames.html"); | |
256 | |
257 EXPECT_EQ(8U, getResources().size()); | |
258 | |
259 EXPECT_TRUE(isSerialized("simple_frames.html", "text/html")); | |
260 EXPECT_TRUE(isSerialized("simple_frames_top.html", "text/html")); | |
261 EXPECT_TRUE(isSerialized("simple_frames_1.html", "text/html")); | |
262 EXPECT_TRUE(isSerialized("simple_frames_3.html", "text/html")); | |
263 | |
264 EXPECT_TRUE(isSerialized("frame_1.png", "image/png")); | |
265 EXPECT_TRUE(isSerialized("frame_2.png", "image/png")); | |
266 EXPECT_TRUE(isSerialized("frame_3.png", "image/png")); | |
267 EXPECT_TRUE(isSerialized("frame_4.png", "image/png")); | |
268 } | |
269 | |
270 TEST_F(PageSerializerTest, IFrames) | |
271 { | |
272 setBaseFolder("pageserializer/frames/"); | |
273 | |
274 registerURL("top_frame.html", "text/html"); | |
275 registerURL("simple_iframe.html", "text/html"); | |
276 registerURL("object_iframe.html", "text/html"); | |
277 registerURL("embed_iframe.html", "text/html"); | |
278 registerURL("encoded_iframe.html", "text/html"); | |
279 | |
280 registerURL("top.png", "image.png", "image/png"); | |
281 registerURL("simple.png", "image.png", "image/png"); | |
282 registerURL("object.png", "image.png", "image/png"); | |
283 registerURL("embed.png", "image.png", "image/png"); | |
284 | |
285 serialize("top_frame.html"); | |
286 | |
287 EXPECT_EQ(10U, getResources().size()); | |
288 | |
289 EXPECT_TRUE(isSerialized("top_frame.html", "text/html")); | |
290 EXPECT_TRUE(isSerialized("simple_iframe.html", "text/html")); // Twice. | |
291 EXPECT_TRUE(isSerialized("object_iframe.html", "text/html")); | |
292 EXPECT_TRUE(isSerialized("embed_iframe.html", "text/html")); | |
293 EXPECT_TRUE(isSerialized("encoded_iframe.html", "text/html")); | |
294 | |
295 EXPECT_TRUE(isSerialized("top.png", "image/png")); | |
296 EXPECT_TRUE(isSerialized("simple.png", "image/png")); | |
297 EXPECT_TRUE(isSerialized("object.png", "image/png")); | |
298 EXPECT_TRUE(isSerialized("embed.png", "image/png")); | |
299 | |
300 // Ensure that page contents are not NFC-normalized before encoding. | |
301 String expectedMetaCharset = "<meta http-equiv=\"Content-Type\" content=\"te
xt/html; charset=EUC-KR\">"; | |
302 EXPECT_TRUE(getSerializedData("encoded_iframe.html", "text/html").contains(e
xpectedMetaCharset)); | |
303 EXPECT_TRUE(getSerializedData("encoded_iframe.html", "text/html").contains("
\xE4\xC5\xD1\xE2")); | |
304 EXPECT_FALSE(getSerializedData("encoded_iframe.html", "text/html").contains(
"\xE4\xC5\xE4\xC5")); | |
305 } | |
306 | |
307 // Tests that when serializing a page with blank frames these are reported with
their resources. | |
308 TEST_F(PageSerializerTest, BlankFrames) | |
309 { | |
310 setBaseFolder("pageserializer/frames/"); | |
311 | |
312 registerURL("blank_frames.html", "text/html"); | |
313 registerURL("red_background.png", "image.png", "image/png"); | |
314 registerURL("orange_background.png", "image.png", "image/png"); | |
315 registerURL("blue_background.png", "image.png", "image/png"); | |
316 | |
317 serialize("blank_frames.html"); | |
318 | |
319 EXPECT_EQ(7U, getResources().size()); | |
320 | |
321 EXPECT_TRUE(isSerialized("http://www.test.com/red_background.png", "image/pn
g")); | |
322 EXPECT_TRUE(isSerialized("http://www.test.com/orange_background.png", "image
/png")); | |
323 EXPECT_TRUE(isSerialized("http://www.test.com/blue_background.png", "image/p
ng")); | |
324 | |
325 // The blank frames no longer get magic URL (i.e. wyciwyg://frame/0), so we | |
326 // can't really assert their presence via URL. We also can't use content-id | |
327 // in assertions (since it is not deterministic). Therefore we need to rely | |
328 // on getResources().size() assertion above and on browser-level tests | |
329 // (i.e. SavePageMultiFrameBrowserTest.AboutBlank). | |
330 } | |
331 | |
332 TEST_F(PageSerializerTest, CSS) | |
333 { | |
334 setBaseFolder("pageserializer/css/"); | |
335 | |
336 registerURL("css_test_page.html", "text/html"); | |
337 registerURL("link_styles.css", "text/css"); | |
338 registerURL("encoding.css", "text/css"); | |
339 registerURL("import_style_from_link.css", "text/css"); | |
340 registerURL("import_styles.css", "text/css"); | |
341 registerURL("do_not_serialize.png", "image.png", "image/png"); | |
342 registerURL("red_background.png", "image.png", "image/png"); | |
343 registerURL("orange_background.png", "image.png", "image/png"); | |
344 registerURL("yellow_background.png", "image.png", "image/png"); | |
345 registerURL("green_background.png", "image.png", "image/png"); | |
346 registerURL("blue_background.png", "image.png", "image/png"); | |
347 registerURL("purple_background.png", "image.png", "image/png"); | |
348 registerURL("pink_background.png", "image.png", "image/png"); | |
349 registerURL("brown_background.png", "image.png", "image/png"); | |
350 registerURL("ul-dot.png", "image.png", "image/png"); | |
351 registerURL("ol-dot.png", "image.png", "image/png"); | |
352 | |
353 serialize("css_test_page.html"); | |
354 | |
355 EXPECT_EQ(15U, getResources().size()); | |
356 | |
357 EXPECT_FALSE(isSerialized("do_not_serialize.png", "image/png")); | |
358 | |
359 EXPECT_TRUE(isSerialized("css_test_page.html", "text/html")); | |
360 EXPECT_TRUE(isSerialized("link_styles.css", "text/css")); | |
361 EXPECT_TRUE(isSerialized("encoding.css", "text/css")); | |
362 EXPECT_TRUE(isSerialized("import_styles.css", "text/css")); | |
363 EXPECT_TRUE(isSerialized("import_style_from_link.css", "text/css")); | |
364 EXPECT_TRUE(isSerialized("red_background.png", "image/png")); | |
365 EXPECT_TRUE(isSerialized("orange_background.png", "image/png")); | |
366 EXPECT_TRUE(isSerialized("yellow_background.png", "image/png")); | |
367 EXPECT_TRUE(isSerialized("green_background.png", "image/png")); | |
368 EXPECT_TRUE(isSerialized("blue_background.png", "image/png")); | |
369 EXPECT_TRUE(isSerialized("purple_background.png", "image/png")); | |
370 EXPECT_TRUE(isSerialized("pink_background.png", "image/png")); | |
371 EXPECT_TRUE(isSerialized("brown_background.png", "image/png")); | |
372 EXPECT_TRUE(isSerialized("ul-dot.png", "image/png")); | |
373 EXPECT_TRUE(isSerialized("ol-dot.png", "image/png")); | |
374 | |
375 // Ensure encodings are specified. | |
376 EXPECT_TRUE(getSerializedData("link_styles.css", "text/css").startsWith("@ch
arset")); | |
377 EXPECT_TRUE(getSerializedData("import_styles.css", "text/css").startsWith("@
charset")); | |
378 EXPECT_TRUE(getSerializedData("import_style_from_link.css", "text/css").star
tsWith("@charset")); | |
379 EXPECT_TRUE(getSerializedData("encoding.css", "text/css").startsWith("@chars
et \"euc-kr\";")); | |
380 | |
381 // Ensure that stylesheet contents are not NFC-normalized before encoding. | |
382 EXPECT_TRUE(getSerializedData("encoding.css", "text/css").contains("\xE4\xC5
\xD1\xE2")); | |
383 EXPECT_FALSE(getSerializedData("encoding.css", "text/css").contains("\xE4\xC
5\xE4\xC5")); | |
384 } | |
385 | |
386 TEST_F(PageSerializerTest, CSSImport) | |
387 { | |
388 setBaseFolder("pageserializer/css/"); | |
389 | |
390 registerURL("import.html", "text/html"); | |
391 registerURL("import/base.css", "text/css"); | |
392 registerURL("import/relative/red-background.css", "text/css"); | |
393 registerURL("import/absolute/green-header.css", "text/css"); | |
394 | |
395 serialize("import.html"); | |
396 | |
397 EXPECT_TRUE(isSerialized("import.html", "text/html")); | |
398 EXPECT_TRUE(isSerialized("import/base.css", "text/css")); | |
399 EXPECT_TRUE(isSerialized("import/relative/red-background.css", "text/css")); | |
400 EXPECT_TRUE(isSerialized("import/absolute/green-header.css", "text/css")); | |
401 } | |
402 | |
403 TEST_F(PageSerializerTest, XMLDeclaration) | |
404 { | |
405 V8TestingScope scope(v8::Isolate::GetCurrent()); | |
406 setBaseFolder("pageserializer/xml/"); | |
407 | |
408 registerURL("xmldecl.xml", "text/xml"); | |
409 serialize("xmldecl.xml"); | |
410 | |
411 String expectedStart("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); | |
412 EXPECT_TRUE(getSerializedData("xmldecl.xml").startsWith(expectedStart)); | |
413 } | |
414 | |
415 TEST_F(PageSerializerTest, DTD) | |
416 { | |
417 setBaseFolder("pageserializer/dtd/"); | |
418 | |
419 registerURL("html5.html", "text/html"); | |
420 serialize("html5.html"); | |
421 | |
422 String expectedStart("<!DOCTYPE html>"); | |
423 EXPECT_TRUE(getSerializedData("html5.html").startsWith(expectedStart)); | |
424 } | |
425 | |
426 TEST_F(PageSerializerTest, Font) | |
427 { | |
428 setBaseFolder("pageserializer/font/"); | |
429 | |
430 registerURL("font.html", "text/html"); | |
431 registerURL("font.ttf", "application/octet-stream"); | |
432 | |
433 serialize("font.html"); | |
434 | |
435 EXPECT_TRUE(isSerialized("font.ttf", "application/octet-stream")); | |
436 } | |
437 | |
438 TEST_F(PageSerializerTest, DataURI) | |
439 { | |
440 setBaseFolder("pageserializer/datauri/"); | |
441 | |
442 registerURL("page_with_data.html", "text/html"); | |
443 | |
444 serialize("page_with_data.html"); | |
445 | |
446 EXPECT_EQ(1U, getResources().size()); | |
447 EXPECT_TRUE(isSerialized("page_with_data.html", "text/html")); | |
448 } | |
449 | |
450 TEST_F(PageSerializerTest, DataURIMorphing) | |
451 { | |
452 setBaseFolder("pageserializer/datauri/"); | |
453 | |
454 registerURL("page_with_morphing_data.html", "text/html"); | |
455 | |
456 serialize("page_with_morphing_data.html"); | |
457 | |
458 EXPECT_EQ(2U, getResources().size()); | |
459 EXPECT_TRUE(isSerialized("page_with_morphing_data.html", "text/html")); | |
460 } | |
461 | |
462 TEST_F(PageSerializerTest, RewriteLinksSimple) | |
463 { | |
464 setBaseFolder("pageserializer/rewritelinks/"); | |
465 setRewriteURLFolder("folder"); | |
466 | |
467 registerURL("rewritelinks_simple.html", "text/html"); | |
468 registerURL("absolute.png", "image.png", "image/png"); | |
469 registerURL("relative.png", "image.png", "image/png"); | |
470 registerRewriteURL("http://www.test.com/absolute.png", "a.png"); | |
471 registerRewriteURL("http://www.test.com/relative.png", "b.png"); | |
472 | |
473 serialize("rewritelinks_simple.html"); | |
474 | |
475 EXPECT_EQ(3U, getResources().size()); | |
476 EXPECT_NE(getSerializedData("rewritelinks_simple.html", "text/html").find("\
"folder/a.png\""), kNotFound); | |
477 EXPECT_NE(getSerializedData("rewritelinks_simple.html", "text/html").find("\
"folder/b.png\""), kNotFound); | |
478 } | |
479 | |
480 // Test that we don't regress https://bugs.webkit.org/show_bug.cgi?id=99105 | |
481 TEST_F(PageSerializerTest, SVGImageDontCrash) | |
482 { | |
483 setBaseFolder("pageserializer/svg/"); | |
484 | |
485 registerURL("page_with_svg_image.html", "text/html"); | |
486 registerURL("green_rectangle.svg", "image/svg+xml"); | |
487 | |
488 serialize("page_with_svg_image.html"); | |
489 | |
490 EXPECT_EQ(2U, getResources().size()); | |
491 | |
492 EXPECT_TRUE(isSerialized("green_rectangle.svg", "image/svg+xml")); | |
493 EXPECT_GT(getSerializedData("green_rectangle.svg", "image/svg+xml").length()
, 250U); | |
494 } | |
495 | |
496 TEST_F(PageSerializerTest, DontIncludeErrorImage) | |
497 { | |
498 setBaseFolder("pageserializer/image/"); | |
499 | |
500 registerURL("page_with_img_error.html", "text/html"); | |
501 registerURL("error_image.png", "image/png"); | |
502 | |
503 serialize("page_with_img_error.html"); | |
504 | |
505 EXPECT_EQ(1U, getResources().size()); | |
506 EXPECT_TRUE(isSerialized("page_with_img_error.html", "text/html")); | |
507 EXPECT_FALSE(isSerialized("error_image.png", "image/png")); | |
508 } | |
509 | |
510 TEST_F(PageSerializerTest, NamespaceElementsDontCrash) | |
511 { | |
512 setBaseFolder("pageserializer/namespace/"); | |
513 | |
514 registerURL("namespace_element.html", "text/html"); | |
515 | |
516 serialize("namespace_element.html"); | |
517 | |
518 EXPECT_EQ(1U, getResources().size()); | |
519 EXPECT_TRUE(isSerialized("namespace_element.html", "text/html")); | |
520 EXPECT_GT(getSerializedData("namespace_element.html", "text/html").length(),
0U); | |
521 } | |
522 | |
523 TEST_F(PageSerializerTest, markOfTheWebDeclaration) | |
524 { | |
525 EXPECT_EQ("saved from url=(0015)http://foo.com/", PageSerializer::markOfTheW
ebDeclaration(KURL(ParsedURLString, "http://foo.com"))); | |
526 EXPECT_EQ("saved from url=(0015)http://f-o.com/", PageSerializer::markOfTheW
ebDeclaration(KURL(ParsedURLString, "http://f-o.com"))); | |
527 EXPECT_EQ("saved from url=(0019)http://foo.com-%2D/", PageSerializer::markOf
TheWebDeclaration(KURL(ParsedURLString, "http://foo.com--"))); | |
528 EXPECT_EQ("saved from url=(0024)http://f-%2D.com-%2D%3E/", PageSerializer::m
arkOfTheWebDeclaration(KURL(ParsedURLString, "http://f--.com-->"))); | |
529 EXPECT_EQ("saved from url=(0020)http://foo.com/?-%2D", PageSerializer::markO
fTheWebDeclaration(KURL(ParsedURLString, "http://foo.com?--"))); | |
530 EXPECT_EQ("saved from url=(0020)http://foo.com/#-%2D", PageSerializer::markO
fTheWebDeclaration(KURL(ParsedURLString, "http://foo.com#--"))); | |
531 EXPECT_EQ("saved from url=(0026)http://foo.com/#bar-%2Dbaz", PageSerializer:
:markOfTheWebDeclaration(KURL(ParsedURLString, "http://foo.com#bar--baz"))); | |
532 } | |
533 | |
534 } // namespace blink | |
OLD | NEW |