Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/sim/SimTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/sim/SimTest.cpp b/third_party/WebKit/Source/web/tests/sim/SimTest.cpp |
| index 2a8e66e79baf943a992ca259f9a7a386f5f54bed..b1dbdf1e15a13ed475a609235db23cc35e2bd7d9 100644 |
| --- a/third_party/WebKit/Source/web/tests/sim/SimTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/sim/SimTest.cpp |
| @@ -10,11 +10,29 @@ |
| #include "platform/scroll/ScrollbarTheme.h" |
| #include "platform/testing/UnitTestHelpers.h" |
| #include "public/platform/WebCache.h" |
| +#include "public/web/WebScriptExecutionCallback.h" |
| +#include "public/web/WebScriptSource.h" |
| #include "web/WebLocalFrameImpl.h" |
| #include "web/WebViewImpl.h" |
| namespace blink { |
| +namespace { |
| +class ScriptExecutionCallbackHelper : public WebScriptExecutionCallback { |
| + public: |
| + const String Result() const { return result_; } |
| + |
| + private: |
| + void Completed(const WebVector<v8::Local<v8::Value>>& values) override { |
| + if (!values.IsEmpty() && !values[0].IsEmpty() && values[0]->IsString()) { |
| + result_ = ToCoreString(v8::Local<v8::String>::Cast(values[0])); |
| + } |
| + } |
| + |
| + String result_; |
| +}; |
| +} // namespace |
| + |
| SimTest::SimTest() : web_view_client_(compositor_), web_frame_client_(*this) { |
| Document::SetThreadedParsingEnabledForTesting(false); |
| // Use the mock theme to get more predictable code paths, this also avoids |
| @@ -77,4 +95,11 @@ void SimTest::AddConsoleMessage(const String& message) { |
| console_messages_.push_back(message); |
| } |
| +String SimTest::ExecuteJavaScript(String script_source) { |
| + ScriptExecutionCallbackHelper callback_helper; |
| + WebView().MainFrame()->ToWebLocalFrame()->RequestExecuteScriptAndReturnValue( |
|
esprehn
2017/04/20 19:54:07
Since you can access the core types directly this
|
| + WebScriptSource(WebString(script_source)), false, &callback_helper); |
| + return callback_helper.Result(); |
| +} |
| + |
| } // namespace blink |