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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 new content::MessageLoopRunner); | 716 new content::MessageLoopRunner); |
717 InterstitialObserver observer(web_contents, | 717 InterstitialObserver observer(web_contents, |
718 base::Closure(), | 718 base::Closure(), |
719 loop_runner->QuitClosure()); | 719 loop_runner->QuitClosure()); |
720 if (!task.is_null()) | 720 if (!task.is_null()) |
721 task.Run(); | 721 task.Run(); |
722 // At this point, web_contents may have been deleted. | 722 // At this point, web_contents may have been deleted. |
723 loop_runner->Run(); | 723 loop_runner->Run(); |
724 } | 724 } |
725 | 725 |
| 726 bool WaitForRenderFrameReady(RenderFrameHost* rfh) { |
| 727 if (!rfh) |
| 728 return false; |
| 729 std::string result; |
| 730 EXPECT_TRUE( |
| 731 content::ExecuteScriptAndExtractString( |
| 732 rfh, |
| 733 "(function() {" |
| 734 " var done = false;" |
| 735 " function checkState() {" |
| 736 " if (!done && document.readyState == 'complete') {" |
| 737 " done = true;" |
| 738 " window.domAutomationController.send('pageLoadComplete');" |
| 739 " }" |
| 740 " }" |
| 741 " checkState();" |
| 742 " document.addEventListener('readystatechange', checkState);" |
| 743 "})();", |
| 744 &result)); |
| 745 return result == "pageLoadComplete"; |
| 746 } |
| 747 |
726 TitleWatcher::TitleWatcher(WebContents* web_contents, | 748 TitleWatcher::TitleWatcher(WebContents* web_contents, |
727 const base::string16& expected_title) | 749 const base::string16& expected_title) |
728 : WebContentsObserver(web_contents), | 750 : WebContentsObserver(web_contents), |
729 message_loop_runner_(new MessageLoopRunner) { | 751 message_loop_runner_(new MessageLoopRunner) { |
730 EXPECT_TRUE(web_contents != NULL); | 752 EXPECT_TRUE(web_contents != NULL); |
731 expected_titles_.push_back(expected_title); | 753 expected_titles_.push_back(expected_title); |
732 } | 754 } |
733 | 755 |
734 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { | 756 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { |
735 expected_titles_.push_back(expected_title); | 757 expected_titles_.push_back(expected_title); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 | 939 |
918 bool WebContentsAddedObserver::RenderViewCreatedCalled() { | 940 bool WebContentsAddedObserver::RenderViewCreatedCalled() { |
919 if (child_observer_) { | 941 if (child_observer_) { |
920 return child_observer_->render_view_created_called_ && | 942 return child_observer_->render_view_created_called_ && |
921 child_observer_->main_frame_created_called_; | 943 child_observer_->main_frame_created_called_; |
922 } | 944 } |
923 return false; | 945 return false; |
924 } | 946 } |
925 | 947 |
926 } // namespace content | 948 } // namespace content |
OLD | NEW |