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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 72 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
73 } | 73 } |
74 | 74 |
75 void registerMockedURLLoad(const std::string& url, const WebString& fileName
) | 75 void registerMockedURLLoad(const std::string& url, const WebString& fileName
) |
76 { | 76 { |
77 URLTestHelpers::registerMockedURLLoad(toKURL(url), fileName, WebString::
fromUTF8("pageserialization/"), WebString::fromUTF8("text/html")); | 77 URLTestHelpers::registerMockedURLLoad(toKURL(url), fileName, WebString::
fromUTF8("pageserialization/"), WebString::fromUTF8("text/html")); |
78 } | 78 } |
79 | 79 |
80 void loadURLInTopFrame(const WebURL& url) | 80 void loadURLInTopFrame(const WebURL& url) |
81 { | 81 { |
82 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), url.string(
).utf8()); | 82 WebURLRequest urlRequest; |
| 83 urlRequest.initialize(); |
| 84 urlRequest.setURL(url); |
| 85 m_helper.webView()->mainFrame()->loadRequest(urlRequest); |
| 86 // Make sure any pending request get served. |
| 87 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); |
83 } | 88 } |
84 | 89 |
85 static bool webVectorContains(const WebVector<WebURL>& vector, const char* u
rl) | 90 static bool webVectorContains(const WebVector<WebURL>& vector, const char* u
rl) |
86 { | 91 { |
87 return vector.contains(WebURL(toKURL(std::string(url)))); | 92 return vector.contains(WebURL(toKURL(std::string(url)))); |
88 } | 93 } |
89 | 94 |
90 // Useful for debugging. | 95 // Useful for debugging. |
91 static void printWebURLs(const WebVector<WebURL>& urls) | 96 static void printWebURLs(const WebVector<WebURL>& urls) |
92 { | 97 { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 WebString::fromUTF8("object_iframe.html")); | 153 WebString::fromUTF8("object_iframe.html")); |
149 registerMockedURLLoad("http://www.test.com/embed_iframe.html", | 154 registerMockedURLLoad("http://www.test.com/embed_iframe.html", |
150 WebString::fromUTF8("embed_iframe.html")); | 155 WebString::fromUTF8("embed_iframe.html")); |
151 // If we don't register a mocked resource for awesome.png, it causes the | 156 // If we don't register a mocked resource for awesome.png, it causes the |
152 // document loader of the iframe that has it as its src to assert on close, | 157 // document loader of the iframe that has it as its src to assert on close, |
153 // not sure why. | 158 // not sure why. |
154 registerMockedURLLoad("http://www.test.com/awesome.png", | 159 registerMockedURLLoad("http://www.test.com/awesome.png", |
155 WebString::fromUTF8("awesome.png")); | 160 WebString::fromUTF8("awesome.png")); |
156 | 161 |
157 loadURLInTopFrame(topFrameURL); | 162 loadURLInTopFrame(topFrameURL); |
| 163 // OBJECT/EMBED have some delay to start to load their content. The first |
| 164 // serveAsynchronousMockedRequests call in loadURLInTopFrame() finishes |
| 165 // before the start. |
| 166 RefPtrWillBeRawPtr<Document> document = static_cast<PassRefPtrWillBeRawPtr<D
ocument> >(webView()->mainFrame()->document()); |
| 167 document->updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasksS
ynchronously); |
| 168 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
158 | 169 |
159 // Retrieve all resources. | 170 // Retrieve all resources. |
160 WebVector<WebURL> frames; | 171 WebVector<WebURL> frames; |
161 WebVector<WebURL> resources; | 172 WebVector<WebURL> resources; |
162 ASSERT_TRUE(WebPageSerializer::retrieveAllResources( | 173 ASSERT_TRUE(WebPageSerializer::retrieveAllResources( |
163 webView(), m_supportedSchemes, &resources, &frames)); | 174 webView(), m_supportedSchemes, &resources, &frames)); |
164 | 175 |
165 // Tests that all resources from the frame have been retrieved. | 176 // Tests that all resources from the frame have been retrieved. |
166 EXPECT_EQ(4U, frames.size()); // There should be no duplicates. | 177 EXPECT_EQ(4U, frames.size()); // There should be no duplicates. |
167 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com")); | 178 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com")); |
168 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/simple_iframe.htm
l")); | 179 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/simple_iframe.htm
l")); |
169 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/object_iframe.htm
l")); | 180 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/object_iframe.htm
l")); |
170 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/embed_iframe.html
")); | 181 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/embed_iframe.html
")); |
171 | 182 |
172 EXPECT_EQ(5U, resources.size()); // There should be no duplicates. | 183 EXPECT_EQ(5U, resources.size()); // There should be no duplicates. |
173 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/awesome.png"))
; | 184 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/awesome.png"))
; |
174 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png
")); | 185 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png
")); |
175 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/flash.swf")); | 186 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/flash.swf")); |
176 // FIXME: for some reason the following resources is missing on one of the b
ot | 187 // FIXME: for some reason the following resources is missing on one of the b
ot |
177 // causing the test to fail. Probably a plugin issue. | 188 // causing the test to fail. Probably a plugin issue. |
178 // EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/music.mid")
); | 189 // EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/music.mid")
); |
179 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/object.png")); | 190 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/object.png")); |
180 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/embed.png")); | 191 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/embed.png")); |
181 } | 192 } |
182 | 193 |
183 } | 194 } |
OLD | NEW |