OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Opera Software ASA. All rights reserved. | 2 * Copyright (c) 2013, Opera Software ASA. 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 | 113 |
114 void registerRewriteURL(const char* fromURL, const char* toURL) | 114 void registerRewriteURL(const char* fromURL, const char* toURL) |
115 { | 115 { |
116 m_rewriteURLs.add(fromURL, toURL); | 116 m_rewriteURLs.add(fromURL, toURL); |
117 } | 117 } |
118 | 118 |
119 void serialize(const char* url) | 119 void serialize(const char* url) |
120 { | 120 { |
121 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), KURL(m_base
Url, url).string().utf8().data()); | 121 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), KURL(m_base
Url, url).string().utf8().data()); |
122 PageSerializer serializer(m_resources, this); | 122 PageSerializer serializer(m_resources, *this); |
123 Frame* frame = m_helper.webViewImpl()->mainFrameImpl()->frame(); | 123 Frame* frame = m_helper.webViewImpl()->mainFrameImpl()->frame(); |
124 for (; frame; frame = frame->tree().traverseNext()) { | 124 for (; frame; frame = frame->tree().traverseNext()) { |
125 // This is safe, because tests do not do cross-site navigation | 125 // This is safe, because tests do not do cross-site navigation |
126 // (and therefore don't have remote frames). | 126 // (and therefore don't have remote frames). |
127 serializer.serializeFrame(*toLocalFrame(frame)); | 127 serializer.serializeFrame(*toLocalFrame(frame)); |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 Vector<SerializedResource>& getResources() | 131 Vector<SerializedResource>& getResources() |
132 { | 132 { |
(...skipping 28 matching lines...) Expand all Loading... |
161 | 161 |
162 private: | 162 private: |
163 static void configureSettings(WebSettings* settings) | 163 static void configureSettings(WebSettings* settings) |
164 { | 164 { |
165 settings->setImagesEnabled(true); | 165 settings->setImagesEnabled(true); |
166 settings->setLoadsImagesAutomatically(true); | 166 settings->setLoadsImagesAutomatically(true); |
167 settings->setJavaScriptEnabled(true); | 167 settings->setJavaScriptEnabled(true); |
168 } | 168 } |
169 | 169 |
170 // PageSerializer::Delegate implementation. | 170 // PageSerializer::Delegate implementation. |
171 bool shouldIgnoreAttribute(const Attribute&) override | |
172 { | |
173 return false; | |
174 } | |
175 | |
176 // PageSerializer::Delegate implementation. | |
177 bool rewriteLink(const Element& element, String& rewrittenLink) | 171 bool rewriteLink(const Element& element, String& rewrittenLink) |
178 { | 172 { |
179 String completeURL; | 173 String completeURL; |
180 for (const auto& attribute : element.attributes()) { | 174 for (const auto& attribute : element.attributes()) { |
181 if (element.hasLegalLinkAttribute(attribute.name())) { | 175 if (element.hasLegalLinkAttribute(attribute.name())) { |
182 completeURL = element.document().completeURL(attribute.value()); | 176 completeURL = element.document().completeURL(attribute.value()); |
183 break; | 177 break; |
184 } | 178 } |
185 } | 179 } |
186 | 180 |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 EXPECT_EQ("saved from url=(0015)http://foo.com/", PageSerializer::markOfTheW
ebDeclaration(KURL(ParsedURLString, "http://foo.com"))); | 525 EXPECT_EQ("saved from url=(0015)http://foo.com/", PageSerializer::markOfTheW
ebDeclaration(KURL(ParsedURLString, "http://foo.com"))); |
532 EXPECT_EQ("saved from url=(0015)http://f-o.com/", PageSerializer::markOfTheW
ebDeclaration(KURL(ParsedURLString, "http://f-o.com"))); | 526 EXPECT_EQ("saved from url=(0015)http://f-o.com/", PageSerializer::markOfTheW
ebDeclaration(KURL(ParsedURLString, "http://f-o.com"))); |
533 EXPECT_EQ("saved from url=(0019)http://foo.com-%2D/", PageSerializer::markOf
TheWebDeclaration(KURL(ParsedURLString, "http://foo.com--"))); | 527 EXPECT_EQ("saved from url=(0019)http://foo.com-%2D/", PageSerializer::markOf
TheWebDeclaration(KURL(ParsedURLString, "http://foo.com--"))); |
534 EXPECT_EQ("saved from url=(0024)http://f-%2D.com-%2D%3E/", PageSerializer::m
arkOfTheWebDeclaration(KURL(ParsedURLString, "http://f--.com-->"))); | 528 EXPECT_EQ("saved from url=(0024)http://f-%2D.com-%2D%3E/", PageSerializer::m
arkOfTheWebDeclaration(KURL(ParsedURLString, "http://f--.com-->"))); |
535 EXPECT_EQ("saved from url=(0020)http://foo.com/?-%2D", PageSerializer::markO
fTheWebDeclaration(KURL(ParsedURLString, "http://foo.com?--"))); | 529 EXPECT_EQ("saved from url=(0020)http://foo.com/?-%2D", PageSerializer::markO
fTheWebDeclaration(KURL(ParsedURLString, "http://foo.com?--"))); |
536 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#--"))); |
537 EXPECT_EQ("saved from url=(0026)http://foo.com/#bar-%2Dbaz", PageSerializer:
:markOfTheWebDeclaration(KURL(ParsedURLString, "http://foo.com#bar--baz"))); | 531 EXPECT_EQ("saved from url=(0026)http://foo.com/#bar-%2Dbaz", PageSerializer:
:markOfTheWebDeclaration(KURL(ParsedURLString, "http://foo.com#bar--baz"))); |
538 } | 532 } |
539 | 533 |
540 } // namespace blink | 534 } // namespace blink |
OLD | NEW |