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

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_browsertest.cc

Issue 2639203003: Add certificate error handling to devtools. (Closed)
Patch Set: Fixed test. Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 web_contents->GetController().GetTransientEntry(); 1405 web_contents->GetController().GetTransientEntry();
1406 ASSERT_TRUE(transient_entry); 1406 ASSERT_TRUE(transient_entry);
1407 transient_entry->GetSSL().certificate = expired_cert(); 1407 transient_entry->GetSSL().certificate = expired_cert();
1408 ASSERT_TRUE(transient_entry->GetSSL().certificate); 1408 ASSERT_TRUE(transient_entry->GetSSL().certificate);
1409 1409
1410 std::unique_ptr<base::DictionaryValue> params2(new base::DictionaryValue()); 1410 std::unique_ptr<base::DictionaryValue> params2(new base::DictionaryValue());
1411 SendCommand("Security.showCertificateViewer", std::move(params2), true); 1411 SendCommand("Security.showCertificateViewer", std::move(params2), true);
1412 EXPECT_EQ(transient_entry->GetSSL().certificate, last_shown_certificate()); 1412 EXPECT_EQ(transient_entry->GetSSL().certificate, last_shown_certificate());
1413 } 1413 }
1414 1414
1415 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, CertificateError) {
1416 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
1417 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED);
1418 ASSERT_TRUE(https_server.Start());
1419 GURL test_url = https_server.GetURL("/devtools/navigation.html");
1420 std::unique_ptr<base::DictionaryValue> params;
1421 std::unique_ptr<base::DictionaryValue> command_params;
1422 int eventID;
1423
1424 shell()->LoadURL(GURL("about://blank"));
1425 WaitForLoadStop(shell()->web_contents());
1426
1427 Attach();
1428 SendCommand("Network.enable", nullptr, false);
1429 SendCommand("Security.enableCertificateErrorHandling", nullptr, true);
1430
1431 // Test continue.
1432 TestNavigationObserver continue_observer(shell()->web_contents(), 1);
1433 shell()->LoadURL(test_url);
1434 params = WaitForNotification("Security.certificateError", false);
1435 EXPECT_TRUE(params->GetInteger("eventID", &eventID));
1436 command_params.reset(new base::DictionaryValue());
1437 command_params->SetInteger("eventID", eventID);
1438 command_params->SetString("action", "continue");
1439 SendCommand("Security.handleCertificateError", std::move(command_params),
1440 false);
1441 WaitForNotification("Network.loadingFinished", true);
1442 continue_observer.Wait();
1443
1444 // Test cancel.
1445 shell()->LoadURL(test_url);
1446 params = WaitForNotification("Security.certificateError", false);
1447 EXPECT_TRUE(params->GetInteger("eventID", &eventID));
1448 command_params.reset(new base::DictionaryValue());
1449 command_params->SetInteger("eventID", eventID);
1450 command_params->SetString("action", "cancel");
1451 SendCommand("Security.handleCertificateError", std::move(command_params),
1452 false);
1453 WaitForNotification("Network.loadingFailed", true);
1454
1455 // Test deny.
1456 shell()->LoadURL(test_url);
1457 params = WaitForNotification("Security.certificateError", false);
1458 EXPECT_TRUE(params->GetInteger("eventID", &eventID));
1459 command_params.reset(new base::DictionaryValue());
1460 command_params->SetInteger("eventID", eventID);
1461 command_params->SetString("action", "deny");
1462 SendCommand("Security.handleCertificateError", std::move(command_params),
1463 false);
1464 WaitForNotification("Network.loadingFailed", true);
1465 }
1466
1415 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) { 1467 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) {
1416 std::string temp; 1468 std::string temp;
1417 std::set<std::string> ids; 1469 std::set<std::string> ids;
1418 std::unique_ptr<base::DictionaryValue> command_params; 1470 std::unique_ptr<base::DictionaryValue> command_params;
1419 std::unique_ptr<base::DictionaryValue> params; 1471 std::unique_ptr<base::DictionaryValue> params;
1420 1472
1421 ASSERT_TRUE(embedded_test_server()->Start()); 1473 ASSERT_TRUE(embedded_test_server()->Start());
1422 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html"); 1474 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html");
1423 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1); 1475 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1);
1424 1476
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 EXPECT_EQ("polyglottal", value); 1697 EXPECT_EQ("polyglottal", value);
1646 found++; 1698 found++;
1647 } else { 1699 } else {
1648 FAIL(); 1700 FAIL();
1649 } 1701 }
1650 } 1702 }
1651 EXPECT_EQ(2u, found); 1703 EXPECT_EQ(2u, found);
1652 } 1704 }
1653 1705
1654 } // namespace content 1706 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698