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

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

Issue 2639203003: Add certificate error handling to devtools. (Closed)
Patch Set: Add subresource test 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 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 web_contents->GetController().GetTransientEntry(); 1401 web_contents->GetController().GetTransientEntry();
1402 ASSERT_TRUE(transient_entry); 1402 ASSERT_TRUE(transient_entry);
1403 transient_entry->GetSSL().certificate = expired_cert(); 1403 transient_entry->GetSSL().certificate = expired_cert();
1404 ASSERT_TRUE(transient_entry->GetSSL().certificate); 1404 ASSERT_TRUE(transient_entry->GetSSL().certificate);
1405 1405
1406 std::unique_ptr<base::DictionaryValue> params2(new base::DictionaryValue()); 1406 std::unique_ptr<base::DictionaryValue> params2(new base::DictionaryValue());
1407 SendCommand("Security.showCertificateViewer", std::move(params2), true); 1407 SendCommand("Security.showCertificateViewer", std::move(params2), true);
1408 EXPECT_EQ(transient_entry->GetSSL().certificate, last_shown_certificate()); 1408 EXPECT_EQ(transient_entry->GetSSL().certificate, last_shown_certificate());
1409 } 1409 }
1410 1410
1411 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, CertificateError) {
1412 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
1413 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED);
1414 ASSERT_TRUE(https_server.Start());
1415 GURL test_url = https_server.GetURL("/devtools/image.html");
1416 std::unique_ptr<base::DictionaryValue> params;
1417 std::unique_ptr<base::DictionaryValue> command_params;
1418 int eventID;
1419
1420 shell()->LoadURL(GURL("about://blank"));
1421 WaitForLoadStop(shell()->web_contents());
1422
1423 Attach();
1424 SendCommand("Network.enable", nullptr, true);
1425 SendCommand("Security.enable", nullptr, false);
1426 command_params.reset(new base::DictionaryValue());
1427 command_params->SetBoolean("override", true);
1428 SendCommand("Security.setOverrideCertificateErrors",
1429 std::move(command_params), true);
1430
1431 // Test cancel.
1432 SendCommand("Network.clearBrowserCache", nullptr, true);
1433 SendCommand("Network.clearBrowserCookies", nullptr, true);
1434 shell()->LoadURL(test_url);
1435 params = WaitForNotification("Security.certificateError", false);
1436 EXPECT_TRUE(params->GetInteger("eventID", &eventID));
1437 command_params.reset(new base::DictionaryValue());
1438 command_params->SetInteger("eventID", eventID);
1439 command_params->SetString("action", "cancel");
1440 SendCommand("Security.handleCertificateError", std::move(command_params),
estark 2017/03/14 01:22:50 Hmm, this test doesn't currently check that the co
irisu 2017/03/16 03:40:18 Done.
1441 false);
1442
1443 // Test continue.
1444 SendCommand("Network.clearBrowserCache", nullptr, true);
1445 SendCommand("Network.clearBrowserCookies", nullptr, true);
1446 TestNavigationObserver continue_observer(shell()->web_contents(), 1);
1447 shell()->LoadURL(test_url);
1448 params = WaitForNotification("Security.certificateError", false);
1449 EXPECT_TRUE(params->GetInteger("eventID", &eventID));
1450 command_params.reset(new base::DictionaryValue());
1451 command_params->SetInteger("eventID", eventID);
1452 command_params->SetString("action", "continue");
1453 SendCommand("Security.handleCertificateError", std::move(command_params),
1454 false);
1455 WaitForNotification("Network.loadingFinished", true);
1456 continue_observer.Wait();
estark 2017/03/14 01:22:50 Maybe add an expectation that you ended up on the
irisu 2017/03/16 03:40:18 Done.
1457 }
1458
1411 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) { 1459 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) {
1412 std::string temp; 1460 std::string temp;
1413 std::set<std::string> ids; 1461 std::set<std::string> ids;
1414 std::unique_ptr<base::DictionaryValue> command_params; 1462 std::unique_ptr<base::DictionaryValue> command_params;
1415 std::unique_ptr<base::DictionaryValue> params; 1463 std::unique_ptr<base::DictionaryValue> params;
1416 1464
1417 ASSERT_TRUE(embedded_test_server()->Start()); 1465 ASSERT_TRUE(embedded_test_server()->Start());
1418 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html"); 1466 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html");
1419 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1); 1467 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1);
1420 1468
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 EXPECT_EQ("polyglottal", value); 1689 EXPECT_EQ("polyglottal", value);
1642 found++; 1690 found++;
1643 } else { 1691 } else {
1644 FAIL(); 1692 FAIL();
1645 } 1693 }
1646 } 1694 }
1647 EXPECT_EQ(2u, found); 1695 EXPECT_EQ(2u, found);
1648 } 1696 }
1649 1697
1650 } // namespace content 1698 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | content/browser/devtools/protocol/security_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698