| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "core/frame/DOMTimer.h" | 5 #include "core/frame/DOMTimer.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "bindings/core/v8/ScriptController.h" | 9 #include "bindings/core/v8/ScriptController.h" |
| 10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 RenderingTest::SetUp(); | 43 RenderingTest::SetUp(); |
| 44 // Advance timer again as otherwise the time between the first call to | 44 // Advance timer again as otherwise the time between the first call to |
| 45 // setInterval and it running will be off by 5us. | 45 // setInterval and it running will be off by 5us. |
| 46 platform_->AdvanceClockSeconds(1); | 46 platform_->AdvanceClockSeconds(1); |
| 47 GetDocument().GetSettings()->SetScriptEnabled(true); | 47 GetDocument().GetSettings()->SetScriptEnabled(true); |
| 48 } | 48 } |
| 49 | 49 |
| 50 v8::Local<v8::Value> EvalExpression(const char* expr) { | 50 v8::Local<v8::Value> EvalExpression(const char* expr) { |
| 51 return GetDocument() | 51 return GetDocument() |
| 52 .GetFrame() | 52 .GetFrame() |
| 53 ->Script() | 53 ->GetScriptController() |
| 54 .ExecuteScriptInMainWorldAndReturnValue(ScriptSourceCode(expr)); | 54 .ExecuteScriptInMainWorldAndReturnValue(ScriptSourceCode(expr)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 Vector<double> ToDoubleArray(v8::Local<v8::Value> value, | 57 Vector<double> ToDoubleArray(v8::Local<v8::Value> value, |
| 58 v8::HandleScope& scope) { | 58 v8::HandleScope& scope) { |
| 59 NonThrowableExceptionState exception_state; | 59 NonThrowableExceptionState exception_state; |
| 60 return ToImplArray<Vector<double>>(value, 0, scope.GetIsolate(), | 60 return ToImplArray<Vector<double>>(value, 0, scope.GetIsolate(), |
| 61 exception_state); | 61 exception_state); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void ExecuteScriptAndWaitUntilIdle(const char* script_text) { | 64 void ExecuteScriptAndWaitUntilIdle(const char* script_text) { |
| 65 ScriptSourceCode script(script_text); | 65 ScriptSourceCode script(script_text); |
| 66 GetDocument().GetFrame()->Script().ExecuteScriptInMainWorld(script); | 66 GetDocument().GetFrame()->GetScriptController().ExecuteScriptInMainWorld( |
| 67 script); |
| 67 platform_->RunUntilIdle(); | 68 platform_->RunUntilIdle(); |
| 68 } | 69 } |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 const char* g_k_set_timeout_script_text = | 72 const char* g_k_set_timeout_script_text = |
| 72 "var id;" | 73 "var id;" |
| 73 "var last = performance.now();" | 74 "var last = performance.now();" |
| 74 "var times = [];" | 75 "var times = [];" |
| 75 "function nestSetTimeouts() {" | 76 "function nestSetTimeouts() {" |
| 76 " var current = performance.now();" | 77 " var current = performance.now();" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 ExecuteScriptAndWaitUntilIdle(g_k_set_interval_script_text); | 128 ExecuteScriptAndWaitUntilIdle(g_k_set_interval_script_text); |
| 128 | 129 |
| 129 auto times(ToDoubleArray(EvalExpression("times"), scope)); | 130 auto times(ToDoubleArray(EvalExpression("times"), scope)); |
| 130 | 131 |
| 131 EXPECT_THAT(times, ElementsAreArray(kExpectedTimings)); | 132 EXPECT_THAT(times, ElementsAreArray(kExpectedTimings)); |
| 132 } | 133 } |
| 133 | 134 |
| 134 } // namespace | 135 } // namespace |
| 135 | 136 |
| 136 } // namespace blink | 137 } // namespace blink |
| OLD | NEW |