OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 251 |
252 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 252 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
253 new net::test_server::BasicHttpResponse); | 253 new net::test_server::BasicHttpResponse); |
254 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); | 254 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); |
255 http_response->AddCustomHeader("Location", redirect_target.spec()); | 255 http_response->AddCustomHeader("Location", redirect_target.spec()); |
256 return http_response.Pass(); | 256 return http_response.Pass(); |
257 } | 257 } |
258 | 258 |
259 } // namespace | 259 } // namespace |
260 | 260 |
| 261 bool NavigateIframeToURL(WebContents* web_contents, |
| 262 std::string iframe_id, |
| 263 const GURL& url) { |
| 264 // TODO(creis): This should wait for LOAD_STOP, but cross-site subframe |
| 265 // navigations generate extra DidStartLoading and DidStopLoading messages. |
| 266 // Until we replace swappedout:// with frame proxies, we need to listen for |
| 267 // something else. For now, we trigger NEW_SUBFRAME navigations and listen |
| 268 // for commit. See https://crbug.com/436250. |
| 269 std::string script = base::StringPrintf( |
| 270 "setTimeout(\"" |
| 271 "var iframes = document.getElementById('%s');iframes.src='%s';" |
| 272 "\",0)", |
| 273 iframe_id.c_str(), url.spec().c_str()); |
| 274 WindowedNotificationObserver load_observer( |
| 275 NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 276 Source<NavigationController>(&web_contents->GetController())); |
| 277 bool result = ExecuteScript(web_contents, script); |
| 278 load_observer.Wait(); |
| 279 return result; |
| 280 } |
261 | 281 |
262 GURL GetFileUrlWithQuery(const base::FilePath& path, | 282 GURL GetFileUrlWithQuery(const base::FilePath& path, |
263 const std::string& query_string) { | 283 const std::string& query_string) { |
264 GURL url = net::FilePathToFileURL(path); | 284 GURL url = net::FilePathToFileURL(path); |
265 if (!query_string.empty()) { | 285 if (!query_string.empty()) { |
266 GURL::Replacements replacements; | 286 GURL::Replacements replacements; |
267 replacements.SetQueryStr(query_string); | 287 replacements.SetQueryStr(query_string); |
268 return url.ReplaceComponents(replacements); | 288 return url.ReplaceComponents(replacements); |
269 } | 289 } |
270 return url; | 290 return url; |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 } | 854 } |
835 // The queue should not be empty, unless we were quit because of a timeout. | 855 // The queue should not be empty, unless we were quit because of a timeout. |
836 if (message_queue_.empty()) | 856 if (message_queue_.empty()) |
837 return false; | 857 return false; |
838 *message = message_queue_.front(); | 858 *message = message_queue_.front(); |
839 message_queue_.pop(); | 859 message_queue_.pop(); |
840 return true; | 860 return true; |
841 } | 861 } |
842 | 862 |
843 } // namespace content | 863 } // namespace content |
OLD | NEW |