OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project 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 #if !defined(_WIN32) && !defined(_WIN64) | 5 #if !defined(_WIN32) && !defined(_WIN64) |
6 #include <unistd.h> // NOLINT | 6 #include <unistd.h> // NOLINT |
7 #endif // !defined(_WIN32) && !defined(_WIN64) | 7 #endif // !defined(_WIN32) && !defined(_WIN64) |
8 | 8 |
9 #include <locale.h> | 9 #include <locale.h> |
10 | 10 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 } else { | 313 } else { |
314 task.reset(new ExecuteStringTask( | 314 task.reset(new ExecuteStringTask( |
315 ToVector(args[0].As<v8::String>()), v8::String::Empty(isolate), | 315 ToVector(args[0].As<v8::String>()), v8::String::Empty(isolate), |
316 v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0), | 316 v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0), |
317 v8::Boolean::New(isolate, false), "setTimeout", inspector)); | 317 v8::Boolean::New(isolate, false), "setTimeout", inspector)); |
318 } | 318 } |
319 TaskRunner::FromContext(context)->Append(task.release()); | 319 TaskRunner::FromContext(context)->Append(task.release()); |
320 } | 320 } |
321 }; | 321 }; |
322 | 322 |
| 323 bool StrictAccessCheck(v8::Local<v8::Context> accessing_context, |
| 324 v8::Local<v8::Object> accessed_object, |
| 325 v8::Local<v8::Value> data) { |
| 326 CHECK(accessing_context.IsEmpty()); |
| 327 return accessing_context.IsEmpty(); |
| 328 } |
| 329 |
323 class InspectorExtension : public v8::Extension { | 330 class InspectorExtension : public v8::Extension { |
324 public: | 331 public: |
325 InspectorExtension() | 332 InspectorExtension() |
326 : v8::Extension("v8_inspector/inspector", | 333 : v8::Extension("v8_inspector/inspector", |
327 "native function attachInspector();" | 334 "native function attachInspector();" |
328 "native function detachInspector();" | 335 "native function detachInspector();" |
329 "native function setMaxAsyncTaskStacks();" | 336 "native function setMaxAsyncTaskStacks();" |
330 "native function breakProgram();") {} | 337 "native function breakProgram();" |
| 338 "native function createObjectWithStrictCheck();") {} |
331 | 339 |
332 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | 340 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( |
333 v8::Isolate* isolate, v8::Local<v8::String> name) { | 341 v8::Isolate* isolate, v8::Local<v8::String> name) { |
334 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 342 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
335 if (name->Equals(context, | 343 if (name->Equals(context, |
336 v8::String::NewFromUtf8(isolate, "attachInspector", | 344 v8::String::NewFromUtf8(isolate, "attachInspector", |
337 v8::NewStringType::kNormal) | 345 v8::NewStringType::kNormal) |
338 .ToLocalChecked()) | 346 .ToLocalChecked()) |
339 .FromJust()) { | 347 .FromJust()) { |
340 return v8::FunctionTemplate::New(isolate, InspectorExtension::Attach); | 348 return v8::FunctionTemplate::New(isolate, InspectorExtension::Attach); |
(...skipping 10 matching lines...) Expand all Loading... |
351 .FromJust()) { | 359 .FromJust()) { |
352 return v8::FunctionTemplate::New( | 360 return v8::FunctionTemplate::New( |
353 isolate, InspectorExtension::SetMaxAsyncTaskStacks); | 361 isolate, InspectorExtension::SetMaxAsyncTaskStacks); |
354 } else if (name->Equals(context, | 362 } else if (name->Equals(context, |
355 v8::String::NewFromUtf8(isolate, "breakProgram", | 363 v8::String::NewFromUtf8(isolate, "breakProgram", |
356 v8::NewStringType::kNormal) | 364 v8::NewStringType::kNormal) |
357 .ToLocalChecked()) | 365 .ToLocalChecked()) |
358 .FromJust()) { | 366 .FromJust()) { |
359 return v8::FunctionTemplate::New(isolate, | 367 return v8::FunctionTemplate::New(isolate, |
360 InspectorExtension::BreakProgram); | 368 InspectorExtension::BreakProgram); |
| 369 } else if (name->Equals(context, v8::String::NewFromUtf8( |
| 370 isolate, "createObjectWithStrictCheck", |
| 371 v8::NewStringType::kNormal) |
| 372 .ToLocalChecked()) |
| 373 .FromJust()) { |
| 374 return v8::FunctionTemplate::New( |
| 375 isolate, InspectorExtension::CreateObjectWithStrictCheck); |
361 } | 376 } |
362 return v8::Local<v8::FunctionTemplate>(); | 377 return v8::Local<v8::FunctionTemplate>(); |
363 } | 378 } |
364 | 379 |
365 private: | 380 private: |
366 static void Attach(const v8::FunctionCallbackInfo<v8::Value>& args) { | 381 static void Attach(const v8::FunctionCallbackInfo<v8::Value>& args) { |
367 v8::Isolate* isolate = args.GetIsolate(); | 382 v8::Isolate* isolate = args.GetIsolate(); |
368 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 383 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
369 v8_inspector::V8Inspector* inspector = | 384 v8_inspector::V8Inspector* inspector = |
370 InspectorClientImpl::InspectorFromContext(context); | 385 InspectorClientImpl::InspectorFromContext(context); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 InspectorClientImpl::SessionFromContext( | 426 InspectorClientImpl::SessionFromContext( |
412 args.GetIsolate()->GetCurrentContext()); | 427 args.GetIsolate()->GetCurrentContext()); |
413 CHECK(session); | 428 CHECK(session); |
414 | 429 |
415 v8::internal::Vector<uint16_t> reason = ToVector(args[0].As<v8::String>()); | 430 v8::internal::Vector<uint16_t> reason = ToVector(args[0].As<v8::String>()); |
416 v8_inspector::StringView reason_view(reason.start(), reason.length()); | 431 v8_inspector::StringView reason_view(reason.start(), reason.length()); |
417 v8::internal::Vector<uint16_t> details = ToVector(args[1].As<v8::String>()); | 432 v8::internal::Vector<uint16_t> details = ToVector(args[1].As<v8::String>()); |
418 v8_inspector::StringView details_view(details.start(), details.length()); | 433 v8_inspector::StringView details_view(details.start(), details.length()); |
419 session->breakProgram(reason_view, details_view); | 434 session->breakProgram(reason_view, details_view); |
420 } | 435 } |
| 436 |
| 437 static void CreateObjectWithStrictCheck( |
| 438 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 439 if (args.Length() != 0) { |
| 440 fprintf(stderr, "Internal error: createObjectWithStrictCheck()."); |
| 441 Exit(); |
| 442 } |
| 443 v8::Local<v8::ObjectTemplate> templ = |
| 444 v8::ObjectTemplate::New(args.GetIsolate()); |
| 445 templ->SetAccessCheckCallback(&StrictAccessCheck); |
| 446 args.GetReturnValue().Set( |
| 447 templ->NewInstance(args.GetIsolate()->GetCurrentContext()) |
| 448 .ToLocalChecked()); |
| 449 } |
421 }; | 450 }; |
422 | 451 |
423 v8::Local<v8::String> ToString(v8::Isolate* isolate, | 452 v8::Local<v8::String> ToString(v8::Isolate* isolate, |
424 const v8_inspector::StringView& string) { | 453 const v8_inspector::StringView& string) { |
425 if (string.is8Bit()) | 454 if (string.is8Bit()) |
426 return v8::String::NewFromOneByte(isolate, string.characters8(), | 455 return v8::String::NewFromOneByte(isolate, string.characters8(), |
427 v8::NewStringType::kNormal, | 456 v8::NewStringType::kNormal, |
428 static_cast<int>(string.length())) | 457 static_cast<int>(string.length())) |
429 .ToLocalChecked(); | 458 .ToLocalChecked(); |
430 else | 459 else |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 argv[i]); | 552 argv[i]); |
524 Exit(); | 553 Exit(); |
525 } | 554 } |
526 frontend_runner.Append(new ExecuteStringTask(chars)); | 555 frontend_runner.Append(new ExecuteStringTask(chars)); |
527 } | 556 } |
528 | 557 |
529 frontend_runner.Join(); | 558 frontend_runner.Join(); |
530 backend_runner.Join(); | 559 backend_runner.Join(); |
531 return 0; | 560 return 0; |
532 } | 561 } |
OLD | NEW |