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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 | 288 |
289 bool IsLastCommittedEntryOfPageType(WebContents* web_contents, | 289 bool IsLastCommittedEntryOfPageType(WebContents* web_contents, |
290 content::PageType page_type) { | 290 content::PageType page_type) { |
291 NavigationEntry* last_entry = | 291 NavigationEntry* last_entry = |
292 web_contents->GetController().GetLastCommittedEntry(); | 292 web_contents->GetController().GetLastCommittedEntry(); |
293 if (!last_entry) | 293 if (!last_entry) |
294 return false; | 294 return false; |
295 return last_entry->GetPageType() == page_type; | 295 return last_entry->GetPageType() == page_type; |
296 } | 296 } |
297 | 297 |
298 bool NavigateIframeToURL(WebContents* web_contents, | |
299 const GURL& url, | |
300 std::string iframe_id) { | |
301 // TODO(creis): This should wait for LOAD_STOP, but cross-site subframe | |
302 // navigations generate extra DidStartLoading and DidStopLoading messages. | |
303 // Until we replace swappedout:// with frame proxies, we need to listen for | |
304 // something else. For now, we trigger NEW_SUBFRAME navigations and listen | |
305 // for commit. | |
Charlie Reis
2014/12/12 18:02:45
Also mention http://crbug.com/436250.
alexmos
2014/12/13 00:58:12
Done.
| |
306 std::string script = base::StringPrintf( | |
307 "setTimeout(\"" | |
308 "var iframes = document.getElementById('%s');iframes.src='%s';" | |
309 "\",0)", | |
310 iframe_id.c_str(), url.spec().c_str()); | |
311 WindowedNotificationObserver load_observer( | |
312 NOTIFICATION_NAV_ENTRY_COMMITTED, | |
313 Source<NavigationController>(&web_contents->GetController())); | |
314 bool result = ExecuteScript(web_contents, script); | |
315 load_observer.Wait(); | |
316 return result; | |
317 } | |
318 | |
298 void CrashTab(WebContents* web_contents) { | 319 void CrashTab(WebContents* web_contents) { |
299 RenderProcessHost* rph = web_contents->GetRenderProcessHost(); | 320 RenderProcessHost* rph = web_contents->GetRenderProcessHost(); |
300 RenderProcessHostWatcher watcher( | 321 RenderProcessHostWatcher watcher( |
301 rph, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 322 rph, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
302 rph->Shutdown(0, false); | 323 rph->Shutdown(0, false); |
303 watcher.Wait(); | 324 watcher.Wait(); |
304 } | 325 } |
305 | 326 |
306 #if defined(USE_AURA) | 327 #if defined(USE_AURA) |
307 bool IsResizeComplete(aura::test::WindowEventDispatcherTestApi* dispatcher_test, | 328 bool IsResizeComplete(aura::test::WindowEventDispatcherTestApi* dispatcher_test, |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
834 } | 855 } |
835 // The queue should not be empty, unless we were quit because of a timeout. | 856 // The queue should not be empty, unless we were quit because of a timeout. |
836 if (message_queue_.empty()) | 857 if (message_queue_.empty()) |
837 return false; | 858 return false; |
838 *message = message_queue_.front(); | 859 *message = message_queue_.front(); |
839 message_queue_.pop(); | 860 message_queue_.pop(); |
840 return true; | 861 return true; |
841 } | 862 } |
842 | 863 |
843 } // namespace content | 864 } // namespace content |
OLD | NEW |