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 "base/path_service.h" | 5 #include "base/path_service.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "content/browser/frame_host/render_frame_host_impl.h" | 9 #include "content/browser/frame_host/render_frame_host_impl.h" |
10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 private: | 56 private: |
57 net::HostPortPair observed_socket_address_; | 57 net::HostPortPair observed_socket_address_; |
58 GURL base_url_; | 58 GURL base_url_; |
59 int navigation_count_; | 59 int navigation_count_; |
60 | 60 |
61 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestWebContentsObserver); | 61 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestWebContentsObserver); |
62 }; | 62 }; |
63 | 63 |
64 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, FrameNavigateSocketAddress) { | 64 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, FrameNavigateSocketAddress) { |
65 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 65 ASSERT_TRUE(embedded_test_server()->Start()); |
66 RenderViewHostTestWebContentsObserver observer(shell()->web_contents()); | 66 RenderViewHostTestWebContentsObserver observer(shell()->web_contents()); |
67 | 67 |
68 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); | 68 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); |
69 NavigateToURL(shell(), test_url); | 69 NavigateToURL(shell(), test_url); |
70 | 70 |
71 EXPECT_EQ(net::HostPortPair::FromURL( | 71 EXPECT_EQ(net::HostPortPair::FromURL( |
72 embedded_test_server()->base_url()).ToString(), | 72 embedded_test_server()->base_url()).ToString(), |
73 observer.observed_socket_address().ToString()); | 73 observer.observed_socket_address().ToString()); |
74 EXPECT_EQ(1, observer.navigation_count()); | 74 EXPECT_EQ(1, observer.navigation_count()); |
75 } | 75 } |
76 | 76 |
77 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, BaseURLParam) { | 77 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, BaseURLParam) { |
78 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 78 ASSERT_TRUE(embedded_test_server()->Start()); |
79 RenderViewHostTestWebContentsObserver observer(shell()->web_contents()); | 79 RenderViewHostTestWebContentsObserver observer(shell()->web_contents()); |
80 | 80 |
81 // Base URL is not set if it is the same as the URL. | 81 // Base URL is not set if it is the same as the URL. |
82 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); | 82 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); |
83 NavigateToURL(shell(), test_url); | 83 NavigateToURL(shell(), test_url); |
84 EXPECT_TRUE(observer.base_url().is_empty()); | 84 EXPECT_TRUE(observer.base_url().is_empty()); |
85 EXPECT_EQ(1, observer.navigation_count()); | 85 EXPECT_EQ(1, observer.navigation_count()); |
86 | 86 |
87 // But should be set to the original page when reading MHTML. | 87 // But should be set to the original page when reading MHTML. |
88 base::FilePath content_test_data_dir; | 88 base::FilePath content_test_data_dir; |
89 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &content_test_data_dir)); | 89 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &content_test_data_dir)); |
90 test_url = net::FilePathToFileURL( | 90 test_url = net::FilePathToFileURL( |
91 content_test_data_dir.AppendASCII("google.mht")); | 91 content_test_data_dir.AppendASCII("google.mht")); |
92 NavigateToURL(shell(), test_url); | 92 NavigateToURL(shell(), test_url); |
93 EXPECT_EQ("http://www.google.com/", observer.base_url().spec()); | 93 EXPECT_EQ("http://www.google.com/", observer.base_url().spec()); |
94 } | 94 } |
95 | 95 |
96 // This test ensures a RenderFrameHost object is created for the top level frame | 96 // This test ensures a RenderFrameHost object is created for the top level frame |
97 // in each RenderViewHost. | 97 // in each RenderViewHost. |
98 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, BasicRenderFrameHost) { | 98 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, BasicRenderFrameHost) { |
99 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 99 ASSERT_TRUE(embedded_test_server()->Start()); |
100 | 100 |
101 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); | 101 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); |
102 NavigateToURL(shell(), test_url); | 102 NavigateToURL(shell(), test_url); |
103 | 103 |
104 FrameTreeNode* old_root = static_cast<WebContentsImpl*>( | 104 FrameTreeNode* old_root = static_cast<WebContentsImpl*>( |
105 shell()->web_contents())->GetFrameTree()->root(); | 105 shell()->web_contents())->GetFrameTree()->root(); |
106 EXPECT_TRUE(old_root->current_frame_host()); | 106 EXPECT_TRUE(old_root->current_frame_host()); |
107 | 107 |
108 ShellAddedObserver new_shell_observer; | 108 ShellAddedObserver new_shell_observer; |
109 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "window.open();")); | 109 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "window.open();")); |
110 Shell* new_shell = new_shell_observer.GetShell(); | 110 Shell* new_shell = new_shell_observer.GetShell(); |
111 FrameTreeNode* new_root = static_cast<WebContentsImpl*>( | 111 FrameTreeNode* new_root = static_cast<WebContentsImpl*>( |
112 new_shell->web_contents())->GetFrameTree()->root(); | 112 new_shell->web_contents())->GetFrameTree()->root(); |
113 | 113 |
114 EXPECT_TRUE(new_root->current_frame_host()); | 114 EXPECT_TRUE(new_root->current_frame_host()); |
115 EXPECT_NE(old_root->current_frame_host()->routing_id(), | 115 EXPECT_NE(old_root->current_frame_host()->routing_id(), |
116 new_root->current_frame_host()->routing_id()); | 116 new_root->current_frame_host()->routing_id()); |
117 } | 117 } |
118 | 118 |
119 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, IsFocusedElementEditable) { | 119 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, IsFocusedElementEditable) { |
120 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 120 ASSERT_TRUE(embedded_test_server()->Start()); |
121 | 121 |
122 GURL test_url = embedded_test_server()->GetURL("/touch_selection.html"); | 122 GURL test_url = embedded_test_server()->GetURL("/touch_selection.html"); |
123 NavigateToURL(shell(), test_url); | 123 NavigateToURL(shell(), test_url); |
124 | 124 |
125 RenderViewHost* rvh = shell()->web_contents()->GetRenderViewHost(); | 125 RenderViewHost* rvh = shell()->web_contents()->GetRenderViewHost(); |
126 EXPECT_FALSE(rvh->IsFocusedElementEditable()); | 126 EXPECT_FALSE(rvh->IsFocusedElementEditable()); |
127 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "focus_textfield();")); | 127 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "focus_textfield();")); |
128 EXPECT_TRUE(rvh->IsFocusedElementEditable()); | 128 EXPECT_TRUE(rvh->IsFocusedElementEditable()); |
129 } | 129 } |
130 | 130 |
131 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, ReleaseSessionOnCloseACK) { | 131 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, ReleaseSessionOnCloseACK) { |
132 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 132 ASSERT_TRUE(embedded_test_server()->Start()); |
133 GURL test_url = embedded_test_server()->GetURL( | 133 GURL test_url = embedded_test_server()->GetURL( |
134 "/access-session-storage.html"); | 134 "/access-session-storage.html"); |
135 NavigateToURL(shell(), test_url); | 135 NavigateToURL(shell(), test_url); |
136 | 136 |
137 // Make a new Shell, a seperate tab with it's own session namespace and | 137 // Make a new Shell, a seperate tab with it's own session namespace and |
138 // have it start loading a url but still be in progress. | 138 // have it start loading a url but still be in progress. |
139 ShellAddedObserver new_shell_observer; | 139 ShellAddedObserver new_shell_observer; |
140 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "window.open();")); | 140 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "window.open();")); |
141 Shell* new_shell = new_shell_observer.GetShell(); | 141 Shell* new_shell = new_shell_observer.GetShell(); |
142 new_shell->LoadURL(test_url); | 142 new_shell->LoadURL(test_url); |
(...skipping 11 matching lines...) Expand all Loading... |
154 | 154 |
155 // Do something that causes ipc queues to flush and tasks in | 155 // Do something that causes ipc queues to flush and tasks in |
156 // flight to complete such that we should have received the ACK. | 156 // flight to complete such that we should have received the ACK. |
157 NavigateToURL(shell(), test_url); | 157 NavigateToURL(shell(), test_url); |
158 | 158 |
159 // Verify we have the only remaining reference to the namespace. | 159 // Verify we have the only remaining reference to the namespace. |
160 EXPECT_TRUE(session_namespace->HasOneRef()); | 160 EXPECT_TRUE(session_namespace->HasOneRef()); |
161 } | 161 } |
162 | 162 |
163 } // namespace content | 163 } // namespace content |
OLD | NEW |