Chromium Code Reviews| 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" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/test/test_timeouts.h" | 15 #include "base/test/test_timeouts.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "content/browser/renderer_host/render_widget_host_impl.h" | 17 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 18 #include "content/browser/web_contents/web_contents_impl.h" | 18 #include "content/browser/web_contents/web_contents_impl.h" |
| 19 #include "content/browser/web_contents/web_contents_view.h" | 19 #include "content/browser/web_contents/web_contents_view.h" |
| 20 #include "content/common/input/synthetic_web_input_event_builders.h" | 20 #include "content/common/input/synthetic_web_input_event_builders.h" |
| 21 #include "content/public/browser/browser_context.h" | 21 #include "content/public/browser/browser_context.h" |
| 22 #include "content/public/browser/dom_operation_notification_details.h" | 22 #include "content/public/browser/dom_operation_notification_details.h" |
| 23 #include "content/public/browser/histogram_fetcher.h" | 23 #include "content/public/browser/histogram_fetcher.h" |
| 24 #include "content/public/browser/interstitial_page.h" | |
| 24 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
| 25 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 26 #include "content/public/browser/notification_types.h" | 27 #include "content/public/browser/notification_types.h" |
| 27 #include "content/public/browser/render_frame_host.h" | 28 #include "content/public/browser/render_frame_host.h" |
| 28 #include "content/public/browser/render_process_host.h" | 29 #include "content/public/browser/render_process_host.h" |
| 29 #include "content/public/browser/render_view_host.h" | 30 #include "content/public/browser/render_view_host.h" |
| 30 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 31 #include "content/public/browser/web_contents_observer.h" | 32 #include "content/public/browser/web_contents_observer.h" |
| 32 #include "content/public/test/test_utils.h" | 33 #include "content/public/test/test_utils.h" |
| 33 #include "net/base/filename_util.h" | 34 #include "net/base/filename_util.h" |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 716 new content::MessageLoopRunner); | 717 new content::MessageLoopRunner); |
| 717 InterstitialObserver observer(web_contents, | 718 InterstitialObserver observer(web_contents, |
| 718 base::Closure(), | 719 base::Closure(), |
| 719 loop_runner->QuitClosure()); | 720 loop_runner->QuitClosure()); |
| 720 if (!task.is_null()) | 721 if (!task.is_null()) |
| 721 task.Run(); | 722 task.Run(); |
| 722 // At this point, web_contents may have been deleted. | 723 // At this point, web_contents may have been deleted. |
| 723 loop_runner->Run(); | 724 loop_runner->Run(); |
| 724 } | 725 } |
| 725 | 726 |
| 727 bool WaitForInterstitialReady(content::InterstitialPage* interstitial) { | |
| 728 content::RenderFrameHost* rfh = interstitial->GetMainFrame(); | |
|
mattm
2015/01/22 02:28:32
Since the rest of this function isn't interstitial
meacer
2015/01/22 03:18:07
Done.
| |
| 729 if (!rfh) | |
| 730 return false; | |
| 731 bool load_complete = false; | |
| 732 EXPECT_TRUE( | |
| 733 content::ExecuteScriptAndExtractBool( | |
| 734 rfh, | |
| 735 "(function() {" | |
| 736 " var done = false;" | |
| 737 " function checkState() {" | |
| 738 " if (!done && document.readyState == 'complete') {" | |
| 739 " done = true;" | |
| 740 " window.domAutomationController.send(true);" | |
| 741 " }" | |
| 742 " }" | |
| 743 " checkState();" | |
| 744 " document.addEventListener('readystatechange', checkState);" | |
| 745 "})();", | |
| 746 &load_complete)); | |
| 747 return load_complete; | |
| 748 } | |
| 749 | |
| 726 TitleWatcher::TitleWatcher(WebContents* web_contents, | 750 TitleWatcher::TitleWatcher(WebContents* web_contents, |
| 727 const base::string16& expected_title) | 751 const base::string16& expected_title) |
| 728 : WebContentsObserver(web_contents), | 752 : WebContentsObserver(web_contents), |
| 729 message_loop_runner_(new MessageLoopRunner) { | 753 message_loop_runner_(new MessageLoopRunner) { |
| 730 EXPECT_TRUE(web_contents != NULL); | 754 EXPECT_TRUE(web_contents != NULL); |
| 731 expected_titles_.push_back(expected_title); | 755 expected_titles_.push_back(expected_title); |
| 732 } | 756 } |
| 733 | 757 |
| 734 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { | 758 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { |
| 735 expected_titles_.push_back(expected_title); | 759 expected_titles_.push_back(expected_title); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 917 | 941 |
| 918 bool WebContentsAddedObserver::RenderViewCreatedCalled() { | 942 bool WebContentsAddedObserver::RenderViewCreatedCalled() { |
| 919 if (child_observer_) { | 943 if (child_observer_) { |
| 920 return child_observer_->render_view_created_called_ && | 944 return child_observer_->render_view_created_called_ && |
| 921 child_observer_->main_frame_created_called_; | 945 child_observer_->main_frame_created_called_; |
| 922 } | 946 } |
| 923 return false; | 947 return false; |
| 924 } | 948 } |
| 925 | 949 |
| 926 } // namespace content | 950 } // namespace content |
| OLD | NEW |