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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 253 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
254 new net::test_server::BasicHttpResponse); | 254 new net::test_server::BasicHttpResponse); |
255 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); | 255 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); |
256 http_response->AddCustomHeader("Location", redirect_target.spec()); | 256 http_response->AddCustomHeader("Location", redirect_target.spec()); |
257 return http_response.Pass(); | 257 return http_response.Pass(); |
258 } | 258 } |
259 | 259 |
260 } // namespace | 260 } // namespace |
261 | 261 |
| 262 bool NavigateIframeToURL(WebContents* web_contents, |
| 263 std::string iframe_id, |
| 264 const GURL& url) { |
| 265 // TODO(creis): This should wait for LOAD_STOP, but cross-site subframe |
| 266 // navigations generate extra DidStartLoading and DidStopLoading messages. |
| 267 // Until we replace swappedout:// with frame proxies, we need to listen for |
| 268 // something else. For now, we trigger NEW_SUBFRAME navigations and listen |
| 269 // for commit. See https://crbug.com/436250. |
| 270 std::string script = base::StringPrintf( |
| 271 "setTimeout(\"" |
| 272 "var iframes = document.getElementById('%s');iframes.src='%s';" |
| 273 "\",0)", |
| 274 iframe_id.c_str(), url.spec().c_str()); |
| 275 WindowedNotificationObserver load_observer( |
| 276 NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 277 Source<NavigationController>(&web_contents->GetController())); |
| 278 bool result = ExecuteScript(web_contents, script); |
| 279 load_observer.Wait(); |
| 280 return result; |
| 281 } |
262 | 282 |
263 GURL GetFileUrlWithQuery(const base::FilePath& path, | 283 GURL GetFileUrlWithQuery(const base::FilePath& path, |
264 const std::string& query_string) { | 284 const std::string& query_string) { |
265 GURL url = net::FilePathToFileURL(path); | 285 GURL url = net::FilePathToFileURL(path); |
266 if (!query_string.empty()) { | 286 if (!query_string.empty()) { |
267 GURL::Replacements replacements; | 287 GURL::Replacements replacements; |
268 replacements.SetQueryStr(query_string); | 288 replacements.SetQueryStr(query_string); |
269 return url.ReplaceComponents(replacements); | 289 return url.ReplaceComponents(replacements); |
270 } | 290 } |
271 return url; | 291 return url; |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 | 917 |
898 bool WebContentsAddedObserver::RenderViewCreatedCalled() { | 918 bool WebContentsAddedObserver::RenderViewCreatedCalled() { |
899 if (child_observer_) { | 919 if (child_observer_) { |
900 return child_observer_->render_view_created_called_ && | 920 return child_observer_->render_view_created_called_ && |
901 child_observer_->main_frame_created_called_; | 921 child_observer_->main_frame_created_called_; |
902 } | 922 } |
903 return false; | 923 return false; |
904 } | 924 } |
905 | 925 |
906 } // namespace content | 926 } // namespace content |
OLD | NEW |