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

Unified Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ssl/ssl_browser_tests.cc
===================================================================
--- chrome/browser/ssl/ssl_browser_tests.cc (revision 116109)
+++ chrome/browser/ssl/ssl_browser_tests.cc (working copy)
@@ -16,16 +16,18 @@
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/interstitial_page.h"
-#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/tab_contents/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/ssl_status.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/common/security_style.h"
#include "net/base/cert_status_flags.h"
#include "net/test/test_server.h"
using content::NavigationEntry;
using content::SSLStatus;
+using content::WebContents;
const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data");
@@ -49,7 +51,7 @@
command_line->AppendSwitch(switches::kAllowRunningInsecureContent);
}
- void CheckAuthenticatedState(TabContents* tab,
+ void CheckAuthenticatedState(WebContents* tab,
bool displayed_insecure_content) {
ASSERT_FALSE(tab->IsCrashed());
NavigationEntry* entry = tab->GetController().GetActiveEntry();
@@ -65,7 +67,7 @@
!!(entry->GetSSL().content_status & SSLStatus::RAN_INSECURE_CONTENT));
}
- void CheckUnauthenticatedState(TabContents* tab) {
+ void CheckUnauthenticatedState(WebContents* tab) {
ASSERT_FALSE(tab->IsCrashed());
NavigationEntry* entry = tab->GetController().GetActiveEntry();
ASSERT_TRUE(entry);
@@ -79,7 +81,7 @@
!!(entry->GetSSL().content_status & SSLStatus::RAN_INSECURE_CONTENT));
}
- void CheckAuthenticationBrokenState(TabContents* tab,
+ void CheckAuthenticationBrokenState(WebContents* tab,
net::CertStatus error,
bool ran_insecure_content,
bool interstitial) {
@@ -102,7 +104,7 @@
!!(entry->GetSSL().content_status & SSLStatus::RAN_INSECURE_CONTENT));
}
- void CheckWorkerLoadResult(TabContents* tab, bool expectLoaded) {
+ void CheckWorkerLoadResult(WebContents* tab, bool expectLoaded) {
// Workers are async and we don't have notifications for them passing
// messages since they do it between renderer and worker processes.
// So have a polling loop, check every 200ms, timeout at 30s.
@@ -134,7 +136,7 @@
EXPECT_EQ(expectLoaded, actuallyLoadedContent);
}
- void ProceedThroughInterstitial(TabContents* tab) {
+ void ProceedThroughInterstitial(content::WebContents* tab) {
InterstitialPage* interstitial_page = tab->GetInterstitialPage();
ASSERT_TRUE(interstitial_page);
ui_test_utils::WindowedNotificationObserver observer(
@@ -251,7 +253,7 @@
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL("files/ssl/google.html"));
- CheckUnauthenticatedState(browser()->GetSelectedTabContents());
+ CheckUnauthenticatedState(browser()->GetSelectedWebContents());
}
// Visits a page over http which includes broken https resources (status should
@@ -271,7 +273,7 @@
ui_test_utils::NavigateToURL(
browser(), test_server()->GetURL(replacement_path));
- CheckUnauthenticatedState(browser()->GetSelectedTabContents());
+ CheckUnauthenticatedState(browser()->GetSelectedWebContents());
}
// http://crbug.com/91745
@@ -288,7 +290,7 @@
ui_test_utils::NavigateToURL(browser(),
https_server_.GetURL("files/ssl/google.html"));
- CheckAuthenticatedState(browser()->GetSelectedTabContents(), false);
+ CheckAuthenticatedState(browser()->GetSelectedWebContents(), false);
}
// Visits a page with https error and proceed:
@@ -298,7 +300,7 @@
ui_test_utils::NavigateToURL(browser(),
https_server_expired_.GetURL("files/ssl/google.html"));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
true); // Interstitial showing
@@ -328,7 +330,7 @@
ui_test_utils::NavigateToURL(browser(),
https_server_.GetURL("files/ssl/google.html"));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
NavigationEntry* entry = tab->GetController().GetActiveEntry();
ASSERT_TRUE(entry);
@@ -373,7 +375,7 @@
// First navigate to an HTTP page.
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL("files/ssl/google.html"));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
NavigationEntry* entry = tab->GetController().GetActiveEntry();
ASSERT_TRUE(entry);
@@ -396,7 +398,7 @@
EXPECT_FALSE(tab->GetRenderViewHost()->is_swapped_out());
// We should be back at the original good page.
- EXPECT_FALSE(browser()->GetSelectedTabContents()->GetInterstitialPage());
+ EXPECT_FALSE(browser()->GetSelectedWebContents()->GetInterstitialPage());
CheckUnauthenticatedState(tab);
}
@@ -409,7 +411,7 @@
// First navigate to an HTTP page.
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL("files/ssl/google.html"));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
NavigationEntry* entry = tab->GetController().GetActiveEntry();
ASSERT_TRUE(entry);
@@ -423,7 +425,7 @@
tab->GetController().GoToOffset(-1);
// We should be back at the original good page.
- EXPECT_FALSE(browser()->GetSelectedTabContents()->GetInterstitialPage());
+ EXPECT_FALSE(browser()->GetSelectedWebContents()->GetInterstitialPage());
CheckUnauthenticatedState(tab);
}
@@ -436,7 +438,7 @@
// First navigate to two HTTP pages.
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL("files/ssl/google.html"));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
NavigationEntry* entry1 = tab->GetController().GetActiveEntry();
ASSERT_TRUE(entry1);
ui_test_utils::NavigateToURL(browser(),
@@ -472,7 +474,7 @@
}
// We should be showing the second good page.
- EXPECT_FALSE(browser()->GetSelectedTabContents()->GetInterstitialPage());
+ EXPECT_FALSE(browser()->GetSelectedWebContents()->GetInterstitialPage());
CheckUnauthenticatedState(tab);
EXPECT_FALSE(tab->GetController().CanGoForward());
NavigationEntry* entry4 = tab->GetController().GetActiveEntry();
@@ -497,13 +499,13 @@
GURL url = https_server_expired_.GetURL("files/ssl/google.htm");
TabContentsWrapper* tab2 =
browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED);
- ui_test_utils::WaitForLoadStop(tab2->tab_contents());
+ ui_test_utils::WaitForLoadStop(tab2->web_contents());
// Verify our assumption that there was no prior navigation.
EXPECT_FALSE(browser()->command_updater()->IsCommandEnabled(IDC_BACK));
// We should have an interstitial page showing.
- ASSERT_TRUE(tab2->tab_contents()->GetInterstitialPage());
+ ASSERT_TRUE(tab2->web_contents()->GetInterstitialPage());
}
// Disabled due to crash in downloads code that this triggers.
@@ -531,7 +533,7 @@
// Proceed through the SSL interstitial. This doesn't use
// |ProceedThroughInterstitial| since no page load will commit.
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
ASSERT_TRUE(tab != NULL);
ASSERT_TRUE(tab->GetInterstitialPage() != NULL);
{
@@ -570,7 +572,7 @@
ui_test_utils::NavigateToURL(browser(),
https_server_.GetURL(replacement_path));
- CheckAuthenticatedState(browser()->GetSelectedTabContents(), true);
+ CheckAuthenticatedState(browser()->GetSelectedWebContents(), true);
}
// Visits a page that runs insecure content and tries to suppress the insecure
@@ -584,7 +586,7 @@
ui_test_utils::NavigateToURL(browser(), https_server_.GetURL(
"files/ssl/page_runs_insecure_content.html"));
- CheckAuthenticationBrokenState(browser()->GetSelectedTabContents(), 0, true,
+ CheckAuthenticationBrokenState(browser()->GetSelectedWebContents(), 0, true,
false);
}
@@ -604,7 +606,7 @@
ui_test_utils::NavigateToURL(browser(),
https_server_.GetURL(replacement_path));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
// When the bad content is filtered, the state is expected to be
// authenticated.
CheckAuthenticatedState(tab, false);
@@ -646,7 +648,7 @@
ui_test_utils::NavigateToURL(browser(), https_server_.GetURL(
replacement_path));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
CheckAuthenticatedState(tab, false);
// Load the insecure image.
@@ -673,7 +675,7 @@
TabContentsWrapper* tab1 = browser()->GetSelectedTabContentsWrapper();
// This tab should be fine.
- CheckAuthenticatedState(tab1->tab_contents(), false);
+ CheckAuthenticatedState(tab1->web_contents(), false);
// Create a new tab.
std::string replacement_path;
@@ -696,10 +698,10 @@
observer.Wait();
// The new tab has insecure content.
- CheckAuthenticatedState(tab2->tab_contents(), true);
+ CheckAuthenticatedState(tab2->web_contents(), true);
// The original tab should not be contaminated.
- CheckAuthenticatedState(tab1->tab_contents(), false);
+ CheckAuthenticatedState(tab1->web_contents(), false);
}
// Visits two pages from the same origin: one that runs insecure content and one
@@ -715,7 +717,7 @@
TabContentsWrapper* tab1 = browser()->GetSelectedTabContentsWrapper();
// This tab should be fine.
- CheckAuthenticatedState(tab1->tab_contents(), false);
+ CheckAuthenticatedState(tab1->web_contents(), false);
std::string replacement_path;
ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
@@ -737,11 +739,11 @@
observer.Wait();
// The new tab has insecure content.
- CheckAuthenticationBrokenState(tab2->tab_contents(), 0, true, false);
+ CheckAuthenticationBrokenState(tab2->web_contents(), 0, true, false);
// Which means the origin for the first tab has also been contaminated with
// insecure content.
- CheckAuthenticationBrokenState(tab1->tab_contents(), 0, true, false);
+ CheckAuthenticationBrokenState(tab1->web_contents(), 0, true, false);
}
// Visits a page with an image over http. Visits another page over https
@@ -760,7 +762,7 @@
// Load original page over HTTP.
const GURL url_http = test_server()->GetURL(replacement_path);
ui_test_utils::NavigateToURL(browser(), url_http);
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
CheckUnauthenticatedState(tab);
// Load again but over SSL. It should be marked as displaying insecure
@@ -794,7 +796,7 @@
// Load original page over HTTP.
const GURL url_http = test_server()->GetURL(replacement_path);
ui_test_utils::NavigateToURL(browser(), url_http);
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
CheckUnauthenticatedState(tab);
// Load again but over SSL. It should be marked as displaying insecure
@@ -816,7 +818,7 @@
https_server_mismatched_.GetURL("files/ssl/google.html"));
// We get an interstitial page as a result.
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
false, true); // Interstitial showing.
ProceedThroughInterstitial(tab);
@@ -854,7 +856,7 @@
ui_test_utils::NavigateToURL(browser(),
https_server_expired_.GetURL("files/ssl/page_with_refs.html"));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
true); // Interstitial showing.
@@ -889,7 +891,7 @@
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(replacement_path));
- TabContents* tab1 = browser()->GetSelectedTabContents();
+ WebContents* tab1 = browser()->GetSelectedWebContents();
// It is probably overkill to add a notification for a popup-opening, let's
// just poll.
for (int i = 0; i < 10; i++) {
@@ -924,7 +926,7 @@
ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec()));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
true); // Interstitial showing.
@@ -945,7 +947,7 @@
GURL url2 = https_server_expired_.GetURL("files/ssl/google.html");
ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec()));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
true); // Interstitial showing.
@@ -960,7 +962,7 @@
ASSERT_TRUE(test_server()->Start());
ASSERT_TRUE(https_server_.Start());
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
// HTTP redirects to good HTTPS.
GURL http_url = test_server()->GetURL("server-redirect?");
@@ -977,7 +979,7 @@
ASSERT_TRUE(test_server()->Start());
ASSERT_TRUE(https_server_expired_.Start());
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
GURL http_url = test_server()->GetURL("server-redirect?");
GURL bad_https_url =
@@ -1005,18 +1007,18 @@
ui_test_utils::NavigateToURL(browser(),
GURL(https_url.spec() + http_url.spec()));
- CheckUnauthenticatedState(browser()->GetSelectedTabContents());
+ CheckUnauthenticatedState(browser()->GetSelectedWebContents());
}
// Visits a page to which we could not connect (bad port) over http and https
// and make sure the security style is correct.
IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) {
ui_test_utils::NavigateToURL(browser(), GURL("http://localhost:17"));
- CheckUnauthenticatedState(browser()->GetSelectedTabContents());
+ CheckUnauthenticatedState(browser()->GetSelectedWebContents());
// Same thing over HTTPS.
ui_test_utils::NavigateToURL(browser(), GURL("https://localhost:17"));
- CheckUnauthenticatedState(browser()->GetSelectedTabContents());
+ CheckUnauthenticatedState(browser()->GetSelectedWebContents());
}
//
@@ -1039,7 +1041,7 @@
https_server_expired_,
&top_frame_path));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
ui_test_utils::NavigateToURL(browser(),
https_server_.GetURL(top_frame_path));
@@ -1138,7 +1140,7 @@
https_server_expired_,
&top_frame_path));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
ui_test_utils::NavigateToURL(browser(),
https_server_expired_.GetURL(top_frame_path));
CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
@@ -1177,7 +1179,7 @@
https_server_expired_,
&top_frame_path));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(top_frame_path));
CheckUnauthenticatedState(tab);
@@ -1239,7 +1241,7 @@
&page_with_unsafe_worker_path));
ui_test_utils::NavigateToURL(browser(), https_server_.GetURL(
page_with_unsafe_worker_path));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
// Expect Worker not to load insecure content.
CheckWorkerLoadResult(tab, false);
// The bad content is filtered, expect the state to be authenticated.
@@ -1255,7 +1257,7 @@
// the user approves the bad certificate.
ui_test_utils::NavigateToURL(browser(),
https_server_expired_.GetURL("files/ssl/blank_page.html"));
- TabContents* tab = browser()->GetSelectedTabContents();
+ WebContents* tab = browser()->GetSelectedWebContents();
CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
true); // Interstitial showing
ProceedThroughInterstitial(tab);
@@ -1290,7 +1292,7 @@
ui_test_utils::NavigateToURL(browser(),
https_server_.GetURL(replacement_path));
- CheckAuthenticatedState(browser()->GetSelectedTabContents(), false);
+ CheckAuthenticatedState(browser()->GetSelectedWebContents(), false);
}
// Test that when the browser blocks displaying insecure content (iframes), the
@@ -1309,7 +1311,7 @@
ui_test_utils::NavigateToURL(browser(),
https_server_.GetURL(replacement_path));
- CheckAuthenticatedState(browser()->GetSelectedTabContents(), false);
+ CheckAuthenticatedState(browser()->GetSelectedWebContents(), false);
}
@@ -1329,7 +1331,7 @@
ui_test_utils::NavigateToURL(browser(),
https_server_.GetURL(replacement_path));
- CheckAuthenticatedState(browser()->GetSelectedTabContents(), false);
+ CheckAuthenticatedState(browser()->GetSelectedWebContents(), false);
}
« no previous file with comments | « chrome/browser/speech/speech_input_bubble_browsertest.cc ('k') | chrome/browser/sync/test/integration/sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698