OLD | NEW |
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 Loading... |
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, true); |
| 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 continue. |
| 1448 SendCommand("Network.clearBrowserCache", nullptr, true); |
| 1449 SendCommand("Network.clearBrowserCookies", nullptr, true); |
| 1450 TestNavigationObserver continue_observer(shell()->web_contents(), 1); |
| 1451 shell()->LoadURL(test_url); |
| 1452 params = WaitForNotification("Security.certificateError", false); |
| 1453 EXPECT_TRUE(params->GetInteger("eventID", &eventID)); |
| 1454 command_params.reset(new base::DictionaryValue()); |
| 1455 command_params->SetInteger("eventID", eventID); |
| 1456 command_params->SetString("action", "continue"); |
| 1457 SendCommand("Security.handleCertificateError", std::move(command_params), |
| 1458 false); |
| 1459 WaitForNotification("Network.loadingFinished", true); |
| 1460 continue_observer.Wait(); |
| 1461 } |
| 1462 |
1415 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) { | 1463 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) { |
1416 std::string temp; | 1464 std::string temp; |
1417 std::set<std::string> ids; | 1465 std::set<std::string> ids; |
1418 std::unique_ptr<base::DictionaryValue> command_params; | 1466 std::unique_ptr<base::DictionaryValue> command_params; |
1419 std::unique_ptr<base::DictionaryValue> params; | 1467 std::unique_ptr<base::DictionaryValue> params; |
1420 | 1468 |
1421 ASSERT_TRUE(embedded_test_server()->Start()); | 1469 ASSERT_TRUE(embedded_test_server()->Start()); |
1422 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html"); | 1470 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html"); |
1423 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1); | 1471 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1); |
1424 | 1472 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 EXPECT_EQ("polyglottal", value); | 1693 EXPECT_EQ("polyglottal", value); |
1646 found++; | 1694 found++; |
1647 } else { | 1695 } else { |
1648 FAIL(); | 1696 FAIL(); |
1649 } | 1697 } |
1650 } | 1698 } |
1651 EXPECT_EQ(2u, found); | 1699 EXPECT_EQ(2u, found); |
1652 } | 1700 } |
1653 | 1701 |
1654 } // namespace content | 1702 } // namespace content |
OLD | NEW |