OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/test/base/v8_unit_test.h" | 5 #include "chrome/test/base/v8_unit_test.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/message_loop/message_loop.h" | |
11 #include "base/path_service.h" | 10 #include "base/path_service.h" |
12 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
13 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
14 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
15 #include "third_party/WebKit/public/web/WebKit.h" | 14 #include "third_party/WebKit/public/web/WebKit.h" |
16 | 15 |
17 namespace { | 16 namespace { |
18 | 17 |
19 // |args| are passed through the various JavaScript logging functions such as | 18 // |args| are passed through the various JavaScript logging functions such as |
20 // console.log. Returns a string appropriate for logging with LOG(severity). | 19 // console.log. Returns a string appropriate for logging with LOG(severity). |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 error_function->RemovePrototype(); | 194 error_function->RemovePrototype(); |
196 console->Set(v8::String::NewFromUtf8(isolate, "error"), error_function); | 195 console->Set(v8::String::NewFromUtf8(isolate, "error"), error_function); |
197 { | 196 { |
198 v8::Local<v8::Context> context = context_.Get(isolate); | 197 v8::Local<v8::Context> context = context_.Get(isolate); |
199 v8::Context::Scope context_scope(context); | 198 v8::Context::Scope context_scope(context); |
200 context->Global() | 199 context->Global() |
201 ->Set(context, v8::String::NewFromUtf8(isolate, "console"), | 200 ->Set(context, v8::String::NewFromUtf8(isolate, "console"), |
202 console->NewInstance(context).ToLocalChecked()) | 201 console->NewInstance(context).ToLocalChecked()) |
203 .ToChecked(); | 202 .ToChecked(); |
204 } | 203 } |
205 | |
206 loop_ = base::MakeUnique<base::MessageLoop>(); | |
gab
2017/05/03 17:38:36
That's peculiar. Should check with owners if there
| |
207 } | 204 } |
208 | 205 |
209 void V8UnitTest::SetGlobalStringVar(const std::string& var_name, | 206 void V8UnitTest::SetGlobalStringVar(const std::string& var_name, |
210 const std::string& value) { | 207 const std::string& value) { |
211 v8::Isolate* isolate = blink::MainThreadIsolate(); | 208 v8::Isolate* isolate = blink::MainThreadIsolate(); |
212 v8::Local<v8::Context> context = | 209 v8::Local<v8::Context> context = |
213 v8::Local<v8::Context>::New(isolate, context_); | 210 v8::Local<v8::Context>::New(isolate, context_); |
214 v8::Context::Scope context_scope(context); | 211 v8::Context::Scope context_scope(context); |
215 context->Global()->Set( | 212 context->Global()->Set( |
216 v8::String::NewFromUtf8(isolate, | 213 v8::String::NewFromUtf8(isolate, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 v8::Local<v8::Array> test_result(args[1].As<v8::Array>()); | 320 v8::Local<v8::Array> test_result(args[1].As<v8::Array>()); |
324 EXPECT_EQ(2U, test_result->Length()); | 321 EXPECT_EQ(2U, test_result->Length()); |
325 if (::testing::Test::HasNonfatalFailure()) | 322 if (::testing::Test::HasNonfatalFailure()) |
326 return; | 323 return; |
327 g_test_result_ok = test_result->Get(0)->BooleanValue(); | 324 g_test_result_ok = test_result->Get(0)->BooleanValue(); |
328 if (!g_test_result_ok) { | 325 if (!g_test_result_ok) { |
329 v8::String::Utf8Value message(test_result->Get(1)); | 326 v8::String::Utf8Value message(test_result->Get(1)); |
330 LOG(ERROR) << *message; | 327 LOG(ERROR) << *message; |
331 } | 328 } |
332 } | 329 } |
OLD | NEW |