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 "chrome/browser/ui/webui/options/options_ui_browsertest.h" | 5 #include "chrome/browser/ui/webui/options/options_ui_browsertest.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 // It is not possible to subscribe to the OnFinishedLoading event before the | 124 // It is not possible to subscribe to the OnFinishedLoading event before the |
125 // call to NavigateToURL(), because the WebUI does not yet exist at that time. | 125 // call to NavigateToURL(), because the WebUI does not yet exist at that time. |
126 // However, it is safe to subscribe afterwards, because the event will always | 126 // However, it is safe to subscribe afterwards, because the event will always |
127 // be posted asynchronously to the message loop. | 127 // be posted asynchronously to the message loop. |
128 scoped_refptr<MessageLoopRunner> message_loop_runner(new MessageLoopRunner); | 128 scoped_refptr<MessageLoopRunner> message_loop_runner(new MessageLoopRunner); |
129 scoped_ptr<OptionsUI::OnFinishedLoadingCallbackList::Subscription> | 129 scoped_ptr<OptionsUI::OnFinishedLoadingCallbackList::Subscription> |
130 subscription = options_ui->RegisterOnFinishedLoadingCallback( | 130 subscription = options_ui->RegisterOnFinishedLoadingCallback( |
131 message_loop_runner->QuitClosure()); | 131 message_loop_runner->QuitClosure()); |
132 message_loop_runner->Run(); | 132 message_loop_runner->Run(); |
| 133 |
| 134 // The OnFinishedLoading event, which indicates that all WebUI initialization |
| 135 // methods have been called on the JS side, is temporally unrelated to whether |
| 136 // or not the WebContents considers itself to have finished loading. We want |
| 137 // to wait for this too, however, because, e.g. this is a sufficient condition |
| 138 // to get the focus properly placed on a form element. |
| 139 content::WaitForLoadStop(web_contents); |
133 } | 140 } |
134 | 141 |
135 void OptionsUIBrowserTest::NavigateToSettingsFrame() { | 142 void OptionsUIBrowserTest::NavigateToSettingsFrame() { |
136 const GURL& url = GURL(chrome::kChromeUISettingsFrameURL); | 143 const GURL& url = GURL(chrome::kChromeUISettingsFrameURL); |
137 ui_test_utils::NavigateToURL(browser(), url); | 144 ui_test_utils::NavigateToURL(browser(), url); |
138 } | 145 } |
139 | 146 |
140 void OptionsUIBrowserTest::VerifyNavbar() { | 147 void OptionsUIBrowserTest::VerifyNavbar() { |
141 bool navbar_exist = false; | 148 bool navbar_exist = false; |
142 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 149 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 run_loop.Run(); | 316 run_loop.Run(); |
310 | 317 |
311 // Verify that the settings page has updated and lists two profiles. | 318 // Verify that the settings page has updated and lists two profiles. |
312 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 319 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
313 contents, javascript, &profiles)); | 320 contents, javascript, &profiles)); |
314 EXPECT_EQ(2, profiles); | 321 EXPECT_EQ(2, profiles); |
315 } | 322 } |
316 #endif | 323 #endif |
317 | 324 |
318 } // namespace options | 325 } // namespace options |
OLD | NEW |