Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 129383002: Better test coverage for prerender sessionStorage merging. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add TODO Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/data/prerender/init_session_storage.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <deque> 5 #include <deque>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 PrerenderTestURLImpl(prerender_url, destination_url, 885 PrerenderTestURLImpl(prerender_url, destination_url,
886 expected_final_status_queue, 886 expected_final_status_queue,
887 expected_number_of_loads, 887 expected_number_of_loads,
888 false); 888 false);
889 } 889 }
890 890
891 void NavigateToDestURL() const { 891 void NavigateToDestURL() const {
892 NavigateToDestURLWithDisposition(CURRENT_TAB, true); 892 NavigateToDestURLWithDisposition(CURRENT_TAB, true);
893 } 893 }
894 894
895 void NavigateToDestURLInNewTab() const {
896 // First, open a new tab.
897 ui_test_utils::NavigateToURLWithDisposition(
898 current_browser(), GURL(content::kAboutBlankURL),
899 NEW_FOREGROUND_TAB,
900 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
901 // Next, navigate to the destination URL. The swap-in will not succeed,
902 // due to session storage namespace mismatch. The merge is only kicked off
903 // asynchronously.
904 NavigateToDestURLWithDisposition(CURRENT_TAB, false);
905 }
906
907 // Opens the url in a new tab, with no opener. 895 // Opens the url in a new tab, with no opener.
908 void NavigateToDestURLWithDisposition( 896 void NavigateToDestURLWithDisposition(
909 WindowOpenDisposition disposition, 897 WindowOpenDisposition disposition,
910 bool expect_swap_to_succeed) const { 898 bool expect_swap_to_succeed) const {
911 NavigateToURLWithParams( 899 NavigateToURLWithParams(
912 content::OpenURLParams(dest_url_, Referrer(), disposition, 900 content::OpenURLParams(dest_url_, Referrer(), disposition,
913 content::PAGE_TRANSITION_TYPED, false), 901 content::PAGE_TRANSITION_TYPED, false),
914 expect_swap_to_succeed); 902 expect_swap_to_succeed);
915 } 903 }
916 904
(...skipping 2528 matching lines...) Expand 10 before | Expand all | Expand 10 after
3445 // prerendered page tries to make a second navigation entry. 3433 // prerendered page tries to make a second navigation entry.
3446 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNewNavigationEntry) { 3434 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNewNavigationEntry) {
3447 PrerenderTestURL("files/prerender/prerender_new_entry.html", 3435 PrerenderTestURL("files/prerender/prerender_new_entry.html",
3448 FINAL_STATUS_NEW_NAVIGATION_ENTRY, 3436 FINAL_STATUS_NEW_NAVIGATION_ENTRY,
3449 1); 3437 1);
3450 } 3438 }
3451 3439
3452 // Attempt a swap-in in a new tab, verifying that session storage namespace 3440 // Attempt a swap-in in a new tab, verifying that session storage namespace
3453 // merging works. 3441 // merging works.
3454 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageNewTab) { 3442 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageNewTab) {
3455 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); 3443 PrerenderTestURL("files/prerender/prerender_session_storage.html",
3456 NavigateToDestURLInNewTab(); 3444 FINAL_STATUS_USED, 1);
3445
3446 // Open a new tab to navigate in.
3447 ui_test_utils::NavigateToURLWithDisposition(
3448 current_browser(),
3449 test_server()->GetURL("files/prerender/init_session_storage.html"),
3450 NEW_FOREGROUND_TAB,
3451 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
3452
3453 // Now navigate in the new tab. Set expect_swap_to_succeed to false because
3454 // the swap does not occur synchronously.
3455 //
3456 // TODO(davidben): When all swaps become asynchronous, remove the OpenURL
3457 // return value assertion and let this go through the usual successful-swap
3458 // codepath.
3459 NavigateToDestURLWithDisposition(CURRENT_TAB, false);
3460
3461 // Verify DidDisplayPass manually since the previous call skipped it.
3462 EXPECT_TRUE(DidDisplayPass(
3463 current_browser()->tab_strip_model()->GetActiveWebContents()));
3464 }
3465
3466 // Verify that session storage conflicts don't merge.
3467 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSessionStorageConflict) {
3468 PrerenderTestURL("files/prerender/prerender_session_storage_conflict.html",
3469 FINAL_STATUS_APP_TERMINATING, 1);
3470
3471 // Open a new tab to navigate in.
3472 ui_test_utils::NavigateToURLWithDisposition(
3473 current_browser(),
3474 test_server()->GetURL("files/prerender/init_session_storage.html"),
3475 NEW_FOREGROUND_TAB,
3476 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
3477
3478 // Now navigate in the new tab.
3479 NavigateToDestURLWithDisposition(CURRENT_TAB, false);
3480
3481 // Verify DidDisplayPass in the new tab.
3482 EXPECT_TRUE(DidDisplayPass(
3483 current_browser()->tab_strip_model()->GetActiveWebContents()));
3457 } 3484 }
3458 3485
3459 // Checks that prerenders honor |should_replace_current_entry|. 3486 // Checks that prerenders honor |should_replace_current_entry|.
3460 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReplaceCurrentEntry) { 3487 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReplaceCurrentEntry) {
3461 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); 3488 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
3462 3489
3463 content::OpenURLParams params(dest_url(), Referrer(), CURRENT_TAB, 3490 content::OpenURLParams params(dest_url(), Referrer(), CURRENT_TAB,
3464 content::PAGE_TRANSITION_TYPED, false); 3491 content::PAGE_TRANSITION_TYPED, false);
3465 params.should_replace_current_entry = true; 3492 params.should_replace_current_entry = true;
3466 NavigateToURLWithParams(params, false); 3493 NavigateToURLWithParams(params, false);
3467 3494
3468 WebContents* web_contents = 3495 WebContents* web_contents =
3469 current_browser()->tab_strip_model()->GetActiveWebContents(); 3496 current_browser()->tab_strip_model()->GetActiveWebContents();
3470 const NavigationController& controller = web_contents->GetController(); 3497 const NavigationController& controller = web_contents->GetController();
3471 // First entry is about:blank, second is prerender_page.html. 3498 // First entry is about:blank, second is prerender_page.html.
3472 EXPECT_TRUE(controller.GetPendingEntry() == NULL); 3499 EXPECT_TRUE(controller.GetPendingEntry() == NULL);
3473 EXPECT_EQ(2, controller.GetEntryCount()); 3500 EXPECT_EQ(2, controller.GetEntryCount());
3474 EXPECT_EQ(GURL(content::kAboutBlankURL), 3501 EXPECT_EQ(GURL(content::kAboutBlankURL),
3475 controller.GetEntryAtIndex(0)->GetURL()); 3502 controller.GetEntryAtIndex(0)->GetURL());
3476 EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL()); 3503 EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL());
3477 } 3504 }
3478 3505
3479 } // namespace prerender 3506 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/prerender/init_session_storage.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698