Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "content/browser/frame_host/frame_tree.h" | 7 #include "content/browser/frame_host/frame_tree.h" |
| 8 #include "content/browser/frame_host/navigation_controller_impl.h" | 8 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 // The MessageLoopRunner used to spin the message loop. | 275 // The MessageLoopRunner used to spin the message loop. |
| 276 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 276 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 277 }; | 277 }; |
| 278 | 278 |
| 279 } // namespace | 279 } // namespace |
| 280 | 280 |
| 281 // Verify that the distinction between manual and auto subframes is properly set | 281 // Verify that the distinction between manual and auto subframes is properly set |
| 282 // for subframe navigations. TODO(avi): It's rather bogus that the same info is | 282 // for subframe navigations. TODO(avi): It's rather bogus that the same info is |
| 283 // in two different enums; http://crbug.com/453555. | 283 // in two different enums; http://crbug.com/453555. |
| 284 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 284 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 285 ManualAndAutoSubframeNavigationClassification) { | 285 NavigationTypeClassification_NewAndAutoSubframe) { |
| 286 GURL main_url(embedded_test_server()->GetURL( | 286 GURL main_url(embedded_test_server()->GetURL( |
| 287 "/navigation_controller/page_with_iframe.html")); | 287 "/navigation_controller/page_with_iframe.html")); |
| 288 NavigateToURL(shell(), main_url); | 288 NavigateToURL(shell(), main_url); |
| 289 | 289 |
| 290 // It is safe to obtain the root frame tree node here, as it doesn't change. | 290 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 291 FrameTreeNode* root = | 291 FrameTreeNode* root = |
| 292 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 292 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 293 GetFrameTree()->root(); | 293 GetFrameTree()->root(); |
| 294 | 294 |
| 295 ASSERT_EQ(1U, root->child_count()); | 295 ASSERT_EQ(1U, root->child_count()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 GURL frame_url(embedded_test_server()->GetURL( | 358 GURL frame_url(embedded_test_server()->GetURL( |
| 359 "/navigation_controller/simple_page_2.html")); | 359 "/navigation_controller/simple_page_2.html")); |
| 360 std::string script = "location.replace('" + frame_url.spec() + "')"; | 360 std::string script = "location.replace('" + frame_url.spec() + "')"; |
| 361 EXPECT_TRUE(content::ExecuteScript(root->child_at(0)->current_frame_host(), | 361 EXPECT_TRUE(content::ExecuteScript(root->child_at(0)->current_frame_host(), |
| 362 script)); | 362 script)); |
| 363 capturer.Wait(); | 363 capturer.Wait(); |
| 364 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 364 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 365 } | 365 } |
| 366 | 366 |
| 367 { | 367 { |
| 368 // Use history.pushState(); expect a manual subframe transition. | |
| 369 FrameNavigateParamsCapturer capturer(root->child_at(0)); | |
| 370 std::string script = | |
| 371 "history.pushState({}, 'page 1', 'simple_page_1.html')"; | |
| 372 EXPECT_TRUE(content::ExecuteScript(root->child_at(0)->current_frame_host(), | |
| 373 script)); | |
| 374 capturer.Wait(); | |
| 375 EXPECT_EQ(ui::PAGE_TRANSITION_MANUAL_SUBFRAME, | |
| 376 capturer.params().transition); | |
| 377 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | |
| 378 } | |
| 379 | |
| 380 { | |
| 381 // Use history.replaceState(); expect an auto subframe transition. | |
| 382 // (Replacements aren't "navigation" so we only see the frame load | |
| 383 // committing.) | |
| 384 LoadCommittedCapturer capturer(root->child_at(0)); | |
| 385 std::string script = | |
| 386 "history.replaceState({}, 'page 2', 'simple_page_2.html')"; | |
| 387 EXPECT_TRUE(content::ExecuteScript(root->child_at(0)->current_frame_host(), | |
| 388 script)); | |
| 389 capturer.Wait(); | |
| 390 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | |
|
Charlie Reis
2015/03/06 22:06:30
Is there anything we can check here and in locatio
Avi (use Gerrit)
2015/03/06 22:19:02
I was kinda assuming things actually worked here,
| |
| 391 } | |
| 392 | |
| 393 { | |
| 368 // Reload the subframe; expect an auto subframe transition. (Reloads aren't | 394 // Reload the subframe; expect an auto subframe transition. (Reloads aren't |
| 369 // "navigation" so we only see the frame load committing.) | 395 // "navigation" so we only see the frame load committing.) |
| 370 LoadCommittedCapturer capturer(root->child_at(0)); | 396 LoadCommittedCapturer capturer(root->child_at(0)); |
| 371 EXPECT_TRUE(content::ExecuteScript(root->child_at(0)->current_frame_host(), | 397 EXPECT_TRUE(content::ExecuteScript(root->child_at(0)->current_frame_host(), |
| 372 "location.reload()")); | 398 "location.reload()")); |
| 373 capturer.Wait(); | 399 capturer.Wait(); |
| 374 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 400 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 375 } | 401 } |
| 376 | 402 |
| 377 { | 403 { |
| 378 // Create an iframe; expect an auto subframe transition. (Initial frame | 404 // Create an iframe; expect an auto subframe transition. (Initial frame |
| 379 // creation isn't "navigation" so we only see the frame load committing.) | 405 // creation isn't "navigation" so we only see the frame load committing.) |
| 380 LoadCommittedCapturer capturer(shell()->web_contents()); | 406 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 381 GURL frame_url(embedded_test_server()->GetURL( | 407 GURL frame_url(embedded_test_server()->GetURL( |
| 382 "/navigation_controller/simple_page_1.html")); | 408 "/navigation_controller/simple_page_1.html")); |
| 383 std::string script = "var iframe = document.createElement('iframe');" | 409 std::string script = "var iframe = document.createElement('iframe');" |
| 384 "iframe.src = '" + frame_url.spec() + "';" | 410 "iframe.src = '" + frame_url.spec() + "';" |
| 385 "document.body.appendChild(iframe);"; | 411 "document.body.appendChild(iframe);"; |
| 386 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); | 412 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); |
| 387 capturer.Wait(); | 413 capturer.Wait(); |
| 388 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); | 414 EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type()); |
| 389 } | 415 } |
| 390 } | 416 } |
| 391 | 417 |
| 392 } // namespace content | 418 } // namespace content |
| OLD | NEW |