OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/values.h" | 5 #include "base/values.h" |
6 #include "content/browser/renderer_host/render_view_host_impl.h" | |
7 #include "content/browser/web_contents/web_contents_impl.h" | 6 #include "content/browser/web_contents/web_contents_impl.h" |
8 #include "content/public/browser/load_notification_details.h" | 7 #include "content/public/browser/load_notification_details.h" |
9 #include "content/public/browser/navigation_controller.h" | 8 #include "content/public/browser/navigation_controller.h" |
10 #include "content/public/browser/notification_details.h" | 9 #include "content/public/browser/notification_details.h" |
11 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_types.h" | 11 #include "content/public/browser/notification_types.h" |
| 12 #include "content/public/browser/render_view_host.h" |
13 #include "content/public/browser/render_widget_host_view.h" | 13 #include "content/public/browser/render_widget_host_view.h" |
14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
15 #include "content/public/browser/web_contents_view.h" | 15 #include "content/public/browser/web_contents_view.h" |
16 #include "content/public/common/content_paths.h" | 16 #include "content/public/common/content_paths.h" |
17 #include "content/public/test/browser_test_utils.h" | 17 #include "content/public/test/browser_test_utils.h" |
18 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
19 #include "content/shell/browser/shell.h" | 19 #include "content/shell/browser/shell.h" |
20 #include "content/test/content_browser_test.h" | 20 #include "content/test/content_browser_test.h" |
21 #include "content/test/content_browser_test_utils.h" | 21 #include "content/test/content_browser_test_utils.h" |
22 #include "net/test/embedded_test_server/embedded_test_server.h" | 22 #include "net/test/embedded_test_server/embedded_test_server.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 222 |
223 LoadStopNotificationObserver load_observer2( | 223 LoadStopNotificationObserver load_observer2( |
224 &shell()->web_contents()->GetController()); | 224 &shell()->web_contents()->GetController()); |
225 ASSERT_TRUE(ExecuteScript(shell()->web_contents(), | 225 ASSERT_TRUE(ExecuteScript(shell()->web_contents(), |
226 "window.location.href=\"#foo\";")); | 226 "window.location.href=\"#foo\";")); |
227 load_observer2.Wait(); | 227 load_observer2.Wait(); |
228 EXPECT_EQ(embedded_test_server()->GetURL("/title1.html#foo"), | 228 EXPECT_EQ(embedded_test_server()->GetURL("/title1.html#foo"), |
229 shell()->web_contents()->GetVisibleURL()); | 229 shell()->web_contents()->GetVisibleURL()); |
230 } | 230 } |
231 | 231 |
232 // Test that the browser receives the proper frame attach/detach messages from | |
233 // the renderer and builds proper frame tree. | |
234 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, FrameTree) { | |
235 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
236 | |
237 NavigateToURL(shell(), | |
238 embedded_test_server()->GetURL("/frame_tree/top.html")); | |
239 | |
240 WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents()); | |
241 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | |
242 wc->GetRenderViewHost()); | |
243 FrameTreeNode* root = wc->GetFrameTreeRootForTesting(); | |
244 | |
245 // Check that the root node is properly created with the frame id of the | |
246 // initial navigation. | |
247 EXPECT_EQ(3UL, root->child_count()); | |
248 EXPECT_EQ(std::string(), root->frame_name()); | |
249 EXPECT_EQ(rvh->main_frame_id(), root->frame_id()); | |
250 | |
251 EXPECT_EQ(2UL, root->child_at(0)->child_count()); | |
252 EXPECT_STREQ("1-1-name", root->child_at(0)->frame_name().c_str()); | |
253 | |
254 // Verify the deepest node exists and has the right name. | |
255 EXPECT_EQ(2UL, root->child_at(2)->child_count()); | |
256 EXPECT_EQ(1UL, root->child_at(2)->child_at(1)->child_count()); | |
257 EXPECT_EQ(0UL, root->child_at(2)->child_at(1)->child_at(0)->child_count()); | |
258 EXPECT_STREQ("3-1-id", | |
259 root->child_at(2)->child_at(1)->child_at(0)->frame_name().c_str()); | |
260 | |
261 // Navigate to about:blank, which should leave only the root node of the frame | |
262 // tree in the browser process. | |
263 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); | |
264 | |
265 root = wc->GetFrameTreeRootForTesting(); | |
266 EXPECT_EQ(0UL, root->child_count()); | |
267 EXPECT_EQ(std::string(), root->frame_name()); | |
268 EXPECT_EQ(rvh->main_frame_id(), root->frame_id()); | |
269 } | |
270 | |
271 // TODO(sail): enable this for MAC when auto resizing of WebContentsViewCocoa is | 232 // TODO(sail): enable this for MAC when auto resizing of WebContentsViewCocoa is |
272 // fixed. | 233 // fixed. |
273 // TODO(shrikant): enable this for Windows when issue with | 234 // TODO(shrikant): enable this for Windows when issue with |
274 // force-compositing-mode is resolved (http://crbug.com/281726). | 235 // force-compositing-mode is resolved (http://crbug.com/281726). |
275 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_ANDROID) | 236 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_ANDROID) |
276 #define MAYBE_GetSizeForNewRenderView DISABLED_GetSizeForNewRenderView | 237 #define MAYBE_GetSizeForNewRenderView DISABLED_GetSizeForNewRenderView |
277 #else | 238 #else |
278 #define MAYBE_GetSizeForNewRenderView GetSizeForNewRenderView | 239 #define MAYBE_GetSizeForNewRenderView GetSizeForNewRenderView |
279 #endif | 240 #endif |
280 // Test that RenderViewHost is created and updated at the size specified by | 241 // Test that RenderViewHost is created and updated at the size specified by |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 // RenderViewSizeObserver resizes WebContentsView in NavigateToPendingEntry, | 290 // RenderViewSizeObserver resizes WebContentsView in NavigateToPendingEntry, |
330 // so both WebContentsView and RenderWidgetHostView adopt this new size. | 291 // so both WebContentsView and RenderWidgetHostView adopt this new size. |
331 new_size.Enlarge(size_insets.width(), size_insets.height()); | 292 new_size.Enlarge(size_insets.width(), size_insets.height()); |
332 EXPECT_EQ(new_size, | 293 EXPECT_EQ(new_size, |
333 shell()->web_contents()->GetRenderWidgetHostView()->GetViewBounds(). | 294 shell()->web_contents()->GetRenderWidgetHostView()->GetViewBounds(). |
334 size()); | 295 size()); |
335 EXPECT_EQ(new_size, shell()->web_contents()->GetView()->GetContainerSize()); | 296 EXPECT_EQ(new_size, shell()->web_contents()->GetView()->GetContainerSize()); |
336 } | 297 } |
337 | 298 |
338 } // namespace content | 299 } // namespace content |
OLD | NEW |