| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "base/time.h" | 6 #include "base/time.h" |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/content_settings/host_content_settings_map.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/renderer_host/render_view_host.h" | 10 #include "chrome/browser/renderer_host/render_view_host.h" |
| 11 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
| 12 #include "chrome/browser/tab_contents/tab_contents_observer.h" |
| 12 #include "chrome/browser/tab_contents/tab_specific_content_settings.h" | 13 #include "chrome/browser/tab_contents/tab_specific_content_settings.h" |
| 13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/common/render_messages_params.h" |
| 14 #include "chrome/test/in_process_browser_test.h" | 16 #include "chrome/test/in_process_browser_test.h" |
| 15 #include "chrome/test/ui_test_utils.h" | 17 #include "chrome/test/ui_test_utils.h" |
| 18 #include "net/base/host_port_pair.h" |
| 16 #include "net/test/test_server.h" | 19 #include "net/test/test_server.h" |
| 17 | 20 |
| 18 typedef std::pair<int, Value*> ExecuteDetailType; | 21 typedef std::pair<int, Value*> ExecuteDetailType; |
| 19 | 22 |
| 20 namespace { | 23 namespace { |
| 21 | 24 |
| 22 // NotificationObserver used to listen for EXECUTE_JAVASCRIPT_RESULT | 25 // NotificationObserver used to listen for EXECUTE_JAVASCRIPT_RESULT |
| 23 // notifications. | 26 // notifications. |
| 24 class ExecuteNotificationObserver : public NotificationObserver { | 27 class ExecuteNotificationObserver : public NotificationObserver { |
| 25 public: | 28 public: |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 219 |
| 217 ui_test_utils::NavigateToURL(browser(), test_url); | 220 ui_test_utils::NavigateToURL(browser(), test_url); |
| 218 | 221 |
| 219 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 222 TabContents* tab_contents = browser()->GetSelectedTabContents(); |
| 220 ASSERT_EQ(UTF8ToUTF16(test_url.spec() + " failed to load"), | 223 ASSERT_EQ(UTF8ToUTF16(test_url.spec() + " failed to load"), |
| 221 tab_contents->GetTitle()); | 224 tab_contents->GetTitle()); |
| 222 | 225 |
| 223 EXPECT_TRUE(tab_contents->GetTabSpecificContentSettings()->IsContentBlocked( | 226 EXPECT_TRUE(tab_contents->GetTabSpecificContentSettings()->IsContentBlocked( |
| 224 CONTENT_SETTINGS_TYPE_COOKIES)); | 227 CONTENT_SETTINGS_TYPE_COOKIES)); |
| 225 } | 228 } |
| 229 |
| 230 class RenderViewHostTestTabContentsObserver : public TabContentsObserver { |
| 231 public: |
| 232 explicit RenderViewHostTestTabContentsObserver(TabContents* tab_contents) |
| 233 : TabContentsObserver(tab_contents), |
| 234 navigation_count_(0) {} |
| 235 virtual ~RenderViewHostTestTabContentsObserver() {} |
| 236 |
| 237 virtual void DidNavigateMainFramePostCommit( |
| 238 const NavigationController::LoadCommittedDetails& details, |
| 239 const ViewHostMsg_FrameNavigate_Params& params) { |
| 240 observed_socket_address_ = params.socket_address; |
| 241 ++navigation_count_; |
| 242 } |
| 243 |
| 244 const net::HostPortPair& observed_socket_address() const { |
| 245 return observed_socket_address_; |
| 246 } |
| 247 |
| 248 int navigation_count() const { return navigation_count_; } |
| 249 |
| 250 private: |
| 251 net::HostPortPair observed_socket_address_; |
| 252 int navigation_count_; |
| 253 |
| 254 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestTabContentsObserver); |
| 255 }; |
| 256 |
| 257 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, FrameNavigateSocketAddress) { |
| 258 ASSERT_TRUE(test_server()->Start()); |
| 259 RenderViewHostTestTabContentsObserver observer( |
| 260 browser()->GetSelectedTabContents()); |
| 261 |
| 262 GURL test_url = test_server()->GetURL("files/simple.html"); |
| 263 ui_test_utils::NavigateToURL(browser(), test_url); |
| 264 |
| 265 EXPECT_EQ(test_server()->host_port_pair().ToString(), |
| 266 observer.observed_socket_address().ToString()); |
| 267 EXPECT_EQ(1, observer.navigation_count()); |
| 268 } |
| OLD | NEW |