| Index: third_party/WebKit/Source/core/mojo/tests/JsToCppTest.cpp
|
| diff --git a/mojo/edk/js/tests/js_to_cpp_tests.cc b/third_party/WebKit/Source/core/mojo/tests/JsToCppTest.cpp
|
| similarity index 56%
|
| rename from mojo/edk/js/tests/js_to_cpp_tests.cc
|
| rename to third_party/WebKit/Source/core/mojo/tests/JsToCppTest.cpp
|
| index d193ffc9e8e73a5c57c12af822b1dc5d87bb70e5..2b7ada7a0a41bfc44538f108598d5076b11db82e 100644
|
| --- a/mojo/edk/js/tests/js_to_cpp_tests.cc
|
| +++ b/third_party/WebKit/Source/core/mojo/tests/JsToCppTest.cpp
|
| @@ -2,42 +2,27 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include <stddef.h>
|
| -#include <stdint.h>
|
| -
|
| -#include <string>
|
| -#include <utility>
|
| -
|
| -#include "base/at_exit.h"
|
| -#include "base/files/file_path.h"
|
| -#include "base/files/file_util.h"
|
| -#include "base/macros.h"
|
| -#include "base/run_loop.h"
|
| -#include "base/strings/utf_string_conversions.h"
|
| -#include "base/test/scoped_task_environment.h"
|
| -#include "base/threading/thread_task_runner_handle.h"
|
| -#include "gin/array_buffer.h"
|
| -#include "gin/public/isolate_holder.h"
|
| -#include "gin/v8_initializer.h"
|
| -#include "mojo/common/data_pipe_utils.h"
|
| -#include "mojo/edk/js/mojo_runner_delegate.h"
|
| -#include "mojo/edk/js/tests/js_to_cpp.mojom.h"
|
| +#include "bindings/core/v8/ScriptController.h"
|
| +#include "bindings/core/v8/ScriptSourceCode.h"
|
| +#include "bindings/core/v8/V8BindingForCore.h"
|
| +#include "bindings/core/v8/V8BindingForTesting.h"
|
| +#include "bindings/core/v8/V8ScriptRunner.h"
|
| +#include "core/frame/Settings.h"
|
| +#include "core/mojo/MojoHandle.h"
|
| +#include "core/page/Page.h"
|
| #include "mojo/public/cpp/bindings/binding.h"
|
| -#include "mojo/public/cpp/bindings/lib/validation_errors.h"
|
| -#include "mojo/public/cpp/system/core.h"
|
| #include "mojo/public/cpp/system/wait.h"
|
| +#include "platform/testing/UnitTestHelpers.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| +#include "third_party/WebKit/Source/core/mojo/tests/JsToCpp.mojom-blink.h"
|
|
|
| -namespace mojo {
|
| -namespace edk {
|
| -namespace js {
|
| +namespace blink {
|
| +namespace {
|
|
|
| // Global value updated by some checks to prevent compilers from optimizing
|
| // reads out of existence.
|
| uint32_t g_waste_accumulator = 0;
|
|
|
| -namespace {
|
| -
|
| // Negative numbers with different values in each byte, the last of
|
| // which can survive promotion to double and back.
|
| const int8_t kExpectedInt8Value = -65;
|
| @@ -63,24 +48,53 @@ const float kExpectedFloatNan = std::numeric_limits<float>::quiet_NaN();
|
| // NaN has the property that it is not equal to itself.
|
| #define EXPECT_NAN(x) EXPECT_NE(x, x)
|
|
|
| -void CheckDataPipe(ScopedDataPipeConsumerHandle data_pipe_handle) {
|
| - std::string buffer;
|
| - bool result = common::BlockingCopyToString(std::move(data_pipe_handle),
|
| - &buffer);
|
| - EXPECT_TRUE(result);
|
| - EXPECT_EQ(64u, buffer.size());
|
| - for (int i = 0; i < 64; ++i) {
|
| - EXPECT_EQ(i, buffer[i]);
|
| +String MojoBindingsScriptPath() {
|
| + String filepath = testing::ExecutableDir();
|
| + filepath.append("/gen/mojo/public/js/mojo_bindings.js");
|
| + return filepath;
|
| +}
|
| +
|
| +String TestBindingsScriptPath() {
|
| + String filepath = testing::ExecutableDir();
|
| + filepath.append(
|
| + "/gen/third_party/WebKit/Source/core/mojo/tests/JsToCpp.mojom.js");
|
| + return filepath;
|
| +}
|
| +
|
| +String TestScriptPath() {
|
| + String filepath = testing::BlinkRootDir();
|
| + filepath.append("/Source/core/mojo/tests/JsToCppTest.js");
|
| + return filepath;
|
| +}
|
| +
|
| +v8::Local<v8::Value> ExecuteScript(const String& script_path,
|
| + LocalFrame& frame) {
|
| + RefPtr<SharedBuffer> script_src = testing::ReadFromFile(script_path);
|
| + return frame.GetScriptController().ExecuteScriptInMainWorldAndReturnValue(
|
| + ScriptSourceCode(String(script_src->Data(), script_src->size())));
|
| +}
|
| +
|
| +void CheckDataPipe(mojo::DataPipeConsumerHandle data_pipe_handle) {
|
| + const void* buffer = nullptr;
|
| + unsigned num_bytes = 0;
|
| + MojoResult result = Wait(data_pipe_handle, MOJO_HANDLE_SIGNAL_READABLE);
|
| + EXPECT_EQ(MOJO_RESULT_OK, result);
|
| + result = BeginReadDataRaw(data_pipe_handle, &buffer, &num_bytes,
|
| + MOJO_READ_DATA_FLAG_NONE);
|
| + EXPECT_EQ(MOJO_RESULT_OK, result);
|
| + EXPECT_EQ(64u, num_bytes);
|
| + for (unsigned i = 0; i < num_bytes; ++i) {
|
| + EXPECT_EQ(i, static_cast<unsigned>(static_cast<const char*>(buffer)[i]));
|
| }
|
| + EndReadDataRaw(data_pipe_handle, num_bytes);
|
| }
|
|
|
| -void CheckMessagePipe(MessagePipeHandle message_pipe_handle) {
|
| +void CheckMessagePipe(mojo::MessagePipeHandle message_pipe_handle) {
|
| unsigned char buffer[100];
|
| uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer));
|
| MojoResult result = Wait(message_pipe_handle, MOJO_HANDLE_SIGNAL_READABLE);
|
| EXPECT_EQ(MOJO_RESULT_OK, result);
|
| - result = ReadMessageRaw(
|
| - message_pipe_handle, buffer, &buffer_size, 0, 0, 0);
|
| + result = ReadMessageRaw(message_pipe_handle, buffer, &buffer_size, 0, 0, 0);
|
| EXPECT_EQ(MOJO_RESULT_OK, result);
|
| EXPECT_EQ(64u, buffer_size);
|
| for (int i = 0; i < 64; ++i) {
|
| @@ -88,8 +102,8 @@ void CheckMessagePipe(MessagePipeHandle message_pipe_handle) {
|
| }
|
| }
|
|
|
| -js_to_cpp::EchoArgsPtr BuildSampleEchoArgs() {
|
| - js_to_cpp::EchoArgsPtr args(js_to_cpp::EchoArgs::New());
|
| +js_to_cpp::blink::EchoArgsPtr BuildSampleEchoArgs() {
|
| + auto args = js_to_cpp::blink::EchoArgs::New();
|
| args->si64 = kExpectedInt64Value;
|
| args->si32 = kExpectedInt32Value;
|
| args->si16 = kExpectedInt16Value;
|
| @@ -104,7 +118,7 @@ js_to_cpp::EchoArgsPtr BuildSampleEchoArgs() {
|
| args->double_val = kExpectedDoubleVal;
|
| args->double_inf = kExpectedDoubleInf;
|
| args->double_nan = kExpectedDoubleNan;
|
| - args->name.emplace("coming");
|
| + args->name = "coming";
|
| args->string_array.emplace(3);
|
| (*args->string_array)[0] = "one";
|
| (*args->string_array)[1] = "two";
|
| @@ -112,7 +126,7 @@ js_to_cpp::EchoArgsPtr BuildSampleEchoArgs() {
|
| return args;
|
| }
|
|
|
| -void CheckSampleEchoArgs(js_to_cpp::EchoArgsPtr arg) {
|
| +void CheckSampleEchoArgs(const js_to_cpp::blink::EchoArgsPtr& arg) {
|
| EXPECT_EQ(kExpectedInt64Value, arg->si64);
|
| EXPECT_EQ(kExpectedInt32Value, arg->si32);
|
| EXPECT_EQ(kExpectedInt16Value, arg->si16);
|
| @@ -127,77 +141,70 @@ void CheckSampleEchoArgs(js_to_cpp::EchoArgsPtr arg) {
|
| EXPECT_EQ(kExpectedDoubleVal, arg->double_val);
|
| EXPECT_EQ(kExpectedDoubleInf, arg->double_inf);
|
| EXPECT_NAN(arg->double_nan);
|
| - EXPECT_EQ(std::string("coming"), *arg->name);
|
| - EXPECT_EQ(std::string("one"), (*arg->string_array)[0]);
|
| - EXPECT_EQ(std::string("two"), (*arg->string_array)[1]);
|
| - EXPECT_EQ(std::string("three"), (*arg->string_array)[2]);
|
| - CheckDataPipe(std::move(arg->data_handle));
|
| + EXPECT_EQ(String("coming"), arg->name);
|
| + EXPECT_EQ(String("one"), (*arg->string_array)[0]);
|
| + EXPECT_EQ(String("two"), (*arg->string_array)[1]);
|
| + EXPECT_EQ(String("three"), (*arg->string_array)[2]);
|
| + CheckDataPipe(arg->data_handle.get());
|
| CheckMessagePipe(arg->message_handle.get());
|
| }
|
|
|
| -void CheckSampleEchoArgsList(const js_to_cpp::EchoArgsListPtr& list) {
|
| +void CheckSampleEchoArgsList(const js_to_cpp::blink::EchoArgsListPtr& list) {
|
| if (list.is_null())
|
| return;
|
| - CheckSampleEchoArgs(std::move(list->item));
|
| + CheckSampleEchoArgs(list->item);
|
| CheckSampleEchoArgsList(list->next);
|
| }
|
|
|
| // More forgiving checks are needed in the face of potentially corrupt
|
| // messages. The values don't matter so long as all accesses are within
|
| // bounds.
|
| -void CheckCorruptedString(const std::string& arg) {
|
| - for (size_t i = 0; i < arg.size(); ++i)
|
| +void CheckCorruptedString(const String& arg) {
|
| + for (size_t i = 0; i < arg.length(); ++i)
|
| g_waste_accumulator += arg[i];
|
| }
|
|
|
| -void CheckCorruptedString(const base::Optional<std::string>& arg) {
|
| - if (!arg)
|
| - return;
|
| - CheckCorruptedString(*arg);
|
| -}
|
| -
|
| -void CheckCorruptedStringArray(
|
| - const base::Optional<std::vector<std::string>>& string_array) {
|
| +void CheckCorruptedStringArray(const Optional<Vector<String>>& string_array) {
|
| if (!string_array)
|
| return;
|
| for (size_t i = 0; i < string_array->size(); ++i)
|
| CheckCorruptedString((*string_array)[i]);
|
| }
|
|
|
| -void CheckCorruptedDataPipe(MojoHandle data_pipe_handle) {
|
| +void CheckCorruptedDataPipe(mojo::DataPipeConsumerHandle data_pipe_handle) {
|
| unsigned char buffer[100];
|
| uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer));
|
| - MojoResult result = MojoReadData(
|
| - data_pipe_handle, buffer, &buffer_size, MOJO_READ_DATA_FLAG_NONE);
|
| + MojoResult result = ReadDataRaw(data_pipe_handle, buffer, &buffer_size,
|
| + MOJO_READ_DATA_FLAG_NONE);
|
| if (result != MOJO_RESULT_OK)
|
| return;
|
| for (uint32_t i = 0; i < buffer_size; ++i)
|
| g_waste_accumulator += buffer[i];
|
| }
|
|
|
| -void CheckCorruptedMessagePipe(MojoHandle message_pipe_handle) {
|
| +void CheckCorruptedMessagePipe(mojo::MessagePipeHandle message_pipe_handle) {
|
| unsigned char buffer[100];
|
| uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer));
|
| - MojoResult result = MojoReadMessage(
|
| - message_pipe_handle, buffer, &buffer_size, 0, 0, 0);
|
| + MojoResult result =
|
| + ReadMessageRaw(message_pipe_handle, buffer, &buffer_size, 0, 0, 0);
|
| if (result != MOJO_RESULT_OK)
|
| return;
|
| for (uint32_t i = 0; i < buffer_size; ++i)
|
| g_waste_accumulator += buffer[i];
|
| }
|
|
|
| -void CheckCorruptedEchoArgs(const js_to_cpp::EchoArgsPtr& arg) {
|
| +void CheckCorruptedEchoArgs(const js_to_cpp::blink::EchoArgsPtr& arg) {
|
| if (arg.is_null())
|
| return;
|
| CheckCorruptedString(arg->name);
|
| CheckCorruptedStringArray(arg->string_array);
|
| if (arg->data_handle.is_valid())
|
| - CheckCorruptedDataPipe(arg->data_handle.get().value());
|
| + CheckCorruptedDataPipe(arg->data_handle.get());
|
| if (arg->message_handle.is_valid())
|
| - CheckCorruptedMessagePipe(arg->message_handle.get().value());
|
| + CheckCorruptedMessagePipe(arg->message_handle.get());
|
| }
|
|
|
| -void CheckCorruptedEchoArgsList(const js_to_cpp::EchoArgsListPtr& list) {
|
| +void CheckCorruptedEchoArgsList(const js_to_cpp::blink::EchoArgsListPtr& list) {
|
| if (list.is_null())
|
| return;
|
| CheckCorruptedEchoArgs(list->item);
|
| @@ -207,22 +214,17 @@ void CheckCorruptedEchoArgsList(const js_to_cpp::EchoArgsListPtr& list) {
|
| // Base Provider implementation class. It's expected that tests subclass and
|
| // override the appropriate Provider functions. When test is done quit the
|
| // run_loop().
|
| -class CppSideConnection : public js_to_cpp::CppSide {
|
| +class CppSideConnection : public js_to_cpp::blink::CppSide {
|
| public:
|
| - CppSideConnection()
|
| - : run_loop_(nullptr),
|
| - js_side_(nullptr),
|
| - mishandled_messages_(0),
|
| - binding_(this) {}
|
| + CppSideConnection() : mishandled_messages_(0), binding_(this) {}
|
| ~CppSideConnection() override {}
|
|
|
| - void set_run_loop(base::RunLoop* run_loop) { run_loop_ = run_loop; }
|
| - base::RunLoop* run_loop() { return run_loop_; }
|
| -
|
| - void set_js_side(js_to_cpp::JsSide* js_side) { js_side_ = js_side; }
|
| - js_to_cpp::JsSide* js_side() { return js_side_; }
|
| + void set_js_side(js_to_cpp::blink::JsSidePtr js_side) {
|
| + js_side_ = std::move(js_side);
|
| + }
|
| + js_to_cpp::blink::JsSide* js_side() { return js_side_.get(); }
|
|
|
| - void Bind(InterfaceRequest<js_to_cpp::CppSide> request) {
|
| + void Bind(mojo::InterfaceRequest<js_to_cpp::blink::CppSide> request) {
|
| binding_.Bind(std::move(request));
|
| // Keep the pipe open even after validation errors.
|
| binding_.EnableTestingMode();
|
| @@ -235,28 +237,24 @@ class CppSideConnection : public js_to_cpp::CppSide {
|
|
|
| void PingResponse() override { mishandled_messages_ += 1; }
|
|
|
| - void EchoResponse(js_to_cpp::EchoArgsListPtr list) override {
|
| + void EchoResponse(js_to_cpp::blink::EchoArgsListPtr list) override {
|
| mishandled_messages_ += 1;
|
| }
|
|
|
| void BitFlipResponse(
|
| - js_to_cpp::EchoArgsListPtr list,
|
| - js_to_cpp::ForTestingAssociatedPtrInfo not_used) override {
|
| + js_to_cpp::blink::EchoArgsListPtr list,
|
| + js_to_cpp::blink::ForTestingAssociatedPtrInfo not_used) override {
|
| mishandled_messages_ += 1;
|
| }
|
|
|
| - void BackPointerResponse(js_to_cpp::EchoArgsListPtr list) override {
|
| + void BackPointerResponse(js_to_cpp::blink::EchoArgsListPtr list) override {
|
| mishandled_messages_ += 1;
|
| }
|
|
|
| protected:
|
| - base::RunLoop* run_loop_;
|
| - js_to_cpp::JsSide* js_side_;
|
| + js_to_cpp::blink::JsSidePtr js_side_;
|
| int mishandled_messages_;
|
| - mojo::Binding<js_to_cpp::CppSide> binding_;
|
| -
|
| - private:
|
| - DISALLOW_COPY_AND_ASSIGN(CppSideConnection);
|
| + mojo::Binding<js_to_cpp::blink::CppSide> binding_;
|
| };
|
|
|
| // Trivial test to verify a message sent from JS is received.
|
| @@ -270,25 +268,19 @@ class PingCppSideConnection : public CppSideConnection {
|
|
|
| void PingResponse() override {
|
| got_message_ = true;
|
| - run_loop()->Quit();
|
| + testing::ExitRunLoop();
|
| }
|
|
|
| - bool DidSucceed() {
|
| - return got_message_ && !mishandled_messages_;
|
| - }
|
| + bool DidSucceed() { return got_message_ && !mishandled_messages_; }
|
|
|
| private:
|
| bool got_message_;
|
| - DISALLOW_COPY_AND_ASSIGN(PingCppSideConnection);
|
| };
|
|
|
| // Test that parameters are passed with correct values.
|
| class EchoCppSideConnection : public CppSideConnection {
|
| public:
|
| - EchoCppSideConnection() :
|
| - message_count_(0),
|
| - termination_seen_(false) {
|
| - }
|
| + EchoCppSideConnection() : message_count_(0), termination_seen_(false) {}
|
| ~EchoCppSideConnection() override {}
|
|
|
| // js_to_cpp::CppSide:
|
| @@ -296,33 +288,35 @@ class EchoCppSideConnection : public CppSideConnection {
|
| js_side_->Echo(kExpectedMessageCount, BuildSampleEchoArgs());
|
| }
|
|
|
| - void EchoResponse(js_to_cpp::EchoArgsListPtr list) override {
|
| - const js_to_cpp::EchoArgsPtr& special_arg = list->item;
|
| + void EchoResponse(js_to_cpp::blink::EchoArgsListPtr list) override {
|
| message_count_ += 1;
|
| +
|
| + const js_to_cpp::blink::EchoArgsPtr& special_arg = list->item;
|
| EXPECT_EQ(-1, special_arg->si64);
|
| EXPECT_EQ(-1, special_arg->si32);
|
| EXPECT_EQ(-1, special_arg->si16);
|
| EXPECT_EQ(-1, special_arg->si8);
|
| - EXPECT_EQ(std::string("going"), *special_arg->name);
|
| + EXPECT_EQ(String("going"), special_arg->name);
|
| + CheckDataPipe(special_arg->data_handle.get());
|
| + CheckMessagePipe(special_arg->message_handle.get());
|
| +
|
| CheckSampleEchoArgsList(list->next);
|
| }
|
|
|
| void TestFinished() override {
|
| termination_seen_ = true;
|
| - run_loop()->Quit();
|
| + testing::ExitRunLoop();
|
| }
|
|
|
| bool DidSucceed() {
|
| - return termination_seen_ &&
|
| - !mishandled_messages_ &&
|
| - message_count_ == kExpectedMessageCount;
|
| + return termination_seen_ && !mishandled_messages_ &&
|
| + message_count_ == kExpectedMessageCount;
|
| }
|
|
|
| private:
|
| static const int kExpectedMessageCount = 10;
|
| int message_count_;
|
| bool termination_seen_;
|
| - DISALLOW_COPY_AND_ASSIGN(EchoCppSideConnection);
|
| };
|
|
|
| // Test that corrupted messages don't wreak havoc.
|
| @@ -335,23 +329,20 @@ class BitFlipCppSideConnection : public CppSideConnection {
|
| void StartTest() override { js_side_->BitFlip(BuildSampleEchoArgs()); }
|
|
|
| void BitFlipResponse(
|
| - js_to_cpp::EchoArgsListPtr list,
|
| - js_to_cpp::ForTestingAssociatedPtrInfo not_used) override {
|
| + js_to_cpp::blink::EchoArgsListPtr list,
|
| + js_to_cpp::blink::ForTestingAssociatedPtrInfo not_used) override {
|
| CheckCorruptedEchoArgsList(list);
|
| }
|
|
|
| void TestFinished() override {
|
| termination_seen_ = true;
|
| - run_loop()->Quit();
|
| + testing::ExitRunLoop();
|
| }
|
|
|
| - bool DidSucceed() {
|
| - return termination_seen_;
|
| - }
|
| + bool DidSucceed() { return termination_seen_; }
|
|
|
| private:
|
| bool termination_seen_;
|
| - DISALLOW_COPY_AND_ASSIGN(BitFlipCppSideConnection);
|
| };
|
|
|
| // Test that severely random messages don't wreak havoc.
|
| @@ -363,76 +354,62 @@ class BackPointerCppSideConnection : public CppSideConnection {
|
| // js_to_cpp::CppSide:
|
| void StartTest() override { js_side_->BackPointer(BuildSampleEchoArgs()); }
|
|
|
| - void BackPointerResponse(js_to_cpp::EchoArgsListPtr list) override {
|
| + void BackPointerResponse(js_to_cpp::blink::EchoArgsListPtr list) override {
|
| CheckCorruptedEchoArgsList(list);
|
| }
|
|
|
| void TestFinished() override {
|
| termination_seen_ = true;
|
| - run_loop()->Quit();
|
| + testing::ExitRunLoop();
|
| }
|
|
|
| - bool DidSucceed() {
|
| - return termination_seen_;
|
| - }
|
| + bool DidSucceed() { return termination_seen_; }
|
|
|
| private:
|
| bool termination_seen_;
|
| - DISALLOW_COPY_AND_ASSIGN(BackPointerCppSideConnection);
|
| };
|
|
|
| -} // namespace
|
| -
|
| -class JsToCppTest : public testing::Test {
|
| +class JsToCppTest : public ::testing::Test {
|
| public:
|
| - JsToCppTest() {}
|
| -
|
| - void RunTest(const std::string& test, CppSideConnection* cpp_side) {
|
| - cpp_side->set_run_loop(&run_loop_);
|
| -
|
| - js_to_cpp::JsSidePtr js_side;
|
| - auto js_side_proxy = MakeRequest(&js_side);
|
| -
|
| - cpp_side->set_js_side(js_side.get());
|
| - js_to_cpp::CppSidePtr cpp_side_ptr;
|
| + void RunTest(CppSideConnection* cpp_side) {
|
| + js_to_cpp::blink::CppSidePtr cpp_side_ptr;
|
| cpp_side->Bind(MakeRequest(&cpp_side_ptr));
|
|
|
| - js_side->SetCppSide(std::move(cpp_side_ptr));
|
| -
|
| -#ifdef V8_USE_EXTERNAL_STARTUP_DATA
|
| - gin::V8Initializer::LoadV8Snapshot();
|
| - gin::V8Initializer::LoadV8Natives();
|
| -#endif
|
| -
|
| - gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
|
| - gin::IsolateHolder::kStableV8Extras,
|
| - gin::ArrayBufferAllocator::SharedInstance());
|
| - gin::IsolateHolder instance(base::ThreadTaskRunnerHandle::Get());
|
| - MojoRunnerDelegate delegate;
|
| - gin::ShellRunner runner(&delegate, instance.isolate());
|
| - delegate.Start(&runner, js_side_proxy.PassMessagePipe().release().value(),
|
| - test);
|
| -
|
| - run_loop_.Run();
|
| + js_to_cpp::blink::JsSidePtr js_side_ptr;
|
| + auto js_side_request = MakeRequest(&js_side_ptr);
|
| + js_side_ptr->SetCppSide(std::move(cpp_side_ptr));
|
| + cpp_side->set_js_side(std::move(js_side_ptr));
|
| +
|
| + V8TestingScope scope;
|
| + scope.GetPage().GetSettings().SetScriptEnabled(true);
|
| + ExecuteScript(MojoBindingsScriptPath(), scope.GetFrame());
|
| + ExecuteScript(TestBindingsScriptPath(), scope.GetFrame());
|
| +
|
| + v8::Local<v8::Value> start_fn =
|
| + ExecuteScript(TestScriptPath(), scope.GetFrame());
|
| + ASSERT_FALSE(start_fn.IsEmpty());
|
| + ASSERT_TRUE(start_fn->IsFunction());
|
| + v8::Local<v8::Object> global_proxy = scope.GetContext()->Global();
|
| + v8::Local<v8::Value> args[1] = {
|
| + ToV8(MojoHandle::Create(
|
| + mojo::ScopedHandle::From(js_side_request.PassMessagePipe())),
|
| + global_proxy, scope.GetIsolate())};
|
| + V8ScriptRunner::CallFunction(
|
| + start_fn.As<v8::Function>(), scope.GetExecutionContext(), global_proxy,
|
| + WTF_ARRAY_LENGTH(args), args, scope.GetIsolate());
|
| + testing::EnterRunLoop();
|
| }
|
| -
|
| - private:
|
| - base::ShadowingAtExitManager at_exit_;
|
| - base::test::ScopedTaskEnvironment scoped_task_environment_;
|
| - base::RunLoop run_loop_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(JsToCppTest);
|
| };
|
|
|
| TEST_F(JsToCppTest, Ping) {
|
| PingCppSideConnection cpp_side_connection;
|
| - RunTest("mojo/edk/js/tests/js_to_cpp_tests", &cpp_side_connection);
|
| + RunTest(&cpp_side_connection);
|
| EXPECT_TRUE(cpp_side_connection.DidSucceed());
|
| }
|
|
|
| TEST_F(JsToCppTest, Echo) {
|
| EchoCppSideConnection cpp_side_connection;
|
| - RunTest("mojo/edk/js/tests/js_to_cpp_tests", &cpp_side_connection);
|
| + RunTest(&cpp_side_connection);
|
| EXPECT_TRUE(cpp_side_connection.DidSucceed());
|
| }
|
|
|
| @@ -441,7 +418,7 @@ TEST_F(JsToCppTest, BitFlip) {
|
| mojo::internal::ScopedSuppressValidationErrorLoggingForTests log_suppression;
|
|
|
| BitFlipCppSideConnection cpp_side_connection;
|
| - RunTest("mojo/edk/js/tests/js_to_cpp_tests", &cpp_side_connection);
|
| + RunTest(&cpp_side_connection);
|
| EXPECT_TRUE(cpp_side_connection.DidSucceed());
|
| }
|
|
|
| @@ -450,10 +427,9 @@ TEST_F(JsToCppTest, BackPointer) {
|
| mojo::internal::ScopedSuppressValidationErrorLoggingForTests log_suppression;
|
|
|
| BackPointerCppSideConnection cpp_side_connection;
|
| - RunTest("mojo/edk/js/tests/js_to_cpp_tests", &cpp_side_connection);
|
| + RunTest(&cpp_side_connection);
|
| EXPECT_TRUE(cpp_side_connection.DidSucceed());
|
| }
|
|
|
| -} // namespace js
|
| -} // namespace edk
|
| -} // namespace mojo
|
| +} // namespace
|
| +} // namespace blink
|
|
|