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 de3761dff67071a6f498f99bacf3df1ddd2abc08..8109e3de874890b3fa1f34aad8611185ed46b073 100644 |
--- a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc |
+++ b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc |
@@ -1412,6 +1412,67 @@ 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; |
+ |
+ shell()->LoadURL(GURL("about://blank")); |
+ WaitForLoadStop(shell()->web_contents()); |
+ |
+ Attach(); |
+ SendCommand("Network.enable", nullptr, false); |
Eric Seckler
2017/02/28 08:41:17
Not quite sure, but as I understood it, we should
irisu
2017/02/28 23:30:25
Done.
|
+ SendCommand("Security.enable", nullptr, false); |
+ command_params.reset(new base::DictionaryValue()); |
+ command_params->SetBoolean("override", true); |
+ SendCommand("Security.setOverrideCertificateErrors", |
+ std::move(command_params), true); |
+ |
+ // Test cancel. |
+ SendCommand("Network.clearBrowserCache", nullptr, true); |
+ SendCommand("Network.clearBrowserCookies", nullptr, true); |
+ 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); |
+ |
+ // Test deny. |
+ SendCommand("Network.clearBrowserCache", nullptr, true); |
+ SendCommand("Network.clearBrowserCookies", nullptr, true); |
+ 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); |
+ |
+ // Test continue. |
+ SendCommand("Network.clearBrowserCache", nullptr, true); |
+ SendCommand("Network.clearBrowserCookies", nullptr, true); |
+ 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(); |
+} |
+ |
IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) { |
std::string temp; |
std::set<std::string> ids; |