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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebPageSerializerTest.cpp

Issue 1373573002: ABANDONED: OOPIFs: Moving stitching of local paths from renderer to browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@page-serialization-recursive-begone
Patch Set: Rebasing... Created 5 years, 2 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 25 matching lines...) Expand all
36 #include "public/platform/WebString.h" 36 #include "public/platform/WebString.h"
37 #include "public/platform/WebURL.h" 37 #include "public/platform/WebURL.h"
38 #include "public/platform/WebURLRequest.h" 38 #include "public/platform/WebURLRequest.h"
39 #include "public/platform/WebURLResponse.h" 39 #include "public/platform/WebURLResponse.h"
40 #include "public/platform/WebUnitTestSupport.h" 40 #include "public/platform/WebUnitTestSupport.h"
41 #include "public/web/WebDocument.h" 41 #include "public/web/WebDocument.h"
42 #include "public/web/WebFrame.h" 42 #include "public/web/WebFrame.h"
43 #include "public/web/WebPageSerializerClient.h" 43 #include "public/web/WebPageSerializerClient.h"
44 #include "public/web/WebView.h" 44 #include "public/web/WebView.h"
45 #include "web/tests/FrameTestHelpers.h" 45 #include "web/tests/FrameTestHelpers.h"
46 #include "wtf/Assertions.h"
46 #include <gtest/gtest.h> 47 #include <gtest/gtest.h>
47 48
48 using blink::Document; 49 using blink::Document;
49 using blink::URLTestHelpers::toKURL; 50 using blink::URLTestHelpers::toKURL;
50 51
51 namespace blink { 52 namespace blink {
52 53
53 namespace { 54 namespace {
54 class SimpleWebPageSerializerClient : public WebPageSerializerClient { 55 class SimpleWebPageSerializerClient : public WebPageSerializerClient {
55 public: 56 public:
56 std::string toString() const { return m_string; } 57 std::string toString() const { return m_string; }
57 58
58 private: 59 private:
59 void didSerializeDataForFrame(const WebURL&, const WebCString& data, PageSer ializationStatus) final 60 void writeHtmlFragment(const WebCString& data) override { m_string += data; }
61
62 void writeLocalPathForSubframe(const WebFrame& subframe) override
60 { 63 {
61 m_string += data; 64 // SimpleWebPageSerializerClient is currently only used in tests
65 // of pages without subframes.
66 ASSERT_NOT_REACHED();
62 } 67 }
63 68
69 void writeLocalPathForSavableResource(const WebURL& savableResourceURL) over ride
70 {
71 // SimpleWebPageSerializerClient is currently only used in tests
72 // of pages without subresources.
73 ASSERT_NOT_REACHED();
74 }
75
76 void endOfFrame() override {}
77
64 std::string m_string; 78 std::string m_string;
65 }; 79 };
66 80
67 } // namespace 81 } // namespace
68 82
69 class WebPageSerializerTest : public testing::Test { 83 class WebPageSerializerTest : public testing::Test {
70 public: 84 public:
71 WebPageSerializerTest() : m_supportedSchemes(static_cast<size_t>(3)) 85 WebPageSerializerTest() : m_supportedSchemes(static_cast<size_t>(3))
72 { 86 {
73 m_supportedSchemes[0] = "http"; 87 m_supportedSchemes[0] = "http";
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 188
175 TEST_F(WebPageSerializerTest, fromUrlWithMinusMinus) 189 TEST_F(WebPageSerializerTest, fromUrlWithMinusMinus)
176 { 190 {
177 WebURL topFrameURL = toKURL("http://www.test.com?--x--"); 191 WebURL topFrameURL = toKURL("http://www.test.com?--x--");
178 registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("text_only_pag e.html")); 192 registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("text_only_pag e.html"));
179 loadURLInTopFrame(topFrameURL); 193 loadURLInTopFrame(topFrameURL);
180 194
181 SimpleWebPageSerializerClient serializerClient; 195 SimpleWebPageSerializerClient serializerClient;
182 WebVector<WebURL> links(&topFrameURL, 1); 196 WebVector<WebURL> links(&topFrameURL, 1);
183 WebVector<WebString> localPaths(&"local", 1); 197 WebVector<WebString> localPaths(&"local", 1);
184 WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &ser ializerClient, links, localPaths, ""); 198 WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &ser ializerClient);
185 199
186 EXPECT_EQ("<!-- saved from url=(0030)http://www.test.com/?-%2Dx-%2D -->", se rializerClient.toString().substr(1, 60)); 200 EXPECT_EQ("<!-- saved from url=(0030)http://www.test.com/?-%2Dx-%2D -->", se rializerClient.toString().substr(1, 60));
187 } 201 }
188 202
189 TEST_F(WebPageSerializerTest, MultipleFrames) 203 TEST_F(WebPageSerializerTest, MultipleFrames)
190 { 204 {
191 // Register the mocked frames. 205 // Register the mocked frames.
192 WebURL topFrameURL = toKURL("http://www.test.com"); 206 WebURL topFrameURL = toKURL("http://www.test.com");
193 registerMockedURLLoad("http://www.test.com", WebString::fromUTF8("top_frame. html")); 207 registerMockedURLLoad("http://www.test.com", WebString::fromUTF8("top_frame. html"));
194 registerMockedURLLoad("http://www.test.com/simple_iframe.html", 208 registerMockedURLLoad("http://www.test.com/simple_iframe.html",
(...skipping 28 matching lines...) Expand all
223 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png ")); 237 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png "));
224 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/flash.swf")); 238 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/flash.swf"));
225 // FIXME: for some reason the following resources is missing on one of the b ot 239 // FIXME: for some reason the following resources is missing on one of the b ot
226 // causing the test to fail. Probably a plugin issue. 240 // causing the test to fail. Probably a plugin issue.
227 // EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/music.mid") ); 241 // EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/music.mid") );
228 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/object.png")); 242 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/object.png"));
229 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/embed.png")); 243 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/embed.png"));
230 } 244 }
231 245
232 } // namespace blink 246 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebPageSerializerImpl.cpp ('k') | third_party/WebKit/public/web/WebPageSerializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698