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

Side by Side Diff: test/inspector/inspector-test.cc

Issue 2705533002: [inspector] remove iterators and for...of loops from injected-script-source (Closed)
Patch Set: rebase Created 3 years, 9 months 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
OLDNEW
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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 375
376 class InspectorExtension : public v8::Extension { 376 class InspectorExtension : public v8::Extension {
377 public: 377 public:
378 InspectorExtension() 378 InspectorExtension()
379 : v8::Extension("v8_inspector/inspector", 379 : v8::Extension("v8_inspector/inspector",
380 "native function attachInspector();" 380 "native function attachInspector();"
381 "native function detachInspector();" 381 "native function detachInspector();"
382 "native function setMaxAsyncTaskStacks();" 382 "native function setMaxAsyncTaskStacks();"
383 "native function breakProgram();" 383 "native function breakProgram();"
384 "native function createObjectWithStrictCheck();" 384 "native function createObjectWithStrictCheck();"
385 "native function callWithScheduledBreak();") {} 385 "native function callWithScheduledBreak();"
386 "native function allowAccessorFormatting();") {}
386 387
387 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( 388 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
388 v8::Isolate* isolate, v8::Local<v8::String> name) { 389 v8::Isolate* isolate, v8::Local<v8::String> name) {
389 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 390 v8::Local<v8::Context> context = isolate->GetCurrentContext();
390 if (name->Equals(context, 391 if (name->Equals(context,
391 v8::String::NewFromUtf8(isolate, "attachInspector", 392 v8::String::NewFromUtf8(isolate, "attachInspector",
392 v8::NewStringType::kNormal) 393 v8::NewStringType::kNormal)
393 .ToLocalChecked()) 394 .ToLocalChecked())
394 .FromJust()) { 395 .FromJust()) {
395 return v8::FunctionTemplate::New(isolate, InspectorExtension::Attach); 396 return v8::FunctionTemplate::New(isolate, InspectorExtension::Attach);
(...skipping 24 matching lines...) Expand all
420 .FromJust()) { 421 .FromJust()) {
421 return v8::FunctionTemplate::New( 422 return v8::FunctionTemplate::New(
422 isolate, InspectorExtension::CreateObjectWithStrictCheck); 423 isolate, InspectorExtension::CreateObjectWithStrictCheck);
423 } else if (name->Equals(context, v8::String::NewFromUtf8( 424 } else if (name->Equals(context, v8::String::NewFromUtf8(
424 isolate, "callWithScheduledBreak", 425 isolate, "callWithScheduledBreak",
425 v8::NewStringType::kNormal) 426 v8::NewStringType::kNormal)
426 .ToLocalChecked()) 427 .ToLocalChecked())
427 .FromJust()) { 428 .FromJust()) {
428 return v8::FunctionTemplate::New( 429 return v8::FunctionTemplate::New(
429 isolate, InspectorExtension::CallWithScheduledBreak); 430 isolate, InspectorExtension::CallWithScheduledBreak);
431 } else if (name->Equals(context, v8::String::NewFromUtf8(
432 isolate, "allowAccessorFormatting",
433 v8::NewStringType::kNormal)
434 .ToLocalChecked())
435 .FromJust()) {
436 return v8::FunctionTemplate::New(
437 isolate, InspectorExtension::AllowAccessorFormatting);
430 } 438 }
431 return v8::Local<v8::FunctionTemplate>(); 439 return v8::Local<v8::FunctionTemplate>();
432 } 440 }
433 441
434 private: 442 private:
435 static void Attach(const v8::FunctionCallbackInfo<v8::Value>& args) { 443 static void Attach(const v8::FunctionCallbackInfo<v8::Value>& args) {
436 v8::Isolate* isolate = args.GetIsolate(); 444 v8::Isolate* isolate = args.GetIsolate();
437 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 445 v8::Local<v8::Context> context = isolate->GetCurrentContext();
438 v8_inspector::V8Inspector* inspector = 446 v8_inspector::V8Inspector* inspector =
439 InspectorClientImpl::InspectorFromContext(context); 447 InspectorClientImpl::InspectorFromContext(context);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 v8_inspector::StringView reason_view(reason.start(), reason.length()); 526 v8_inspector::StringView reason_view(reason.start(), reason.length());
519 v8::internal::Vector<uint16_t> details = ToVector(args[2].As<v8::String>()); 527 v8::internal::Vector<uint16_t> details = ToVector(args[2].As<v8::String>());
520 v8_inspector::StringView details_view(details.start(), details.length()); 528 v8_inspector::StringView details_view(details.start(), details.length());
521 session->schedulePauseOnNextStatement(reason_view, details_view); 529 session->schedulePauseOnNextStatement(reason_view, details_view);
522 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); 530 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
523 v8::MaybeLocal<v8::Value> result; 531 v8::MaybeLocal<v8::Value> result;
524 result = args[0].As<v8::Function>()->Call(context, context->Global(), 0, 532 result = args[0].As<v8::Function>()->Call(context, context->Global(), 0,
525 nullptr); 533 nullptr);
526 session->cancelPauseOnNextStatement(); 534 session->cancelPauseOnNextStatement();
527 } 535 }
536
537 static void AllowAccessorFormatting(
538 const v8::FunctionCallbackInfo<v8::Value>& args) {
539 if (args.Length() != 1) {
kozy 2017/03/03 18:20:35 && args[0]->IsObject()
luoe 2017/03/03 18:56:21 Replaced the CHECK on L544 with a condition as you
540 fprintf(stderr, "Internal error: allowAccessorFormatting('object').");
541 Exit();
542 }
543 v8::Local<v8::Object> object = args[0].As<v8::Object>();
544 CHECK(object->IsObject());
545 v8::Isolate* isolate = args.GetIsolate();
546 v8::Local<v8::Private> shouldFormatAccessorsPrivate = v8::Private::ForApi(
547 isolate, v8::String::NewFromUtf8(isolate, "allowAccessorFormatting",
548 v8::NewStringType::kNormal)
549 .ToLocalChecked());
550 object
551 ->SetPrivate(isolate->GetCurrentContext(), shouldFormatAccessorsPrivate,
552 v8::Null(isolate))
553 .ToChecked();
554 }
528 }; 555 };
529 556
530 v8::Local<v8::String> ToString(v8::Isolate* isolate, 557 v8::Local<v8::String> ToString(v8::Isolate* isolate,
531 const v8_inspector::StringView& string) { 558 const v8_inspector::StringView& string) {
532 if (string.is8Bit()) 559 if (string.is8Bit())
533 return v8::String::NewFromOneByte(isolate, string.characters8(), 560 return v8::String::NewFromOneByte(isolate, string.characters8(),
534 v8::NewStringType::kNormal, 561 v8::NewStringType::kNormal,
535 static_cast<int>(string.length())) 562 static_cast<int>(string.length()))
536 .ToLocalChecked(); 563 .ToLocalChecked();
537 else 564 else
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 argv[i]); 657 argv[i]);
631 Exit(); 658 Exit();
632 } 659 }
633 frontend_runner.Append(new ExecuteStringTask(chars)); 660 frontend_runner.Append(new ExecuteStringTask(chars));
634 } 661 }
635 662
636 frontend_runner.Join(); 663 frontend_runner.Join();
637 backend_runner.Join(); 664 backend_runner.Join();
638 return 0; 665 return 0;
639 } 666 }
OLDNEW
« no previous file with comments | « test/inspector/inspector-impl.cc ('k') | test/inspector/runtime/evaluate-with-generate-preview.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698