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 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 } | 1372 } |
1373 | 1373 |
1374 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) { | 1374 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) { |
1375 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 1375 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
1376 Attach(); | 1376 Attach(); |
1377 | 1377 |
1378 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 1378 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
1379 params->SetString("policy", "pause"); | 1379 params->SetString("policy", "pause"); |
1380 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); | 1380 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); |
1381 | 1381 |
1382 // TODO(scheduler-dev): Revisit timing when we have strict ordering | |
1383 // guarantees. | |
1384 params.reset(new base::DictionaryValue()); | 1382 params.reset(new base::DictionaryValue()); |
1385 params->SetString("expression", | 1383 params->SetString("expression", |
1386 "setTimeout(function(){console.log('before')}, 1000);" | 1384 "setTimeout(function(){console.log('before')}, 999);" |
1387 "setTimeout(function(){console.log('after')}, 1002);"); | 1385 "setTimeout(function(){console.log('at')}, 1000);" |
| 1386 "setTimeout(function(){console.log('after')}, 1001);"); |
1388 SendCommand("Runtime.evaluate", std::move(params), true); | 1387 SendCommand("Runtime.evaluate", std::move(params), true); |
1389 | 1388 |
1390 // Let virtual time advance for one second. | 1389 // Let virtual time advance for one second. |
1391 params.reset(new base::DictionaryValue()); | 1390 params.reset(new base::DictionaryValue()); |
1392 params->SetString("policy", "advance"); | 1391 params->SetString("policy", "advance"); |
1393 params->SetInteger("budget", 1001); | 1392 params->SetInteger("budget", 1000); |
1394 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); | 1393 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); |
1395 | 1394 |
1396 WaitForNotification("Emulation.virtualTimeBudgetExpired"); | 1395 WaitForNotification("Emulation.virtualTimeBudgetExpired"); |
1397 | 1396 |
1398 params.reset(new base::DictionaryValue()); | 1397 params.reset(new base::DictionaryValue()); |
1399 params->SetString("expression", "console.log('done')"); | 1398 params->SetString("expression", "console.log('done')"); |
1400 SendCommand("Runtime.evaluate", std::move(params), true); | 1399 SendCommand("Runtime.evaluate", std::move(params), true); |
1401 | 1400 |
1402 // The second timer shold not fire. | 1401 // The second timer shold not fire. |
1403 EXPECT_THAT(console_messages_, ElementsAre("before", "done")); | 1402 EXPECT_THAT(console_messages_, ElementsAre("before", "done")); |
1404 | 1403 |
1405 // Let virtual time advance for another second, which should make the second | 1404 // Let virtual time advance for another second, which should make the second |
1406 // timer fire. | 1405 // timer fire. |
1407 params.reset(new base::DictionaryValue()); | 1406 params.reset(new base::DictionaryValue()); |
1408 params->SetString("policy", "advance"); | 1407 params->SetString("policy", "advance"); |
1409 params->SetInteger("budget", 1000); | 1408 params->SetInteger("budget", 1000); |
1410 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); | 1409 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); |
1411 | 1410 |
1412 WaitForNotification("Emulation.virtualTimeBudgetExpired"); | 1411 WaitForNotification("Emulation.virtualTimeBudgetExpired"); |
1413 | 1412 |
1414 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after")); | 1413 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "at", "after")); |
1415 } | 1414 } |
1416 | 1415 |
1417 // Tests that the Security.showCertificateViewer command shows the | 1416 // Tests that the Security.showCertificateViewer command shows the |
1418 // certificate corresponding to the visible navigation entry, even when | 1417 // certificate corresponding to the visible navigation entry, even when |
1419 // an interstitial is showing. Regression test for | 1418 // an interstitial is showing. Regression test for |
1420 // https://crbug.com/647759. | 1419 // https://crbug.com/647759. |
1421 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, ShowCertificateViewer) { | 1420 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, ShowCertificateViewer) { |
1422 // First test that the correct certificate is shown for a normal | 1421 // First test that the correct certificate is shown for a normal |
1423 // (non-interstitial) page. | 1422 // (non-interstitial) page. |
1424 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 1423 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 EXPECT_EQ("polyglottal", value); | 1813 EXPECT_EQ("polyglottal", value); |
1815 found++; | 1814 found++; |
1816 } else { | 1815 } else { |
1817 FAIL(); | 1816 FAIL(); |
1818 } | 1817 } |
1819 } | 1818 } |
1820 EXPECT_EQ(2u, found); | 1819 EXPECT_EQ(2u, found); |
1821 } | 1820 } |
1822 | 1821 |
1823 } // namespace content | 1822 } // namespace content |
OLD | NEW |