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

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: Addressing comments. 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
« no previous file with comments | « 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_);
7408 v8::Debug::BreakAndRun(isolate_, task_);
7409 task_ = NULL;
7410 }
7411
7412 private:
7413 v8::Isolate* isolate_;
7414 v8::Debug::Task* task_;
7415 int delay_ms_;
7416 };
7417
7418
7419 class StopExecutionTask : public v8::Debug::Task {
7420 public:
7421 explicit StopExecutionTask(LocalContext& context) : context_(context) {}
7422 void Run() override {
7423 context_->Global()->Set(v8_str("stop"), v8::True(context_->GetIsolate()));
7424 }
7425
7426 private:
7427 LocalContext& context_;
7428 };
7429
7430
7431 TEST(RunTaskWhileLooping) {
7432 LocalContext env;
7433 v8::HandleScope scope(env->GetIsolate());
7434
7435 v8::Debug::Task* task = new StopExecutionTask(env);
7436 DelayedTask delayed_task(env->GetIsolate(), task, 10);
yurys 2014/12/17 15:29:09 Please add a comment on why we need the delay.
7437 CompileRun("var stop = false;");
7438 delayed_task.Start();
7439 CompileRun("while (!stop) {}");
7440 }
7441
7442
7399 TEST(LiveEditEnabled) { 7443 TEST(LiveEditEnabled) {
7400 v8::internal::FLAG_allow_natives_syntax = true; 7444 v8::internal::FLAG_allow_natives_syntax = true;
7401 LocalContext env; 7445 LocalContext env;
7402 v8::HandleScope scope(env->GetIsolate()); 7446 v8::HandleScope scope(env->GetIsolate());
7403 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true); 7447 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true);
7404 CompileRun("%LiveEditCompareStrings('', '')"); 7448 CompileRun("%LiveEditCompareStrings('', '')");
7405 } 7449 }
7406 7450
7407 7451
7408 TEST(LiveEditDisabled) { 7452 TEST(LiveEditDisabled) {
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
7672 "let y = 2; \n" 7716 "let y = 2; \n"
7673 "debugger; \n" 7717 "debugger; \n"
7674 "x * y", 7718 "x * y",
7675 30); 7719 30);
7676 ExpectInt32( 7720 ExpectInt32(
7677 "x = 1; y = 2; \n" 7721 "x = 1; y = 2; \n"
7678 "debugger;" 7722 "debugger;"
7679 "x * y", 7723 "x * y",
7680 30); 7724 30);
7681 } 7725 }
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698