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

Side by Side Diff: test/cctest/test-debug.cc

Issue 812583003: Support tasks injection into a running VM. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« src/debug.cc ('K') | « src/debug.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 7378 matching lines...) Expand 10 before | Expand all | Expand 10 after
7389 CHECK_EQ(1, CountNativeContexts()); 7389 CHECK_EQ(1, CountNativeContexts());
7390 7390
7391 v8::Debug::SetDebugEventListener(NopListener); 7391 v8::Debug::SetDebugEventListener(NopListener);
7392 CompileRun("debugger;"); 7392 CompileRun("debugger;");
7393 CHECK_EQ(2, CountNativeContexts()); 7393 CHECK_EQ(2, CountNativeContexts());
7394 7394
7395 v8::Debug::SetDebugEventListener(NULL); 7395 v8::Debug::SetDebugEventListener(NULL);
7396 } 7396 }
7397 7397
7398 7398
7399 class DelayedTask : public v8::base::Thread {
7400 public:
7401 DelayedTask(v8::Isolate* isolate, v8::Debug::Task* task, int delay_ms)
7402 : Thread(Options("DelayedTask")),
7403 isolate_(isolate),
7404 task_(task),
7405 delay_ms_(delay_ms) {}
7406 void Run() override {
7407 v8::base::OS::Sleep(delay_ms_);
yurys 2014/12/17 14:25:03 We can avoid this Sleep. E.g. "while" loop below c
alph 2014/12/17 15:05:46 I would like to make sure the BreakAndRun is engag
7408 v8::Debug::BreakAndRun(isolate_, task_);
yurys 2014/12/17 14:25:03 task_ = NULL?
alph 2014/12/17 15:05:46 Done.
7409 }
7410
7411 private:
7412 v8::Isolate* isolate_;
7413 v8::Debug::Task* task_;
7414 int delay_ms_;
7415 };
7416
7417
7418 class StopExecutionTask : public v8::Debug::Task {
7419 public:
7420 explicit StopExecutionTask(LocalContext& context) : context_(context) {}
7421 void Run() override {
7422 context_->Global()->Set(v8_str("stop"), v8::True(context_->GetIsolate()));
yurys 2014/12/17 14:25:03 We can use a static C++ variable instead, it would
alph 2014/12/17 15:05:46 See my comment above. I'd like it to be a pure JS
7423 }
7424
7425 private:
7426 LocalContext& context_;
7427 };
7428
7429
7430 TEST(RunTaskWhileLooping) {
7431 LocalContext env;
7432 v8::HandleScope scope(env->GetIsolate());
7433
7434 v8::Debug::Task* task = new StopExecutionTask(env);
7435 DelayedTask delayed_task(env->GetIsolate(), task, 100);
yurys 2014/12/17 14:25:03 Or can we at least reduce the delay to 10 or somet
alph 2014/12/17 15:05:46 Acknowledged.
7436 CompileRun("var stop = false;");
7437 delayed_task.Start();
7438 CompileRun("while (!stop) {}");
7439 }
7440
7441
7399 TEST(LiveEditEnabled) { 7442 TEST(LiveEditEnabled) {
7400 v8::internal::FLAG_allow_natives_syntax = true; 7443 v8::internal::FLAG_allow_natives_syntax = true;
7401 LocalContext env; 7444 LocalContext env;
7402 v8::HandleScope scope(env->GetIsolate()); 7445 v8::HandleScope scope(env->GetIsolate());
7403 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true); 7446 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true);
7404 CompileRun("%LiveEditCompareStrings('', '')"); 7447 CompileRun("%LiveEditCompareStrings('', '')");
7405 } 7448 }
7406 7449
7407 7450
7408 TEST(LiveEditDisabled) { 7451 TEST(LiveEditDisabled) {
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
7672 "let y = 2; \n" 7715 "let y = 2; \n"
7673 "debugger; \n" 7716 "debugger; \n"
7674 "x * y", 7717 "x * y",
7675 30); 7718 30);
7676 ExpectInt32( 7719 ExpectInt32(
7677 "x = 1; y = 2; \n" 7720 "x = 1; y = 2; \n"
7678 "debugger;" 7721 "debugger;"
7679 "x * y", 7722 "x * y",
7680 30); 7723 30);
7681 } 7724 }
OLDNEW
« src/debug.cc ('K') | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698