| OLD | NEW |
| 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 #include "content/public/browser/interstitial_page.h" | 64 #include "content/public/browser/interstitial_page.h" |
| 65 #include "content/public/browser/navigation_controller.h" | 65 #include "content/public/browser/navigation_controller.h" |
| 66 #include "content/public/browser/navigation_entry.h" | 66 #include "content/public/browser/navigation_entry.h" |
| 67 #include "content/public/browser/notification_service.h" | 67 #include "content/public/browser/notification_service.h" |
| 68 #include "content/public/browser/render_frame_host.h" | 68 #include "content/public/browser/render_frame_host.h" |
| 69 #include "content/public/browser/render_view_host.h" | 69 #include "content/public/browser/render_view_host.h" |
| 70 #include "content/public/browser/render_widget_host_view.h" | 70 #include "content/public/browser/render_widget_host_view.h" |
| 71 #include "content/public/browser/web_contents.h" | 71 #include "content/public/browser/web_contents.h" |
| 72 #include "content/public/browser/web_contents_observer.h" | 72 #include "content/public/browser/web_contents_observer.h" |
| 73 #include "content/public/common/content_switches.h" | 73 #include "content/public/common/content_switches.h" |
| 74 #include "content/public/common/page_state.h" |
| 74 #include "content/public/common/security_style.h" | 75 #include "content/public/common/security_style.h" |
| 75 #include "content/public/common/ssl_status.h" | 76 #include "content/public/common/ssl_status.h" |
| 76 #include "content/public/test/browser_test_utils.h" | 77 #include "content/public/test/browser_test_utils.h" |
| 77 #include "content/public/test/download_test_observer.h" | 78 #include "content/public/test/download_test_observer.h" |
| 78 #include "content/public/test/test_navigation_observer.h" | 79 #include "content/public/test/test_navigation_observer.h" |
| 79 #include "content/public/test/test_renderer_host.h" | 80 #include "content/public/test/test_renderer_host.h" |
| 80 #include "content/public/test/test_utils.h" | 81 #include "content/public/test/test_utils.h" |
| 81 #include "net/base/host_port_pair.h" | 82 #include "net/base/host_port_pair.h" |
| 82 #include "net/base/net_errors.h" | 83 #include "net/base/net_errors.h" |
| 83 #include "net/cert/cert_status_flags.h" | 84 #include "net/cert/cert_status_flags.h" |
| (...skipping 3034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3118 | 3119 |
| 3119 ui_test_utils::NavigateToURL(browser(), | 3120 ui_test_utils::NavigateToURL(browser(), |
| 3120 https_server.GetURL("/ssl/google.html")); | 3121 https_server.GetURL("/ssl/google.html")); |
| 3121 | 3122 |
| 3122 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(), | 3123 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(), |
| 3123 net::CERT_STATUS_NAME_CONSTRAINT_VIOLATION, | 3124 net::CERT_STATUS_NAME_CONSTRAINT_VIOLATION, |
| 3124 content::SECURITY_STYLE_AUTHENTICATION_BROKEN, | 3125 content::SECURITY_STYLE_AUTHENTICATION_BROKEN, |
| 3125 AuthState::SHOWING_INTERSTITIAL); | 3126 AuthState::SHOWING_INTERSTITIAL); |
| 3126 } | 3127 } |
| 3127 | 3128 |
| 3129 IN_PROC_BROWSER_TEST_F(SSLUITest, RestoreHasSSLState) { |
| 3130 ASSERT_TRUE(https_server_.Start()); |
| 3131 GURL url(https_server_.GetURL("/ssl/google.html")); |
| 3132 ui_test_utils::NavigateToURL(browser(), url); |
| 3133 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 3134 CheckAuthenticatedState(tab, AuthState::NONE); |
| 3135 |
| 3136 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); |
| 3137 std::unique_ptr<NavigationEntry> restored_entry = |
| 3138 content::NavigationController::CreateNavigationEntry( |
| 3139 url, content::Referrer(), ui::PAGE_TRANSITION_RELOAD, false, |
| 3140 std::string(), tab->GetBrowserContext()); |
| 3141 restored_entry->SetPageID(0); |
| 3142 restored_entry->SetPageState(entry->GetPageState()); |
| 3143 |
| 3144 WebContents::CreateParams params(tab->GetBrowserContext()); |
| 3145 WebContents* tab2 = WebContents::Create(params); |
| 3146 tab->GetDelegate()->AddNewContents( |
| 3147 nullptr, tab2, WindowOpenDisposition::NEW_FOREGROUND_TAB, gfx::Rect(), |
| 3148 false, nullptr); |
| 3149 std::vector<std::unique_ptr<NavigationEntry>> entries; |
| 3150 entries.push_back(std::move(restored_entry)); |
| 3151 content::TestNavigationObserver observer(tab2); |
| 3152 tab2->GetController().Restore( |
| 3153 entries.size() - 1, |
| 3154 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); |
| 3155 tab2->GetController().LoadIfNecessary(); |
| 3156 observer.Wait(); |
| 3157 CheckAuthenticatedState(tab2, AuthState::NONE); |
| 3158 } |
| 3159 |
| 3160 // Simulate the URL changing when the user presses enter in the omnibox. This |
| 3161 // could happen when the user's login is expired and the server redirects them |
| 3162 // to a login page. This will be considered a SAME_PAGE navigation but we do |
| 3163 // want to update the SSL state. |
| 3164 IN_PROC_BROWSER_TEST_F(SSLUITest, SamePageHasSSLState) { |
| 3165 ASSERT_TRUE(embedded_test_server()->Start()); |
| 3166 ASSERT_TRUE(https_server_.Start()); |
| 3167 |
| 3168 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 3169 |
| 3170 // Navigate to a simple page and then perform an in-page navigation. |
| 3171 GURL start_url(embedded_test_server()->GetURL("/title1.html")); |
| 3172 ui_test_utils::NavigateToURL(browser(), start_url); |
| 3173 |
| 3174 GURL same_page_url(embedded_test_server()->GetURL("/title1.html#foo")); |
| 3175 ui_test_utils::NavigateToURL(browser(), same_page_url); |
| 3176 CheckUnauthenticatedState(tab, AuthState::NONE); |
| 3177 |
| 3178 // Replace the URL of the current NavigationEntry with one that will cause |
| 3179 // a server redirect when loaded. |
| 3180 { |
| 3181 GURL redirect_dest_url(https_server_.GetURL("/ssl/google.html")); |
| 3182 content::TestNavigationObserver observer(tab); |
| 3183 std::string script = "history.replaceState({}, '', '/server-redirect?" + |
| 3184 redirect_dest_url.spec() + "')"; |
| 3185 EXPECT_TRUE(ExecuteScript(tab, script)); |
| 3186 observer.Wait(); |
| 3187 } |
| 3188 |
| 3189 // Simulate the user hitting Enter in the omnibox without changing the URL. |
| 3190 { |
| 3191 content::TestNavigationObserver observer(tab); |
| 3192 tab->GetController().LoadURL(tab->GetLastCommittedURL(), |
| 3193 content::Referrer(), ui::PAGE_TRANSITION_LINK, |
| 3194 std::string()); |
| 3195 observer.Wait(); |
| 3196 } |
| 3197 |
| 3198 CheckAuthenticatedState(tab, AuthState::NONE); |
| 3199 } |
| 3200 |
| 3128 // TODO(jcampan): more tests to do below. | 3201 // TODO(jcampan): more tests to do below. |
| 3129 | 3202 |
| 3130 // Visit a page over https that contains a frame with a redirect. | 3203 // Visit a page over https that contains a frame with a redirect. |
| 3131 | 3204 |
| 3132 // XMLHttpRequest insecure content in synchronous mode. | 3205 // XMLHttpRequest insecure content in synchronous mode. |
| 3133 | 3206 |
| 3134 // XMLHttpRequest insecure content in asynchronous mode. | 3207 // XMLHttpRequest insecure content in asynchronous mode. |
| 3135 | 3208 |
| 3136 // XMLHttpRequest over bad ssl in synchronous mode. | 3209 // XMLHttpRequest over bad ssl in synchronous mode. |
| 3137 | 3210 |
| 3138 // XMLHttpRequest over OK ssl in synchronous mode. | 3211 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |