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

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

Issue 2639203003: Add certificate error handling to devtools. (Closed)
Patch Set: Add certificate error command tests 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
« no previous file with comments | « no previous file | content/browser/devtools/protocol/security_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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.
1425 SendCommand("Network.enable", nullptr, false);
1426 SendCommand("Security.enableCertificateErrorHandling", nullptr, true);
1427
1428 // Test continue.
1429 WaitForLoadStop(shell()->web_contents());
1430 TestNavigationObserver continue_observer(shell()->web_contents(), 1);
1431 shell()->LoadURL(test_url);
1432 params = WaitForNotification("Security.certificateError", false);
1433 EXPECT_TRUE(params->GetInteger("eventID", &eventID));
1434 command_params.reset(new base::DictionaryValue());
1435 command_params->SetInteger("eventID", eventID);
1436 command_params->SetString("action", "continue");
1437 SendCommand("Security.handleCertificateError", std::move(command_params),
1438 false);
1439 WaitForNotification("Network.loadingFinished", true);
1440 continue_observer.Wait();
1441
1442 // Test cancel.
1443 shell()->LoadURL(test_url);
1444 params = WaitForNotification("Security.certificateError", false);
1445 EXPECT_TRUE(params->GetInteger("eventID", &eventID));
1446 command_params.reset(new base::DictionaryValue());
1447 command_params->SetInteger("eventID", eventID);
1448 command_params->SetString("action", "cancel");
1449 SendCommand("Security.handleCertificateError", std::move(command_params),
1450 false);
1451 WaitForNotification("Network.loadingFailed", true);
1452
1453 // Test deny.
1454 shell()->LoadURL(test_url);
1455 params = WaitForNotification("Security.certificateError", false);
1456 EXPECT_TRUE(params->GetInteger("eventID", &eventID));
1457 command_params.reset(new base::DictionaryValue());
1458 command_params->SetInteger("eventID", eventID);
1459 command_params->SetString("action", "deny");
1460 SendCommand("Security.handleCertificateError", std::move(command_params),
1461 false);
1462 WaitForNotification("Network.loadingFailed", true);
1463 }
1464
1415 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) { 1465 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) {
1416 std::string temp; 1466 std::string temp;
1417 std::set<std::string> ids; 1467 std::set<std::string> ids;
1418 std::unique_ptr<base::DictionaryValue> command_params; 1468 std::unique_ptr<base::DictionaryValue> command_params;
1419 std::unique_ptr<base::DictionaryValue> params; 1469 std::unique_ptr<base::DictionaryValue> params;
1420 1470
1421 ASSERT_TRUE(embedded_test_server()->Start()); 1471 ASSERT_TRUE(embedded_test_server()->Start());
1422 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html"); 1472 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html");
1423 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1); 1473 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1);
1424 1474
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 EXPECT_EQ("polyglottal", value); 1695 EXPECT_EQ("polyglottal", value);
1646 found++; 1696 found++;
1647 } else { 1697 } else {
1648 FAIL(); 1698 FAIL();
1649 } 1699 }
1650 } 1700 }
1651 EXPECT_EQ(2u, found); 1701 EXPECT_EQ(2u, found);
1652 } 1702 }
1653 1703
1654 } // namespace content 1704 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/devtools/protocol/security_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698