Commit eda9b150 authored by toyoshim@chromium.org's avatar toyoshim@chromium.org

Add a SSL UI test to close tabs which contain hanging wss connections.

BUG=122654
TEST=browser_tests --gtest_filter='SSLUITest.TestWSSInvalidCertAndClose'

Review URL: https://chromiumcodereview.appspot.com/10416007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138220 0039d316-1c4b-4281-b951-d872f2087c98
parent ddf72144
......@@ -521,7 +521,48 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndGoForward) {
EXPECT_TRUE(entry2 == entry4);
}
// Visits a HTTPS page and proceeds despite an invalid certificate. The page
// Visit a HTTP page which request WSS connection to a server providing invalid
// certificate. Close the page while WSS connection waits for UI.
IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndClose) {
ASSERT_TRUE(test_server()->Start());
ASSERT_TRUE(https_server_expired_.Start());
// Setup page title observer.
WebContents* tab = browser()->GetSelectedWebContents();
ui_test_utils::TitleWatcher watcher(tab, ASCIIToUTF16("PASS"));
watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
// Create GURLs to test pages.
std::string masterUrlPath = StringPrintf("%s?%d",
test_server()->GetURL("files/ssl/wss_close.html").spec().c_str(),
https_server_expired_.host_port_pair().port());
GURL masterUrl(masterUrlPath);
std::string slaveUrlPath = StringPrintf("%s?%d",
test_server()->GetURL("files/ssl/wss_close_slave.html").spec().c_str(),
https_server_expired_.host_port_pair().port());
GURL slaveUrl(slaveUrlPath);
// Create tabs and visit pages which create hanging WebSocket connections.
TabContentsWrapper* tabs[16];
for (int i = 0; i < 16; ++i) {
tabs[i] = browser()->AddSelectedTabWithURL(
slaveUrl, content::PAGE_TRANSITION_LINK);
}
browser()->SelectNextTab();
// Visit a page which causes a hanging WebSocket connection. After waiting
// for two round trip time, the title will be changed to 'PASS'.
ui_test_utils::NavigateToURL(browser(), masterUrl);
const string16 result = watcher.WaitAndGetTitle();
EXPECT_TRUE(LowerCaseEqualsASCII(result, "pass"));
// Close tabs which contains the test page.
for (int i = 0; i < 16; ++i)
browser()->CloseTabContents(tabs[i]->web_contents());
browser()->CloseTabContents(tab);
}
// Visit a HTTPS page and proceeds despite an invalid certificate. The page
// requests WSS connection to the same origin host to check if WSS connection
// share certificates policy with HTTPS correcly.
IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndGoForward) {
......@@ -541,14 +582,14 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndGoForward) {
ui_test_utils::TitleWatcher watcher(tab, ASCIIToUTF16("PASS"));
watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
// Visits bad HTTPS page.
// Visit bad HTTPS page.
std::string urlPath =
StringPrintf("%s%d%s", "https://localhost:", port, "/wss.html");
ui_test_utils::NavigateToURL(browser(), GURL(urlPath));
CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
false, true); // Interstitial showing
// Proceeds anyway.
// Proceed anyway.
ProceedThroughInterstitial(tab);
// Test page run a WebSocket wss connection test. The result will be shown
......
<!DOCTYPE html>
<html>
<head>
<title>test to close hanging wss connection</title>
<script type="text/javascript">
var href = window.location.href;
var queryBegin = href.lastIndexOf('?') + 1;
var port = href.slice(queryBegin);
var url = 'wss://localhost:' + port;
function fail()
{
// Set document title to 'FAIL'. The test observer catches this title changes
// to know the result.
document.title = 'FAIL';
}
// Do connection test.
var ws = new WebSocket(url);
ws.onopen = fail;
ws.onclose = fail;
ws.onerror = fail;
// Use XHR to wait about two round trip time.
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if (this.readyState != this.DONE)
return;
var xhr2 = new XMLHttpRequest();
xhr2.onreadystatechange = function(){
if (this.readyState != this.DONE)
return;
document.title = 'PASS';
};
xhr2.open('GET', href);
xhr2.send();
};
xhr.open('GET', href);
xhr.send();
setTimeout(fail, 3000);
</script>
</head>
</html>
<!DOCTYPE html>
<html>
<head>
<title>slave tab pages which create hanging wss connection</title>
<script type="text/javascript">
var href = window.location.href;
var queryBegin = href.lastIndexOf('?') + 1;
var port = href.slice(queryBegin);
var url = 'wss://localhost:' + port;
var ws = new WebSocket(url);
</script>
</head>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment