Chromium Code Reviews| Index: content/browser/devtools/protocol/devtools_protocol_browsertest.cc |
| diff --git a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc |
| index 50358c27aec056e904acbfede116981082a82897..cd580119225bab306a49d600050ccb36e2ed5378 100644 |
| --- a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc |
| +++ b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc |
| @@ -1412,6 +1412,56 @@ IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, ShowCertificateViewer) { |
| EXPECT_EQ(transient_entry->GetSSL().certificate, last_shown_certificate()); |
| } |
| +IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, CertificateError) { |
| + net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
| + https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
| + ASSERT_TRUE(https_server.Start()); |
| + GURL test_url = https_server.GetURL("/devtools/navigation.html"); |
| + std::unique_ptr<base::DictionaryValue> params; |
| + std::unique_ptr<base::DictionaryValue> command_params; |
| + int eventID; |
| + |
| + Attach(); |
|
Eric Seckler
2017/02/08 02:40:35
Looks like loading a blank page first and reshuffl
irisu
2017/02/08 03:53:24
Awesome, Thanks!! Done.
|
| + SendCommand("Network.enable", nullptr, false); |
| + SendCommand("Security.enableCertificateErrorHandling", nullptr, true); |
| + |
| + // Test continue. |
| + WaitForLoadStop(shell()->web_contents()); |
| + TestNavigationObserver continue_observer(shell()->web_contents(), 1); |
| + shell()->LoadURL(test_url); |
| + params = WaitForNotification("Security.certificateError", false); |
| + EXPECT_TRUE(params->GetInteger("eventID", &eventID)); |
| + command_params.reset(new base::DictionaryValue()); |
| + command_params->SetInteger("eventID", eventID); |
| + command_params->SetString("action", "continue"); |
| + SendCommand("Security.handleCertificateError", std::move(command_params), |
| + false); |
| + WaitForNotification("Network.loadingFinished", true); |
| + continue_observer.Wait(); |
| + |
| + // Test cancel. |
| + shell()->LoadURL(test_url); |
| + params = WaitForNotification("Security.certificateError", false); |
| + EXPECT_TRUE(params->GetInteger("eventID", &eventID)); |
| + command_params.reset(new base::DictionaryValue()); |
| + command_params->SetInteger("eventID", eventID); |
| + command_params->SetString("action", "cancel"); |
| + SendCommand("Security.handleCertificateError", std::move(command_params), |
| + false); |
| + WaitForNotification("Network.loadingFailed", true); |
| + |
| + // Test deny. |
| + shell()->LoadURL(test_url); |
| + params = WaitForNotification("Security.certificateError", false); |
| + EXPECT_TRUE(params->GetInteger("eventID", &eventID)); |
| + command_params.reset(new base::DictionaryValue()); |
| + command_params->SetInteger("eventID", eventID); |
| + command_params->SetString("action", "deny"); |
| + SendCommand("Security.handleCertificateError", std::move(command_params), |
| + false); |
| + WaitForNotification("Network.loadingFailed", true); |
| +} |
| + |
| IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) { |
| std::string temp; |
| std::set<std::string> ids; |