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

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

Issue 2639203003: Add certificate error handling to devtools. (Closed)
Patch Set: Remove error code from certificateError event parameters 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.enable", nullptr, false);
1430 command_params.reset(new base::DictionaryValue());
1431 command_params->SetBoolean("override", true);
1432 SendCommand("Security.setOverrideCertificateErrors",
1433 std::move(command_params), true);
1434
1435 // Test continue.
1436 TestNavigationObserver continue_observer(shell()->web_contents(), 1);
1437 shell()->LoadURL(test_url);
1438 params = WaitForNotification("Security.certificateError", false);
1439 EXPECT_TRUE(params->GetInteger("eventID", &eventID));
1440 command_params.reset(new base::DictionaryValue());
1441 command_params->SetInteger("eventID", eventID);
1442 command_params->SetString("action", "continue");
1443 SendCommand("Security.handleCertificateError", std::move(command_params),
1444 false);
1445 WaitForNotification("Network.loadingFinished", true);
1446 continue_observer.Wait();
1447
1448 // Test cancel.
1449 shell()->LoadURL(test_url);
1450 params = WaitForNotification("Security.certificateError", false);
1451 EXPECT_TRUE(params->GetInteger("eventID", &eventID));
1452 command_params.reset(new base::DictionaryValue());
1453 command_params->SetInteger("eventID", eventID);
1454 command_params->SetString("action", "cancel");
1455 SendCommand("Security.handleCertificateError", std::move(command_params),
1456 false);
1457 WaitForNotification("Network.loadingFailed", true);
1458
1459 // Test deny.
1460 shell()->LoadURL(test_url);
1461 params = WaitForNotification("Security.certificateError", false);
1462 EXPECT_TRUE(params->GetInteger("eventID", &eventID));
1463 command_params.reset(new base::DictionaryValue());
1464 command_params->SetInteger("eventID", eventID);
1465 command_params->SetString("action", "deny");
1466 SendCommand("Security.handleCertificateError", std::move(command_params),
1467 false);
1468 WaitForNotification("Network.loadingFailed", true);
1469 }
1470
1415 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) { 1471 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) {
1416 std::string temp; 1472 std::string temp;
1417 std::set<std::string> ids; 1473 std::set<std::string> ids;
1418 std::unique_ptr<base::DictionaryValue> command_params; 1474 std::unique_ptr<base::DictionaryValue> command_params;
1419 std::unique_ptr<base::DictionaryValue> params; 1475 std::unique_ptr<base::DictionaryValue> params;
1420 1476
1421 ASSERT_TRUE(embedded_test_server()->Start()); 1477 ASSERT_TRUE(embedded_test_server()->Start());
1422 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html"); 1478 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html");
1423 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1); 1479 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1);
1424 1480
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 EXPECT_EQ("polyglottal", value); 1701 EXPECT_EQ("polyglottal", value);
1646 found++; 1702 found++;
1647 } else { 1703 } else {
1648 FAIL(); 1704 FAIL();
1649 } 1705 }
1650 } 1706 }
1651 EXPECT_EQ(2u, found); 1707 EXPECT_EQ(2u, found);
1652 } 1708 }
1653 1709
1654 } // namespace content 1710 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698