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

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: 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.
mmenke 2014/01/09 16:17:01 Now that we have the swap_observer, can't we just
mmenke 2014/01/09 16:20:27 Oh, is the issue that OpenURL() returns the wrong
davidben 2014/01/09 17:39:15 Yeah, it's really confusing. This isn't new from t
mmenke 2014/01/09 21:48:35 The watcher would always be able to get the right
davidben 2014/01/09 21:51:49 Added TODO.
3455 NavigateToDestURLWithDisposition(CURRENT_TAB, false);
3456
3457 // Verify DidDisplayPass manually since the previous call skipped it.
3458 EXPECT_TRUE(DidDisplayPass(
3459 current_browser()->tab_strip_model()->GetActiveWebContents()));
3460 }
3461
3462 // Verify that session storage conflicts don't merge.
3463 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSessionStorageConflict) {
3464 PrerenderTestURL("files/prerender/prerender_session_storage_conflict.html",
3465 FINAL_STATUS_APP_TERMINATING, 1);
3466
3467 // Open a new tab to navigate in.
3468 ui_test_utils::NavigateToURLWithDisposition(
3469 current_browser(),
3470 test_server()->GetURL("files/prerender/init_session_storage.html"),
3471 NEW_FOREGROUND_TAB,
3472 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
3473
3474 // Now navigate in the new tab.
3475 NavigateToDestURLWithDisposition(CURRENT_TAB, false);
3476
3477 // Verify DidDisplayPass in the new tab.
3478 EXPECT_TRUE(DidDisplayPass(
3479 current_browser()->tab_strip_model()->GetActiveWebContents()));
3457 } 3480 }
3458 3481
3459 // Checks that prerenders honor |should_replace_current_entry|. 3482 // Checks that prerenders honor |should_replace_current_entry|.
3460 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReplaceCurrentEntry) { 3483 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReplaceCurrentEntry) {
3461 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); 3484 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
3462 3485
3463 content::OpenURLParams params(dest_url(), Referrer(), CURRENT_TAB, 3486 content::OpenURLParams params(dest_url(), Referrer(), CURRENT_TAB,
3464 content::PAGE_TRANSITION_TYPED, false); 3487 content::PAGE_TRANSITION_TYPED, false);
3465 params.should_replace_current_entry = true; 3488 params.should_replace_current_entry = true;
3466 NavigateToURLWithParams(params, false); 3489 NavigateToURLWithParams(params, false);
3467 3490
3468 WebContents* web_contents = 3491 WebContents* web_contents =
3469 current_browser()->tab_strip_model()->GetActiveWebContents(); 3492 current_browser()->tab_strip_model()->GetActiveWebContents();
3470 const NavigationController& controller = web_contents->GetController(); 3493 const NavigationController& controller = web_contents->GetController();
3471 // First entry is about:blank, second is prerender_page.html. 3494 // First entry is about:blank, second is prerender_page.html.
3472 EXPECT_TRUE(controller.GetPendingEntry() == NULL); 3495 EXPECT_TRUE(controller.GetPendingEntry() == NULL);
3473 EXPECT_EQ(2, controller.GetEntryCount()); 3496 EXPECT_EQ(2, controller.GetEntryCount());
3474 EXPECT_EQ(GURL(content::kAboutBlankURL), 3497 EXPECT_EQ(GURL(content::kAboutBlankURL),
3475 controller.GetEntryAtIndex(0)->GetURL()); 3498 controller.GetEntryAtIndex(0)->GetURL());
3476 EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL()); 3499 EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL());
3477 } 3500 }
3478 3501
3479 } // namespace prerender 3502 } // 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