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

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: Removed no longer needed WebKit dependency. 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 167
154 TEST_F(WebPageSerializerTest, fromUrlWithMinusMinus) 168 TEST_F(WebPageSerializerTest, fromUrlWithMinusMinus)
155 { 169 {
156 WebURL topFrameURL = toKURL("http://www.test.com?--x--"); 170 WebURL topFrameURL = toKURL("http://www.test.com?--x--");
157 registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("text_only_pag e.html")); 171 registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("text_only_pag e.html"));
158 loadURLInTopFrame(topFrameURL); 172 loadURLInTopFrame(topFrameURL);
159 173
160 SimpleWebPageSerializerClient serializerClient; 174 SimpleWebPageSerializerClient serializerClient;
161 WebVector<WebURL> links(&topFrameURL, 1); 175 WebVector<WebURL> links(&topFrameURL, 1);
162 WebVector<WebString> localPaths(&"local", 1); 176 WebVector<WebString> localPaths(&"local", 1);
163 WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &ser ializerClient, links, localPaths, ""); 177 WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &ser ializerClient);
164 178
165 EXPECT_EQ("<!-- saved from url=(0030)http://www.test.com/?-%2Dx-%2D -->", se rializerClient.toString().substr(1, 60)); 179 EXPECT_EQ("<!-- saved from url=(0030)http://www.test.com/?-%2Dx-%2D -->", se rializerClient.toString().substr(1, 60));
166 } 180 }
167 181
168 TEST_F(WebPageSerializerTest, MultipleFrames) 182 TEST_F(WebPageSerializerTest, MultipleFrames)
169 { 183 {
170 // Register the mocked frames. 184 // Register the mocked frames.
171 WebURL topFrameURL = toKURL("http://www.test.com"); 185 WebURL topFrameURL = toKURL("http://www.test.com");
172 registerMockedURLLoad("http://www.test.com", WebString::fromUTF8("top_frame. html")); 186 registerMockedURLLoad("http://www.test.com", WebString::fromUTF8("top_frame. html"));
173 registerMockedURLLoad("http://www.test.com/simple_iframe.html", 187 registerMockedURLLoad("http://www.test.com/simple_iframe.html",
(...skipping 28 matching lines...) Expand all
202 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png ")); 216 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png "));
203 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/flash.swf")); 217 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/flash.swf"));
204 // FIXME: for some reason the following resources is missing on one of the b ot 218 // FIXME: for some reason the following resources is missing on one of the b ot
205 // causing the test to fail. Probably a plugin issue. 219 // causing the test to fail. Probably a plugin issue.
206 // EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/music.mid") ); 220 // EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/music.mid") );
207 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/object.png")); 221 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/object.png"));
208 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/embed.png")); 222 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/embed.png"));
209 } 223 }
210 224
211 } // namespace blink 225 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698