| 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 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 } | 1360 } |
| 1361 | 1361 |
| 1362 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) { | 1362 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) { |
| 1363 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 1363 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
| 1364 Attach(); | 1364 Attach(); |
| 1365 | 1365 |
| 1366 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 1366 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
| 1367 params->SetString("policy", "pause"); | 1367 params->SetString("policy", "pause"); |
| 1368 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); | 1368 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); |
| 1369 | 1369 |
| 1370 // TODO(scheduler-dev): Revisit timing when we have strict ordering | |
| 1371 // guarantees. | |
| 1372 params.reset(new base::DictionaryValue()); | 1370 params.reset(new base::DictionaryValue()); |
| 1373 params->SetString("expression", | 1371 params->SetString("expression", |
| 1374 "setTimeout(function(){console.log('before')}, 1000);" | 1372 "setTimeout(function(){console.log('before')}, 1000);" |
| 1375 "setTimeout(function(){console.log('after')}, 1002);"); | 1373 "setTimeout(function(){console.log('after')}, 1001);"); |
| 1376 SendCommand("Runtime.evaluate", std::move(params), true); | 1374 SendCommand("Runtime.evaluate", std::move(params), true); |
| 1377 | 1375 |
| 1378 // Let virtual time advance for one second. | 1376 // Let virtual time advance for one second. |
| 1379 params.reset(new base::DictionaryValue()); | 1377 params.reset(new base::DictionaryValue()); |
| 1380 params->SetString("policy", "advance"); | 1378 params->SetString("policy", "advance"); |
| 1381 params->SetInteger("budget", 1001); | 1379 params->SetInteger("budget", 1000); |
| 1382 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); | 1380 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); |
| 1383 | 1381 |
| 1384 WaitForNotification("Emulation.virtualTimeBudgetExpired"); | 1382 WaitForNotification("Emulation.virtualTimeBudgetExpired"); |
| 1385 | 1383 |
| 1386 params.reset(new base::DictionaryValue()); | 1384 params.reset(new base::DictionaryValue()); |
| 1387 params->SetString("expression", "console.log('done')"); | 1385 params->SetString("expression", "console.log('done')"); |
| 1388 SendCommand("Runtime.evaluate", std::move(params), true); | 1386 SendCommand("Runtime.evaluate", std::move(params), true); |
| 1389 | 1387 |
| 1390 // The second timer shold not fire. | 1388 // The second timer shold not fire. |
| 1391 EXPECT_THAT(console_messages_, ElementsAre("before", "done")); | 1389 EXPECT_THAT(console_messages_, ElementsAre("before", "done")); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1803 EXPECT_EQ("polyglottal", value); | 1801 EXPECT_EQ("polyglottal", value); |
| 1804 found++; | 1802 found++; |
| 1805 } else { | 1803 } else { |
| 1806 FAIL(); | 1804 FAIL(); |
| 1807 } | 1805 } |
| 1808 } | 1806 } |
| 1809 EXPECT_EQ(2u, found); | 1807 EXPECT_EQ(2u, found); |
| 1810 } | 1808 } |
| 1811 | 1809 |
| 1812 } // namespace content | 1810 } // namespace content |
| OLD | NEW |