OLD | NEW |
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 registerMockedURLLoad(toKURL("http://www.test.com/green_background.png")
, WebString::fromUTF8("green_background.png"), WebString::fromUTF8("pageserializ
er/"), pngMimeType()); | 152 registerMockedURLLoad(toKURL("http://www.test.com/green_background.png")
, WebString::fromUTF8("green_background.png"), WebString::fromUTF8("pageserializ
er/"), pngMimeType()); |
153 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"),
WebString::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer
/"), pngMimeType()); | 153 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"),
WebString::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer
/"), pngMimeType()); |
154 registerMockedURLLoad(toKURL("http://www.test.com/purple_background.png"
), WebString::fromUTF8("purple_background.png"), WebString::fromUTF8("pageserial
izer/"), pngMimeType()); | 154 registerMockedURLLoad(toKURL("http://www.test.com/purple_background.png"
), WebString::fromUTF8("purple_background.png"), WebString::fromUTF8("pageserial
izer/"), pngMimeType()); |
155 registerMockedURLLoad(toKURL("http://www.test.com/ul-dot.png"), WebStrin
g::fromUTF8("ul-dot.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()
); | 155 registerMockedURLLoad(toKURL("http://www.test.com/ul-dot.png"), WebStrin
g::fromUTF8("ul-dot.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()
); |
156 registerMockedURLLoad(toKURL("http://www.test.com/ol-dot.png"), WebStrin
g::fromUTF8("ol-dot.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()
); | 156 registerMockedURLLoad(toKURL("http://www.test.com/ol-dot.png"), WebStrin
g::fromUTF8("ol-dot.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()
); |
157 return topFrameURL; | 157 return topFrameURL; |
158 } | 158 } |
159 | 159 |
160 void loadURLInTopFrame(const WebURL& url) | 160 void loadURLInTopFrame(const WebURL& url) |
161 { | 161 { |
162 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), url.string(
).utf8()); | 162 WebURLRequest urlRequest; |
| 163 urlRequest.initialize(); |
| 164 urlRequest.setURL(url); |
| 165 m_helper.webView()->mainFrame()->loadRequest(urlRequest); |
| 166 // Make sure any pending request get served. |
| 167 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); |
| 168 // Some requests get delayed, run the timer. |
| 169 runPendingTasks(); |
| 170 // Server the delayed resources. |
| 171 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); |
163 } | 172 } |
164 | 173 |
165 const WebString& htmlMimeType() const { return m_htmlMimeType; } | 174 const WebString& htmlMimeType() const { return m_htmlMimeType; } |
166 const WebString& xhtmlMimeType() const { return m_xhtmlMimeType; } | 175 const WebString& xhtmlMimeType() const { return m_xhtmlMimeType; } |
167 const WebString& cssMimeType() const { return m_cssMimeType; } | 176 const WebString& cssMimeType() const { return m_cssMimeType; } |
168 const WebString& pngMimeType() const { return m_pngMimeType; } | 177 const WebString& pngMimeType() const { return m_pngMimeType; } |
169 const WebString& svgMimeType() const { return m_svgMimeType; } | 178 const WebString& svgMimeType() const { return m_svgMimeType; } |
170 | 179 |
171 static bool resourceVectorContains(const WebVector<WebPageSerializer::Resour
ce>& resources, const char* url, const char* mimeType) | 180 static bool resourceVectorContains(const WebVector<WebPageSerializer::Resour
ce>& resources, const char* url, const char* mimeType) |
172 { | 181 { |
(...skipping 30 matching lines...) Expand all Loading... |
203 // Register the mocked frames. | 212 // Register the mocked frames. |
204 WebURL topFrameURL = toKURL("http://www.test.com"); | 213 WebURL topFrameURL = toKURL("http://www.test.com"); |
205 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("top_frame.html"), We
bString::fromUTF8("pageserializer/"), htmlMimeType()); | 214 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("top_frame.html"), We
bString::fromUTF8("pageserializer/"), htmlMimeType()); |
206 registerMockedURLLoad(toKURL("http://www.test.com/iframe.html"), WebString::
fromUTF8("iframe.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType())
; | 215 registerMockedURLLoad(toKURL("http://www.test.com/iframe.html"), WebString::
fromUTF8("iframe.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType())
; |
207 registerMockedURLLoad(toKURL("http://www.test.com/iframe2.html"), WebString:
:fromUTF8("iframe2.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType(
)); | 216 registerMockedURLLoad(toKURL("http://www.test.com/iframe2.html"), WebString:
:fromUTF8("iframe2.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType(
)); |
208 registerMockedURLLoad(toKURL("http://www.test.com/red_background.png"), WebS
tring::fromUTF8("red_background.png"), WebString::fromUTF8("pageserializer/"), p
ngMimeType()); | 217 registerMockedURLLoad(toKURL("http://www.test.com/red_background.png"), WebS
tring::fromUTF8("red_background.png"), WebString::fromUTF8("pageserializer/"), p
ngMimeType()); |
209 registerMockedURLLoad(toKURL("http://www.test.com/green_background.png"), We
bString::fromUTF8("green_background.png"), WebString::fromUTF8("pageserializer/"
), pngMimeType()); | 218 registerMockedURLLoad(toKURL("http://www.test.com/green_background.png"), We
bString::fromUTF8("green_background.png"), WebString::fromUTF8("pageserializer/"
), pngMimeType()); |
210 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"), Web
String::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer/"),
pngMimeType()); | 219 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"), Web
String::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer/"),
pngMimeType()); |
211 | 220 |
212 loadURLInTopFrame(topFrameURL); | 221 loadURLInTopFrame(topFrameURL); |
| 222 // OBJECT/EMBED have some delay to start to load their content. The first |
| 223 // serveAsynchronousMockedRequests call in loadURLInTopFrame() finishes |
| 224 // before the start. |
| 225 RefPtrWillBeRawPtr<Document> document = static_cast<PassRefPtrWillBeRawPtr<D
ocument> >(webView()->mainFrame()->document()); |
| 226 document->updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasksS
ynchronously); |
| 227 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
213 | 228 |
214 WebVector<WebPageSerializer::Resource> resources; | 229 WebVector<WebPageSerializer::Resource> resources; |
215 WebPageSerializer::serialize(webView(), &resources); | 230 WebPageSerializer::serialize(webView(), &resources); |
216 ASSERT_FALSE(resources.isEmpty()); | 231 ASSERT_FALSE(resources.isEmpty()); |
217 | 232 |
218 // The first resource should be the main-frame. | 233 // The first resource should be the main-frame. |
219 const WebPageSerializer::Resource& resource = resources[0]; | 234 const WebPageSerializer::Resource& resource = resources[0]; |
220 EXPECT_TRUE(resource.url == WebURL(toKURL("http://www.test.com"))); | 235 EXPECT_TRUE(resource.url == WebURL(toKURL("http://www.test.com"))); |
221 EXPECT_EQ(0, resource.mimeType.compare(WebCString("text/html"))); | 236 EXPECT_EQ(0, resource.mimeType.compare(WebCString("text/html"))); |
222 EXPECT_FALSE(resource.data.isEmpty()); | 237 EXPECT_FALSE(resource.data.isEmpty()); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 // exactly two times. | 511 // exactly two times. |
497 size_t nbDataURLs = 0; | 512 size_t nbDataURLs = 0; |
498 LineReader lineReader(std::string(mhtmlData.data())); | 513 LineReader lineReader(std::string(mhtmlData.data())); |
499 std::string line; | 514 std::string line; |
500 while (lineReader.getNextLine(&line)) { | 515 while (lineReader.getNextLine(&line)) { |
501 if (line.find("data:text") != std::string::npos) | 516 if (line.find("data:text") != std::string::npos) |
502 nbDataURLs++; | 517 nbDataURLs++; |
503 } | 518 } |
504 EXPECT_EQ(2u, nbDataURLs); | 519 EXPECT_EQ(2u, nbDataURLs); |
505 } | 520 } |
OLD | NEW |