Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1060)

Side by Side Diff: mojo/public/bindings/js/v8_runner_unittest.cc

Issue 59153005: Begin implementing V8 bindings for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix style nits Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/public/bindings/js/v8_runner.h"
6
7 #include "mojo/public/bindings/js/v8_string.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace mojo {
11 namespace js {
12 namespace {
13
14 std::string ReadGlobal(v8::Isolate* isolate,
15 v8::Handle<v8::Context> context,
16 std::string property) {
17 v8::Handle<v8::String> v8_property =
18 Wrapper<std::string>::ToObject(isolate, property);
19 return Wrapper<std::string>::ToNative(context->Global()->Get(v8_property));
20 }
21
22 TEST(Runner, Basic) {
23 std::string source =
24 "function main(mojo) {\n"
25 " if (mojo.createMessagePipe)\n"
26 " this.result = 'PASS';\n"
27 " else\n"
28 " this.result = 'FAIL';\n"
29 "}\n";
30
31 v8::Isolate* isolate = v8::Isolate::GetCurrent();
32 Runner runner(isolate);
33 Runner::Scope scope(&runner);
34 runner.Run(v8::Script::New(Wrapper<std::string>::ToObject(isolate, source)));
35
36 std::string result = ReadGlobal(isolate, runner.context(isolate), "result");
37 EXPECT_EQ("PASS", result);
38 }
39
40 } // namespace
41 } // namespace js
42 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698