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/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "content/common/view_messages.h" | 23 #include "content/common/view_messages.h" |
24 #include "content/public/browser/browser_context.h" | 24 #include "content/public/browser/browser_context.h" |
25 #include "content/public/browser/histogram_fetcher.h" | 25 #include "content/public/browser/histogram_fetcher.h" |
26 #include "content/public/browser/navigation_entry.h" | 26 #include "content/public/browser/navigation_entry.h" |
27 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
28 #include "content/public/browser/notification_types.h" | 28 #include "content/public/browser/notification_types.h" |
29 #include "content/public/browser/render_frame_host.h" | 29 #include "content/public/browser/render_frame_host.h" |
30 #include "content/public/browser/render_process_host.h" | 30 #include "content/public/browser/render_process_host.h" |
31 #include "content/public/browser/render_view_host.h" | 31 #include "content/public/browser/render_view_host.h" |
32 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
| 33 #include "content/public/test/test_navigation_observer.h" |
33 #include "content/public/test/test_utils.h" | 34 #include "content/public/test/test_utils.h" |
34 #include "net/base/filename_util.h" | 35 #include "net/base/filename_util.h" |
35 #include "net/cookies/cookie_store.h" | 36 #include "net/cookies/cookie_store.h" |
36 #include "net/test/embedded_test_server/embedded_test_server.h" | 37 #include "net/test/embedded_test_server/embedded_test_server.h" |
37 #include "net/test/embedded_test_server/http_request.h" | 38 #include "net/test/embedded_test_server/http_request.h" |
38 #include "net/test/embedded_test_server/http_response.h" | 39 #include "net/test/embedded_test_server/http_response.h" |
39 #include "net/test/python_utils.h" | 40 #include "net/test/python_utils.h" |
40 #include "net/url_request/url_request_context.h" | 41 #include "net/url_request/url_request_context.h" |
41 #include "net/url_request/url_request_context_getter.h" | 42 #include "net/url_request/url_request_context_getter.h" |
42 #include "testing/gtest/include/gtest/gtest.h" | 43 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); | 304 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); |
304 http_response->AddCustomHeader("Location", redirect_target.spec()); | 305 http_response->AddCustomHeader("Location", redirect_target.spec()); |
305 return http_response.Pass(); | 306 return http_response.Pass(); |
306 } | 307 } |
307 | 308 |
308 } // namespace | 309 } // namespace |
309 | 310 |
310 bool NavigateIframeToURL(WebContents* web_contents, | 311 bool NavigateIframeToURL(WebContents* web_contents, |
311 std::string iframe_id, | 312 std::string iframe_id, |
312 const GURL& url) { | 313 const GURL& url) { |
313 // TODO(creis): This should wait for LOAD_STOP, but cross-site subframe | |
314 // navigations generate extra DidStartLoading and DidStopLoading messages. | |
315 // Until we replace swappedout:// with frame proxies, we need to listen for | |
316 // something else. For now, we trigger NEW_SUBFRAME navigations and listen | |
317 // for commit. See https://crbug.com/436250. | |
318 std::string script = base::StringPrintf( | 314 std::string script = base::StringPrintf( |
319 "setTimeout(\"" | 315 "setTimeout(\"" |
320 "var iframes = document.getElementById('%s');iframes.src='%s';" | 316 "var iframes = document.getElementById('%s');iframes.src='%s';" |
321 "\",0)", | 317 "\",0)", |
322 iframe_id.c_str(), url.spec().c_str()); | 318 iframe_id.c_str(), url.spec().c_str()); |
323 WindowedNotificationObserver load_observer( | 319 TestNavigationObserver load_observer(web_contents); |
324 NOTIFICATION_NAV_ENTRY_COMMITTED, | |
325 Source<NavigationController>(&web_contents->GetController())); | |
326 bool result = ExecuteScript(web_contents, script); | 320 bool result = ExecuteScript(web_contents, script); |
327 load_observer.Wait(); | 321 load_observer.Wait(); |
328 return result; | 322 return result; |
329 } | 323 } |
330 | 324 |
331 GURL GetFileUrlWithQuery(const base::FilePath& path, | 325 GURL GetFileUrlWithQuery(const base::FilePath& path, |
332 const std::string& query_string) { | 326 const std::string& query_string) { |
333 GURL url = net::FilePathToFileURL(path); | 327 GURL url = net::FilePathToFileURL(path); |
334 if (!query_string.empty()) { | 328 if (!query_string.empty()) { |
335 GURL::Replacements replacements; | 329 GURL::Replacements replacements; |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 void FrameWatcher::WaitFrames(int frames_to_wait) { | 1089 void FrameWatcher::WaitFrames(int frames_to_wait) { |
1096 if (frames_to_wait <= 0) | 1090 if (frames_to_wait <= 0) |
1097 return; | 1091 return; |
1098 base::RunLoop run_loop; | 1092 base::RunLoop run_loop; |
1099 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1093 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
1100 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); | 1094 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); |
1101 run_loop.Run(); | 1095 run_loop.Run(); |
1102 } | 1096 } |
1103 | 1097 |
1104 } // namespace content | 1098 } // namespace content |
OLD | NEW |