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

Side by Side Diff: chrome/browser/sessions/session_service_unittest.cc

Issue 10855022: Remove the effects of --disable-restore-session-state. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Test update. Created 8 years, 4 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 | « chrome/browser/sessions/base_session_service.cc ('k') | no next file » | 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 service()->SetWindowBounds(window_id, 762 service()->SetWindowBounds(window_id,
763 window_bounds, 763 window_bounds,
764 ui::SHOW_STATE_DEFAULT); 764 ui::SHOW_STATE_DEFAULT);
765 765
766 ScopedVector<SessionWindow> windows; 766 ScopedVector<SessionWindow> windows;
767 ReadWindows(&(windows.get())); 767 ReadWindows(&(windows.get()));
768 ASSERT_EQ(1U, windows.size()); 768 ASSERT_EQ(1U, windows.size());
769 EXPECT_EQ(ui::SHOW_STATE_NORMAL, windows[0]->show_state); 769 EXPECT_EQ(ui::SHOW_STATE_NORMAL, windows[0]->show_state);
770 } 770 }
771 771
772 TEST_F(SessionServiceTest, RemovePostData) { 772 TEST_F(SessionServiceTest, KeepPostDataWithoutPasswords) {
773 helper_.service()->save_post_data_ = false;
774
775 SessionID tab_id; 773 SessionID tab_id;
776 ASSERT_NE(window_id.id(), tab_id.id()); 774 ASSERT_NE(window_id.id(), tab_id.id());
777 775
778 std::string content_state("dummy_content_state");
779 // Create a TabNavigation containing content_state and representing a POST
780 // request.
781 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(),
782 ASCIIToUTF16("title"), content_state,
783 content::PAGE_TRANSITION_QUALIFIER_MASK);
784 nav1.set_type_mask(TabNavigation::HAS_POST_DATA);
785
786 // Create a TabNavigation containing content_state and representing a normal
787 // request.
788 TabNavigation nav2(0, GURL("http://google.com/nopost"), content::Referrer(),
789 ASCIIToUTF16("title"), content_state,
790 content::PAGE_TRANSITION_QUALIFIER_MASK);
791
792 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
793 UpdateNavigation(window_id, tab_id, nav1, 0, true);
794 UpdateNavigation(window_id, tab_id, nav2, 1, true);
795
796 ScopedVector<SessionWindow> windows;
797 ReadWindows(&(windows.get()));
798
799 helper_.AssertSingleWindowWithSingleTab(windows.get(), 2);
800
801 // Expected: the HTTP body was removed from the content state of the POST
802 // navigation but the content state of the normal navigation is intact.
803 EXPECT_NE(content_state, windows[0]->tabs[0]->navigations[0].state());
804 helper_.AssertNavigationEquals(nav2, windows[0]->tabs[0]->navigations[1]);
805 }
806
807 TEST_F(SessionServiceTest, KeepPostDataWithoutPasswords) {
808 helper_.service()->save_post_data_ = true;
809
810 SessionID tab_id;
811 ASSERT_NE(window_id.id(), tab_id.id());
812
813 // Create a content state representing a HTTP body without posted passwords. 776 // Create a content state representing a HTTP body without posted passwords.
814 WebKit::WebHTTPBody http_body; 777 WebKit::WebHTTPBody http_body;
815 http_body.initialize(); 778 http_body.initialize();
816 const char char_data[] = "data"; 779 const char char_data[] = "data";
817 http_body.appendData(WebKit::WebData(char_data, sizeof(char_data)-1)); 780 http_body.appendData(WebKit::WebData(char_data, sizeof(char_data)-1));
818 WebKit::WebHistoryItem history_item; 781 WebKit::WebHistoryItem history_item;
819 history_item.initialize(); 782 history_item.initialize();
820 history_item.setHTTPBody(http_body); 783 history_item.setHTTPBody(http_body);
821 std::string content_state = webkit_glue::HistoryItemToString(history_item); 784 std::string content_state = webkit_glue::HistoryItemToString(history_item);
822 785
(...skipping 18 matching lines...) Expand all
841 ReadWindows(&(windows.get())); 804 ReadWindows(&(windows.get()));
842 805
843 helper_.AssertSingleWindowWithSingleTab(windows.get(), 2); 806 helper_.AssertSingleWindowWithSingleTab(windows.get(), 2);
844 807
845 // Expected: the content state of both navigations was saved and restored. 808 // Expected: the content state of both navigations was saved and restored.
846 helper_.AssertNavigationEquals(nav1, windows[0]->tabs[0]->navigations[0]); 809 helper_.AssertNavigationEquals(nav1, windows[0]->tabs[0]->navigations[0]);
847 helper_.AssertNavigationEquals(nav2, windows[0]->tabs[0]->navigations[1]); 810 helper_.AssertNavigationEquals(nav2, windows[0]->tabs[0]->navigations[1]);
848 } 811 }
849 812
850 TEST_F(SessionServiceTest, RemovePostDataWithPasswords) { 813 TEST_F(SessionServiceTest, RemovePostDataWithPasswords) {
851 helper_.service()->save_post_data_ = true;
852
853 SessionID tab_id; 814 SessionID tab_id;
854 ASSERT_NE(window_id.id(), tab_id.id()); 815 ASSERT_NE(window_id.id(), tab_id.id());
855 816
856 // Create a content state representing a HTTP body with posted passwords. 817 // Create a content state representing a HTTP body with posted passwords.
857 WebKit::WebHTTPBody http_body; 818 WebKit::WebHTTPBody http_body;
858 http_body.initialize(); 819 http_body.initialize();
859 const char char_data[] = "data"; 820 const char char_data[] = "data";
860 http_body.appendData(WebKit::WebData(char_data, sizeof(char_data)-1)); 821 http_body.appendData(WebKit::WebData(char_data, sizeof(char_data)-1));
861 http_body.setContainsPasswordData(true); 822 http_body.setContainsPasswordData(true);
862 WebKit::WebHistoryItem history_item; 823 WebKit::WebHistoryItem history_item;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 ASSERT_TRUE(file_util::CopyFile(v1_file_path, dest_file_path)); 864 ASSERT_TRUE(file_util::CopyFile(v1_file_path, dest_file_path));
904 865
905 SessionService* session_service = new SessionService(path_); 866 SessionService* session_service = new SessionService(path_);
906 helper_.set_service(session_service); 867 helper_.set_service(session_service);
907 ScopedVector<SessionWindow> windows; 868 ScopedVector<SessionWindow> windows;
908 helper_.ReadWindows(&(windows.get())); 869 helper_.ReadWindows(&(windows.get()));
909 ASSERT_EQ(1u, windows.size()); 870 ASSERT_EQ(1u, windows.size());
910 EXPECT_EQ(1u, windows[0]->tabs.size()); 871 EXPECT_EQ(1u, windows[0]->tabs.size());
911 } 872 }
912 #endif 873 #endif
OLDNEW
« no previous file with comments | « chrome/browser/sessions/base_session_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698