| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "core/dom/TaskRunnerHelper.h" | 6 #include "core/dom/TaskRunnerHelper.h" |
| 7 #include "platform/testing/UnitTestHelpers.h" | 7 #include "platform/testing/UnitTestHelpers.h" |
| 8 #include "public/platform/Platform.h" | 8 #include "public/platform/Platform.h" |
| 9 #include "public/platform/WebViewScheduler.h" | 9 #include "public/platform/WebViewScheduler.h" |
| 10 #include "public/web/WebLocalFrame.h" | 10 #include "public/web/WebLocalFrame.h" |
| 11 #include "public/web/WebScriptExecutionCallback.h" | 11 #include "public/web/WebScriptExecutionCallback.h" |
| 12 #include "public/web/WebScriptSource.h" | 12 #include "public/web/WebScriptSource.h" |
| 13 #include "public/web/WebView.h" | 13 #include "public/web/WebView.h" |
| 14 #include "web/tests/sim/SimRequest.h" | 14 #include "web/tests/sim/SimRequest.h" |
| 15 #include "web/tests/sim/SimTest.h" | 15 #include "web/tests/sim/SimTest.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 class ScriptExecutionCallbackHelper : public WebScriptExecutionCallback { | 20 class ScriptExecutionCallbackHelper : public WebScriptExecutionCallback { |
| 21 public: | 21 public: |
| 22 const String result() const { return m_result; } | 22 const String result() const { return m_result; } |
| 23 | 23 |
| 24 private: | 24 private: |
| 25 void completed(const WebVector<v8::Local<v8::Value>>& values) override { | 25 void completed(const WebVector<v8::Local<v8::Value>>& values) override { |
| 26 if (!values.isEmpty() && !values[0].IsEmpty() && values[0]->IsString()) { | 26 if (!values.empty() && !values[0].IsEmpty() && values[0]->IsString()) { |
| 27 m_result = toCoreString(v8::Local<v8::String>::Cast(values[0])); | 27 m_result = toCoreString(v8::Local<v8::String>::Cast(values[0])); |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 String m_result; | 31 String m_result; |
| 32 }; | 32 }; |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 class VirtualTimeTest : public SimTest { | 35 class VirtualTimeTest : public SimTest { |
| 36 protected: | 36 protected: |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 // ALso schedule a second timer for the same point in time. | 228 // ALso schedule a second timer for the same point in time. |
| 229 ExecuteJavaScript("setTimeout(() => { run_order.push(2); }, 1000);"); | 229 ExecuteJavaScript("setTimeout(() => { run_order.push(2); }, 1000);"); |
| 230 | 230 |
| 231 // The second DOM timer shouldn't have run because pausing virtual time also | 231 // The second DOM timer shouldn't have run because pausing virtual time also |
| 232 // atomically pauses DOM timers. | 232 // atomically pauses DOM timers. |
| 233 testing::runPendingTasks(); | 233 testing::runPendingTasks(); |
| 234 EXPECT_EQ("1", ExecuteJavaScript("run_order.join(', ')")); | 234 EXPECT_EQ("1", ExecuteJavaScript("run_order.join(', ')")); |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace blink | 237 } // namespace blink |
| OLD | NEW |