[Extensions] Implement suspicious extensions bubble on mac
[chromium-blink-merge.git] / gin / shell_runner_unittest.cc
blob340b673362f44dbc5e9155374d1d2386af9a9354
1 // Copyright 2014 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.
5 #include "gin/shell_runner.h"
7 #include "base/compiler_specific.h"
8 #include "gin/array_buffer.h"
9 #include "gin/converter.h"
10 #include "gin/public/isolate_holder.h"
11 #include "gin/v8_initializer.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
15 #include "gin/public/isolate_holder.h"
16 #endif
18 using v8::Isolate;
19 using v8::Object;
20 using v8::Script;
21 using v8::String;
23 namespace gin {
25 TEST(RunnerTest, Run) {
26 std::string source = "this.result = 'PASS';\n";
28 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
29 gin::V8Initializer::LoadV8Snapshot();
30 #endif
32 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
33 gin::ArrayBufferAllocator::SharedInstance());
34 gin::IsolateHolder instance;
36 ShellRunnerDelegate delegate;
37 Isolate* isolate = instance.isolate();
38 ShellRunner runner(&delegate, isolate);
39 Runner::Scope scope(&runner);
40 runner.Run(source, "test_data.js");
42 std::string result;
43 EXPECT_TRUE(Converter<std::string>::FromV8(isolate,
44 runner.global()->Get(StringToV8(isolate, "result")),
45 &result));
46 EXPECT_EQ("PASS", result);
49 } // namespace gin