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

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

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

Powered by Google App Engine
This is Rietveld 408576698