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

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

Issue 12313067: Prevent bindings escalation on an existing NavigationEntry (attempt 3). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | content/browser/web_contents/navigation_controller_impl.cc » ('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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/defaults.h" 10 #include "chrome/browser/defaults.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/common/chrome_notification_types.h" 29 #include "chrome/common/chrome_notification_types.h"
30 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
31 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
32 #include "chrome/test/base/in_process_browser_test.h" 32 #include "chrome/test/base/in_process_browser_test.h"
33 #include "chrome/test/base/ui_test_utils.h" 33 #include "chrome/test/base/ui_test_utils.h"
34 #include "content/public/browser/navigation_controller.h" 34 #include "content/public/browser/navigation_controller.h"
35 #include "content/public/browser/navigation_entry.h" 35 #include "content/public/browser/navigation_entry.h"
36 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/notification_types.h" 37 #include "content/public/browser/notification_types.h"
38 #include "content/public/browser/render_process_host.h" 38 #include "content/public/browser/render_process_host.h"
39 #include "content/public/browser/render_view_host.h"
39 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
41 #include "content/public/common/bindings_policy.h"
40 #include "content/public/common/page_transition_types.h" 42 #include "content/public/common/page_transition_types.h"
41 #include "content/public/test/test_navigation_observer.h" 43 #include "content/public/test/test_navigation_observer.h"
42 #include "sync/protocol/session_specifics.pb.h" 44 #include "sync/protocol/session_specifics.pb.h"
43 45
44 #if defined(OS_MACOSX) 46 #if defined(OS_MACOSX)
45 #include "base/mac/scoped_nsautorelease_pool.h" 47 #include "base/mac/scoped_nsautorelease_pool.h"
46 #endif 48 #endif
47 49
48 class SessionRestoreTest : public InProcessBrowserTest { 50 class SessionRestoreTest : public InProcessBrowserTest {
49 public: 51 public:
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 579
578 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); 580 Browser* new_browser = QuitBrowserAndRestore(browser(), 1);
579 ASSERT_EQ(1u, native_browser_list->size()); 581 ASSERT_EQ(1u, native_browser_list->size());
580 ASSERT_EQ(url2_, 582 ASSERT_EQ(url2_,
581 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 583 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL());
582 GoBack(new_browser); 584 GoBack(new_browser);
583 ASSERT_EQ(url1_, 585 ASSERT_EQ(url1_,
584 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 586 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL());
585 } 587 }
586 588
589 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUI) {
590 const GURL webui_url("chrome://newtab");
591 ui_test_utils::NavigateToURL(browser(), webui_url);
592 const content::WebContents* old_tab =
593 browser()->tab_strip_model()->GetActiveWebContents();
594 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI,
595 old_tab->GetRenderViewHost()->GetEnabledBindings());
596
597 Browser* new_browser = QuitBrowserAndRestore(browser(), 1);
598 ASSERT_EQ(1u, native_browser_list->size());
599 const content::WebContents* new_tab =
600 new_browser->tab_strip_model()->GetActiveWebContents();
601 EXPECT_EQ(webui_url, new_tab->GetURL());
602 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI,
603 new_tab->GetRenderViewHost()->GetEnabledBindings());
604 }
605
587 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoresForwardAndBackwardNavs) { 606 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoresForwardAndBackwardNavs) {
588 ui_test_utils::NavigateToURL(browser(), url1_); 607 ui_test_utils::NavigateToURL(browser(), url1_);
589 ui_test_utils::NavigateToURL(browser(), url2_); 608 ui_test_utils::NavigateToURL(browser(), url2_);
590 ui_test_utils::NavigateToURL(browser(), url3_); 609 ui_test_utils::NavigateToURL(browser(), url3_);
591 610
592 GoBack(browser()); 611 GoBack(browser());
593 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); 612 Browser* new_browser = QuitBrowserAndRestore(browser(), 1);
594 ASSERT_EQ(1u, native_browser_list->size()); 613 ASSERT_EQ(1u, native_browser_list->size());
595 ASSERT_EQ(url2_, 614 ASSERT_EQ(url2_,
596 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 615 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL());
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 content::NavigationController* controller = 963 content::NavigationController* controller =
945 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); 964 &browser()->tab_strip_model()->GetActiveWebContents()->GetController();
946 EXPECT_TRUE( 965 EXPECT_TRUE(
947 controller->GetDefaultSessionStorageNamespace()->should_persist()); 966 controller->GetDefaultSessionStorageNamespace()->should_persist());
948 967
949 // Quit and restore. Check that no extra tabs were created. 968 // Quit and restore. Check that no extra tabs were created.
950 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); 969 Browser* new_browser = QuitBrowserAndRestore(browser(), 1);
951 ASSERT_EQ(1u, native_browser_list->size()); 970 ASSERT_EQ(1u, native_browser_list->size());
952 EXPECT_EQ(1, new_browser->tab_strip_model()->count()); 971 EXPECT_EQ(1, new_browser->tab_strip_model()->count());
953 } 972 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/web_contents/navigation_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698