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 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 web_contents->GetController().GetTransientEntry(); | 1407 web_contents->GetController().GetTransientEntry(); |
1408 ASSERT_TRUE(transient_entry); | 1408 ASSERT_TRUE(transient_entry); |
1409 transient_entry->GetSSL().certificate = expired_cert(); | 1409 transient_entry->GetSSL().certificate = expired_cert(); |
1410 ASSERT_TRUE(transient_entry->GetSSL().certificate); | 1410 ASSERT_TRUE(transient_entry->GetSSL().certificate); |
1411 | 1411 |
1412 std::unique_ptr<base::DictionaryValue> params2(new base::DictionaryValue()); | 1412 std::unique_ptr<base::DictionaryValue> params2(new base::DictionaryValue()); |
1413 SendCommand("Security.showCertificateViewer", std::move(params2), true); | 1413 SendCommand("Security.showCertificateViewer", std::move(params2), true); |
1414 EXPECT_EQ(transient_entry->GetSSL().certificate, last_shown_certificate()); | 1414 EXPECT_EQ(transient_entry->GetSSL().certificate, last_shown_certificate()); |
1415 } | 1415 } |
1416 | 1416 |
| 1417 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, CertificateError) { |
| 1418 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
| 1419 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
| 1420 https_server.ServeFilesFromSourceDirectory("content/test/data"); |
| 1421 ASSERT_TRUE(https_server.Start()); |
| 1422 GURL test_url = https_server.GetURL("/devtools/navigation.html"); |
| 1423 std::unique_ptr<base::DictionaryValue> params; |
| 1424 std::unique_ptr<base::DictionaryValue> command_params; |
| 1425 int eventId; |
| 1426 |
| 1427 shell()->LoadURL(GURL("about:blank")); |
| 1428 WaitForLoadStop(shell()->web_contents()); |
| 1429 |
| 1430 Attach(); |
| 1431 SendCommand("Network.enable", nullptr, true); |
| 1432 SendCommand("Security.enable", nullptr, false); |
| 1433 command_params.reset(new base::DictionaryValue()); |
| 1434 command_params->SetBoolean("override", true); |
| 1435 SendCommand("Security.setOverrideCertificateErrors", |
| 1436 std::move(command_params), true); |
| 1437 |
| 1438 // Test cancel. |
| 1439 SendCommand("Network.clearBrowserCache", nullptr, true); |
| 1440 SendCommand("Network.clearBrowserCookies", nullptr, true); |
| 1441 TestNavigationObserver cancel_observer(shell()->web_contents(), 1); |
| 1442 shell()->LoadURL(test_url); |
| 1443 params = WaitForNotification("Security.certificateError", false); |
| 1444 EXPECT_TRUE(shell()->web_contents()->GetController().GetPendingEntry()); |
| 1445 EXPECT_EQ( |
| 1446 test_url, |
| 1447 shell()->web_contents()->GetController().GetPendingEntry()->GetURL()); |
| 1448 EXPECT_TRUE(params->GetInteger("eventId", &eventId)); |
| 1449 command_params.reset(new base::DictionaryValue()); |
| 1450 command_params->SetInteger("eventId", eventId); |
| 1451 command_params->SetString("action", "cancel"); |
| 1452 SendCommand("Security.handleCertificateError", std::move(command_params), |
| 1453 false); |
| 1454 cancel_observer.Wait(); |
| 1455 EXPECT_FALSE(shell()->web_contents()->GetController().GetPendingEntry()); |
| 1456 EXPECT_EQ(GURL("about:blank"), shell() |
| 1457 ->web_contents() |
| 1458 ->GetController() |
| 1459 .GetLastCommittedEntry() |
| 1460 ->GetURL()); |
| 1461 |
| 1462 // Test continue. |
| 1463 SendCommand("Network.clearBrowserCache", nullptr, true); |
| 1464 SendCommand("Network.clearBrowserCookies", nullptr, true); |
| 1465 TestNavigationObserver continue_observer(shell()->web_contents(), 1); |
| 1466 shell()->LoadURL(test_url); |
| 1467 params = WaitForNotification("Security.certificateError", false); |
| 1468 EXPECT_TRUE(params->GetInteger("eventId", &eventId)); |
| 1469 command_params.reset(new base::DictionaryValue()); |
| 1470 command_params->SetInteger("eventId", eventId); |
| 1471 command_params->SetString("action", "continue"); |
| 1472 SendCommand("Security.handleCertificateError", std::move(command_params), |
| 1473 false); |
| 1474 WaitForNotification("Network.loadingFinished", true); |
| 1475 continue_observer.Wait(); |
| 1476 EXPECT_EQ(test_url, shell() |
| 1477 ->web_contents() |
| 1478 ->GetController() |
| 1479 .GetLastCommittedEntry() |
| 1480 ->GetURL()); |
| 1481 } |
| 1482 |
| 1483 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, SubresourceWithCertificateError) { |
| 1484 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
| 1485 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
| 1486 https_server.ServeFilesFromSourceDirectory("content/test/data/devtools"); |
| 1487 ASSERT_TRUE(https_server.Start()); |
| 1488 GURL test_url = https_server.GetURL("/image.html"); |
| 1489 std::unique_ptr<base::DictionaryValue> params; |
| 1490 std::unique_ptr<base::DictionaryValue> command_params; |
| 1491 int eventId; |
| 1492 |
| 1493 shell()->LoadURL(GURL("about:blank")); |
| 1494 WaitForLoadStop(shell()->web_contents()); |
| 1495 |
| 1496 Attach(); |
| 1497 SendCommand("Security.enable", nullptr, false); |
| 1498 command_params.reset(new base::DictionaryValue()); |
| 1499 command_params->SetBoolean("override", true); |
| 1500 SendCommand("Security.setOverrideCertificateErrors", |
| 1501 std::move(command_params), true); |
| 1502 |
| 1503 TestNavigationObserver observer(shell()->web_contents(), 1); |
| 1504 shell()->LoadURL(test_url); |
| 1505 |
| 1506 // Expect certificateError event for main frame. |
| 1507 params = WaitForNotification("Security.certificateError", false); |
| 1508 EXPECT_TRUE(params->GetInteger("eventId", &eventId)); |
| 1509 command_params.reset(new base::DictionaryValue()); |
| 1510 command_params->SetInteger("eventId", eventId); |
| 1511 command_params->SetString("action", "continue"); |
| 1512 SendCommand("Security.handleCertificateError", std::move(command_params), |
| 1513 false); |
| 1514 |
| 1515 // Expect certificateError event for image. |
| 1516 params = WaitForNotification("Security.certificateError", false); |
| 1517 EXPECT_TRUE(params->GetInteger("eventId", &eventId)); |
| 1518 command_params.reset(new base::DictionaryValue()); |
| 1519 command_params->SetInteger("eventId", eventId); |
| 1520 command_params->SetString("action", "continue"); |
| 1521 SendCommand("Security.handleCertificateError", std::move(command_params), |
| 1522 false); |
| 1523 |
| 1524 observer.Wait(); |
| 1525 EXPECT_EQ(test_url, shell() |
| 1526 ->web_contents() |
| 1527 ->GetController() |
| 1528 .GetLastCommittedEntry() |
| 1529 ->GetURL()); |
| 1530 } |
| 1531 |
1417 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) { | 1532 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) { |
1418 std::string temp; | 1533 std::string temp; |
1419 std::set<std::string> ids; | 1534 std::set<std::string> ids; |
1420 std::unique_ptr<base::DictionaryValue> command_params; | 1535 std::unique_ptr<base::DictionaryValue> command_params; |
1421 std::unique_ptr<base::DictionaryValue> params; | 1536 std::unique_ptr<base::DictionaryValue> params; |
1422 | 1537 |
1423 ASSERT_TRUE(embedded_test_server()->Start()); | 1538 ASSERT_TRUE(embedded_test_server()->Start()); |
1424 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html"); | 1539 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html"); |
1425 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1); | 1540 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1); |
1426 | 1541 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1647 EXPECT_EQ("polyglottal", value); | 1762 EXPECT_EQ("polyglottal", value); |
1648 found++; | 1763 found++; |
1649 } else { | 1764 } else { |
1650 FAIL(); | 1765 FAIL(); |
1651 } | 1766 } |
1652 } | 1767 } |
1653 EXPECT_EQ(2u, found); | 1768 EXPECT_EQ(2u, found); |
1654 } | 1769 } |
1655 | 1770 |
1656 } // namespace content | 1771 } // namespace content |
OLD | NEW |