summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autocomplete/autocomplete_browsertest.cc5
-rw-r--r--chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc6
-rw-r--r--chrome/browser/debugger/devtools_sanity_unittest.cc6
-rw-r--r--chrome/browser/extensions/app_process_apitest.cc22
-rw-r--r--chrome/browser/extensions/extension_browsertests_misc.cc7
-rw-r--r--chrome/browser/geolocation/geolocation_browsertest.cc26
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc31
-rw-r--r--chrome/browser/task_manager/task_manager_browsertest.cc5
-rw-r--r--chrome/test/base/in_process_browser_test.cc8
9 files changed, 47 insertions, 69 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc
index a324375..bbc4166 100644
--- a/chrome/browser/autocomplete/autocomplete_browsertest.cc
+++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc
@@ -149,11 +149,10 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) {
EXPECT_EQ(UTF8ToUTF16(chrome::kAboutBlankURL),
location_bar->location_entry()->GetText());
location_bar->location_entry()->SetUserText(string16());
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
browser()->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL),
PageTransition::START_PAGE);
- observer.Wait();
+ ui_test_utils::WaitForNavigation(
+ &browser()->GetSelectedTabContents()->controller());
EXPECT_EQ(UTF8ToUTF16(chrome::kAboutBlankURL),
location_bar->location_entry()->GetText());
browser()->CloseTab();
diff --git a/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc b/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc
index a76430f..67a3293 100644
--- a/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc
+++ b/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc
@@ -37,10 +37,10 @@ class TabCloseableStateWatcherTest : public InProcessBrowserTest {
protected:
// Wrapper for Browser::AddTabWithURL
void AddTabWithURL(Browser* browser, const GURL& url) {
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
AddTabAtIndexToBrowser(browser, 0, url, PageTransition::TYPED);
- observer.Wait();
+ // Wait for page to finish loading.
+ ui_test_utils::WaitForNavigation(
+ &browser->GetSelectedTabContents()->controller());
}
// Wrapper for TabCloseableStateWatcher::CanCloseTab
diff --git a/chrome/browser/debugger/devtools_sanity_unittest.cc b/chrome/browser/debugger/devtools_sanity_unittest.cc
index 6410108..5e8ad78 100644
--- a/chrome/browser/debugger/devtools_sanity_unittest.cc
+++ b/chrome/browser/debugger/devtools_sanity_unittest.cc
@@ -116,11 +116,11 @@ class DevToolsSanityTest : public InProcessBrowserTest {
GURL url = test_server()->GetURL(test_page);
ui_test_utils::NavigateToURL(browser(), url);
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
inspected_rvh_ = GetInspectedTab()->render_view_host();
window_ = DevToolsWindow::OpenDevToolsWindow(inspected_rvh_);
- observer.Wait();
+ RenderViewHost* client_rvh = window_->GetRenderViewHost();
+ TabContents* client_contents = client_rvh->delegate()->GetAsTabContents();
+ ui_test_utils::WaitForNavigation(&client_contents->controller());
}
TabContents* GetInspectedTab() {
diff --git a/chrome/browser/extensions/app_process_apitest.cc b/chrome/browser/extensions/app_process_apitest.cc
index 2e37fd3..1dcc950 100644
--- a/chrome/browser/extensions/app_process_apitest.cc
+++ b/chrome/browser/extensions/app_process_apitest.cc
@@ -38,8 +38,6 @@ static void WindowOpenHelper(Browser* browser,
RenderViewHost* opener_host,
const GURL& url,
bool newtab_process_should_equal_opener) {
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
opener_host, L"", L"window.open('" + UTF8ToWide(url.spec()) + L"');"));
@@ -50,7 +48,9 @@ static void WindowOpenHelper(Browser* browser,
EXPECT_TRUE(last_active_browser);
TabContents* newtab = last_active_browser->GetSelectedTabContents();
EXPECT_TRUE(newtab);
- observer.Wait();
+ if (!newtab->controller().GetLastCommittedEntry() ||
+ newtab->controller().GetLastCommittedEntry()->url() != url)
+ ui_test_utils::WaitForNavigation(&newtab->controller());
EXPECT_EQ(url, newtab->controller().GetLastCommittedEntry()->url());
if (newtab_process_should_equal_opener)
EXPECT_EQ(opener_host->process(), newtab->render_view_host()->process());
@@ -61,9 +61,6 @@ static void WindowOpenHelper(Browser* browser,
// Simulates a page navigating itself to an URL, and waits for the navigation.
static void NavigateTabHelper(TabContents* contents, const GURL& url) {
bool result = false;
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP,
- NotificationService::AllSources());
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
contents->render_view_host(), L"",
L"window.addEventListener('unload', function() {"
@@ -72,7 +69,10 @@ static void NavigateTabHelper(TabContents* contents, const GURL& url) {
L"window.location = '" + UTF8ToWide(url.spec()) + L"';",
&result));
ASSERT_TRUE(result);
- observer.Wait();
+
+ if (!contents->controller().GetLastCommittedEntry() ||
+ contents->controller().GetLastCommittedEntry()->url() != url)
+ ui_test_utils::WaitForNavigation(&contents->controller());
EXPECT_EQ(url, contents->controller().GetLastCommittedEntry()->url());
}
@@ -285,20 +285,16 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcess) {
// Enable app and reload via JavaScript.
EnableExtension(app->id());
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->render_view_host(),
L"", L"location.reload();"));
- observer.Wait();
+ ui_test_utils::WaitForNavigation(&contents->controller());
EXPECT_TRUE(contents->render_view_host()->process()->is_extension_process());
// Disable app and reload via JavaScript.
DisableExtension(app->id());
- ui_test_utils::WindowedNotificationObserver observer2(
- content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->render_view_host(),
L"", L"location.reload();"));
- observer2.Wait();
+ ui_test_utils::WaitForNavigation(&contents->controller());
EXPECT_FALSE(contents->render_view_host()->process()->is_extension_process());
}
diff --git a/chrome/browser/extensions/extension_browsertests_misc.cc b/chrome/browser/extensions/extension_browsertests_misc.cc
index ed0d8462..8a9e996 100644
--- a/chrome/browser/extensions/extension_browsertests_misc.cc
+++ b/chrome/browser/extensions/extension_browsertests_misc.cc
@@ -612,9 +612,6 @@ static void WindowOpenHelper(Browser* browser, const GURL& start_url,
TabContents** newtab_result) {
ui_test_utils::NavigateToURL(browser, start_url);
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP,
- NotificationService::AllSources());
ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
browser->GetSelectedTabContents()->render_view_host(), L"",
L"window.open('" + UTF8ToWide(newtab_url) + L"');"));
@@ -625,7 +622,9 @@ static void WindowOpenHelper(Browser* browser, const GURL& start_url,
TabContents* newtab = last_active_browser->GetSelectedTabContents();
EXPECT_TRUE(newtab);
GURL expected_url = start_url.Resolve(newtab_url);
- observer.Wait();
+ if (!newtab->controller().GetLastCommittedEntry() ||
+ newtab->controller().GetLastCommittedEntry()->url() != expected_url)
+ ui_test_utils::WaitForNavigation(&newtab->controller());
EXPECT_EQ(expected_url,
newtab->controller().GetLastCommittedEntry()->url());
if (newtab_result)
diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc
index d866057..43d89bd 100644
--- a/chrome/browser/geolocation/geolocation_browsertest.cc
+++ b/chrome/browser/geolocation/geolocation_browsertest.cc
@@ -343,6 +343,14 @@ class GeolocationBrowserTest : public InProcessBrowserTest {
settings_state.state_map().find(requesting_origin)->second);
}
+ void WaitForNavigation() {
+ LOG(WARNING) << "will block for navigation";
+ NavigationController* controller =
+ &current_browser_->GetSelectedTabContents()->controller();
+ ui_test_utils::WaitForNavigation(controller);
+ LOG(WARNING) << "navigated";
+ }
+
void CheckStringValueFromJavascriptForTab(
const std::string& expected, const std::string& function,
TabContents* tab_contents) {
@@ -497,12 +505,8 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest,
// MockLocationProvider must have been created.
ASSERT_TRUE(MockLocationProvider::instance_);
Geoposition fresh_position = GeopositionFromLatLong(3.17, 4.23);
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP,
- Source<NavigationController>(
- &current_browser_->GetSelectedTabContents()->controller()));
NotifyGeoposition(fresh_position);
- observer.Wait();
+ WaitForNavigation();
CheckGeoposition(fresh_position);
// Disable navigation for this frame.
@@ -534,12 +538,8 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest,
// MockLocationProvider must have been created.
ASSERT_TRUE(MockLocationProvider::instance_);
Geoposition cached_position = GeopositionFromLatLong(5.67, 8.09);
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP,
- Source<NavigationController>(
- &current_browser_->GetSelectedTabContents()->controller()));
NotifyGeoposition(cached_position);
- observer.Wait();
+ WaitForNavigation();
CheckGeoposition(cached_position);
// Disable navigation for this frame.
@@ -642,12 +642,8 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TwoWatchesInOneFrame) {
// The second watch will now have cancelled. Ensure an update still makes
// its way through to the first watcher.
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP,
- Source<NavigationController>(
- &current_browser_->GetSelectedTabContents()->controller()));
NotifyGeoposition(final_position);
- observer.Wait();
+ WaitForNavigation();
CheckGeoposition(final_position);
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
index 52f580c..1521f25 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -320,6 +319,12 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest,
Source<TabContents>(contents));
}
+ void WaitForNavigation() {
+ NavigationController* controller =
+ &browser()->GetSelectedTabContents()->controller();
+ ui_test_utils::WaitForNavigation(controller);
+ }
+
void AssertReportSent() {
// When a report is scheduled in the IO thread we should get notified.
ui_test_utils::RunMessageLoop();
@@ -417,12 +422,8 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) {
AddURLResult(url, SafeBrowsingService::URL_MALWARE);
ui_test_utils::NavigateToURL(browser(), url);
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP,
- Source<NavigationController>(
- &browser()->GetSelectedTabContentsWrapper()->controller()));
SendCommand("\"proceed\""); // Simulate the user clicking "proceed"
- observer.Wait();
+ WaitForNavigation(); // Wait until we finish the navigation.
AssertNoInterstitial(true); // Assert the interstitial is gone.
EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL());
}
@@ -445,12 +446,8 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) {
ui_test_utils::NavigateToURL(browser(), url);
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP,
- Source<NavigationController>(
- &browser()->GetSelectedTabContentsWrapper()->controller()));
SendCommand("\"proceed\""); // Simulate the user clicking "proceed".
- observer.Wait();
+ WaitForNavigation(); // Wait until we finish the navigation.
AssertNoInterstitial(true); // Assert the interstitial is gone
EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL());
}
@@ -461,12 +458,8 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) {
ui_test_utils::NavigateToURL(browser(), url);
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP,
- Source<NavigationController>(
- &browser()->GetSelectedTabContentsWrapper()->controller()));
SendCommand("\"reportError\""); // Simulate the user clicking "report error"
- observer.Wait();
+ WaitForNavigation(); // Wait until we finish the navigation.
AssertNoInterstitial(false); // Assert the interstitial is gone
// We are in the error reporting page.
@@ -481,12 +474,8 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest,
ui_test_utils::NavigateToURL(browser(), url);
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP,
- Source<NavigationController>(
- &browser()->GetSelectedTabContentsWrapper()->controller()));
SendCommand("\"learnMore\""); // Simulate the user clicking "learn more"
- observer.Wait();
+ WaitForNavigation(); // Wait until we finish the navigation.
AssertNoInterstitial(false); // Assert the interstitial is gone
// We are in the help page.
diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc
index aaf0aef..2fe1ad4 100644
--- a/chrome/browser/task_manager/task_manager_browsertest.cc
+++ b/chrome/browser/task_manager/task_manager_browsertest.cc
@@ -295,10 +295,9 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabs) {
// Open a new tab to an app URL before the app is loaded.
GURL url(base_url.Resolve("path1/empty.html"));
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
AddTabAtIndex(0, url, PageTransition::TYPED);
- observer.Wait();
+ ui_test_utils::WaitForNavigation(
+ &browser()->GetSelectedTabContents()->controller());
// Check that the third entry's title starts with "Tab:".
string16 tab_prefix = l10n_util::GetStringFUTF16(
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc
index 7986608..d8d621f 100644
--- a/chrome/test/base/in_process_browser_test.cc
+++ b/chrome/test/base/in_process_browser_test.cc
@@ -274,12 +274,12 @@ Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) {
}
void InProcessBrowserTest::AddBlankTabAndShow(Browser* browser) {
- ui_test_utils::WindowedNotificationObserver observer(
- content::NOTIFICATION_LOAD_STOP,
- NotificationService::AllSources());
browser->AddSelectedTabWithURL(
GURL(chrome::kAboutBlankURL), PageTransition::START_PAGE);
- observer.Wait();
+
+ // Wait for the page to finish loading.
+ ui_test_utils::WaitForNavigation(
+ &browser->GetSelectedTabContents()->controller());
browser->window()->Show();
}