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/macros.h" | 5 #include "base/macros.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 ASSERT_TRUE(embedded_test_server()->Start()); | 101 ASSERT_TRUE(embedded_test_server()->Start()); |
102 | 102 |
103 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); | 103 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); |
104 NavigateToURL(shell(), test_url); | 104 NavigateToURL(shell(), test_url); |
105 | 105 |
106 FrameTreeNode* old_root = static_cast<WebContentsImpl*>( | 106 FrameTreeNode* old_root = static_cast<WebContentsImpl*>( |
107 shell()->web_contents())->GetFrameTree()->root(); | 107 shell()->web_contents())->GetFrameTree()->root(); |
108 EXPECT_TRUE(old_root->current_frame_host()); | 108 EXPECT_TRUE(old_root->current_frame_host()); |
109 | 109 |
110 ShellAddedObserver new_shell_observer; | 110 ShellAddedObserver new_shell_observer; |
111 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "window.open();")); | 111 EXPECT_TRUE(ExecuteScript(shell(), "window.open();")); |
112 Shell* new_shell = new_shell_observer.GetShell(); | 112 Shell* new_shell = new_shell_observer.GetShell(); |
113 FrameTreeNode* new_root = static_cast<WebContentsImpl*>( | 113 FrameTreeNode* new_root = static_cast<WebContentsImpl*>( |
114 new_shell->web_contents())->GetFrameTree()->root(); | 114 new_shell->web_contents())->GetFrameTree()->root(); |
115 | 115 |
116 EXPECT_TRUE(new_root->current_frame_host()); | 116 EXPECT_TRUE(new_root->current_frame_host()); |
117 EXPECT_NE(old_root->current_frame_host()->routing_id(), | 117 EXPECT_NE(old_root->current_frame_host()->routing_id(), |
118 new_root->current_frame_host()->routing_id()); | 118 new_root->current_frame_host()->routing_id()); |
119 } | 119 } |
120 | 120 |
121 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, IsFocusedElementEditable) { | 121 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, IsFocusedElementEditable) { |
122 ASSERT_TRUE(embedded_test_server()->Start()); | 122 ASSERT_TRUE(embedded_test_server()->Start()); |
123 | 123 |
124 GURL test_url = embedded_test_server()->GetURL("/touch_selection.html"); | 124 GURL test_url = embedded_test_server()->GetURL("/touch_selection.html"); |
125 NavigateToURL(shell(), test_url); | 125 NavigateToURL(shell(), test_url); |
126 | 126 |
127 RenderViewHost* rvh = shell()->web_contents()->GetRenderViewHost(); | 127 RenderViewHost* rvh = shell()->web_contents()->GetRenderViewHost(); |
128 EXPECT_FALSE(rvh->IsFocusedElementEditable()); | 128 EXPECT_FALSE(rvh->IsFocusedElementEditable()); |
129 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "focus_textfield();")); | 129 EXPECT_TRUE(ExecuteScript(shell(), "focus_textfield();")); |
130 EXPECT_TRUE(rvh->IsFocusedElementEditable()); | 130 EXPECT_TRUE(rvh->IsFocusedElementEditable()); |
131 } | 131 } |
132 | 132 |
133 // Flaky on Linux (https://crbug.com/559192). | 133 // Flaky on Linux (https://crbug.com/559192). |
134 #if defined(OS_LINUX) | 134 #if defined(OS_LINUX) |
135 #define MAYBE_ReleaseSessionOnCloseACK DISABLED_ReleaseSessionOnCloseACK | 135 #define MAYBE_ReleaseSessionOnCloseACK DISABLED_ReleaseSessionOnCloseACK |
136 #else | 136 #else |
137 #define MAYBE_ReleaseSessionOnCloseACK ReleaseSessionOnCloseACK | 137 #define MAYBE_ReleaseSessionOnCloseACK ReleaseSessionOnCloseACK |
138 #endif | 138 #endif |
139 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, MAYBE_ReleaseSessionOnCloseACK) { | 139 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, MAYBE_ReleaseSessionOnCloseACK) { |
140 ASSERT_TRUE(embedded_test_server()->Start()); | 140 ASSERT_TRUE(embedded_test_server()->Start()); |
141 GURL test_url = embedded_test_server()->GetURL( | 141 GURL test_url = embedded_test_server()->GetURL( |
142 "/access-session-storage.html"); | 142 "/access-session-storage.html"); |
143 NavigateToURL(shell(), test_url); | 143 NavigateToURL(shell(), test_url); |
144 | 144 |
145 // Make a new Shell, a seperate tab with it's own session namespace and | 145 // Make a new Shell, a seperate tab with it's own session namespace and |
146 // have it start loading a url but still be in progress. | 146 // have it start loading a url but still be in progress. |
147 ShellAddedObserver new_shell_observer; | 147 ShellAddedObserver new_shell_observer; |
148 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "window.open();")); | 148 EXPECT_TRUE(ExecuteScript(shell(), "window.open();")); |
149 Shell* new_shell = new_shell_observer.GetShell(); | 149 Shell* new_shell = new_shell_observer.GetShell(); |
150 new_shell->LoadURL(test_url); | 150 new_shell->LoadURL(test_url); |
151 RenderViewHost* rvh = new_shell->web_contents()->GetRenderViewHost(); | 151 RenderViewHost* rvh = new_shell->web_contents()->GetRenderViewHost(); |
152 SiteInstance* site_instance = rvh->GetSiteInstance(); | 152 SiteInstance* site_instance = rvh->GetSiteInstance(); |
153 scoped_refptr<SessionStorageNamespace> session_namespace = | 153 scoped_refptr<SessionStorageNamespace> session_namespace = |
154 rvh->GetDelegate()->GetSessionStorageNamespace(site_instance); | 154 rvh->GetDelegate()->GetSessionStorageNamespace(site_instance); |
155 EXPECT_FALSE(session_namespace->HasOneRef()); | 155 EXPECT_FALSE(session_namespace->HasOneRef()); |
156 | 156 |
157 // Close it, or rather start the close operation. The session namespace | 157 // Close it, or rather start the close operation. The session namespace |
158 // should remain until RPH gets an ACK from the renderer about having | 158 // should remain until RPH gets an ACK from the renderer about having |
159 // closed the view. | 159 // closed the view. |
160 new_shell->Close(); | 160 new_shell->Close(); |
161 EXPECT_FALSE(session_namespace->HasOneRef()); | 161 EXPECT_FALSE(session_namespace->HasOneRef()); |
162 | 162 |
163 // Do something that causes ipc queues to flush and tasks in | 163 // Do something that causes ipc queues to flush and tasks in |
164 // flight to complete such that we should have received the ACK. | 164 // flight to complete such that we should have received the ACK. |
165 NavigateToURL(shell(), test_url); | 165 NavigateToURL(shell(), test_url); |
166 | 166 |
167 // Verify we have the only remaining reference to the namespace. | 167 // Verify we have the only remaining reference to the namespace. |
168 EXPECT_TRUE(session_namespace->HasOneRef()); | 168 EXPECT_TRUE(session_namespace->HasOneRef()); |
169 } | 169 } |
170 | 170 |
171 } // namespace content | 171 } // namespace content |
OLD | NEW |