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

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: Added a comment. 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.h ('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_);
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 // Delaying the task increases probability the task is injected while the
Benedikt Meurer 2014/12/18 04:11:57 This is rather fragile. Can we have a more robust
Sven Panne 2014/12/18 08:27:51 I would even go a step further: Without proper syn
alph 2014/12/18 14:28:03 This test case it robust. It does not fail/flake d
alph 2014/12/18 14:28:03 Again, this Sleep does not lead to flakiness. Ther
7437 // loop is already running.
7438 DelayedTask delayed_task(env->GetIsolate(), task, 10);
7439 CompileRun("var stop = false;");
7440 delayed_task.Start();
7441 CompileRun("while (!stop) {}");
7442 }
7443
7444
7399 TEST(LiveEditEnabled) { 7445 TEST(LiveEditEnabled) {
7400 v8::internal::FLAG_allow_natives_syntax = true; 7446 v8::internal::FLAG_allow_natives_syntax = true;
7401 LocalContext env; 7447 LocalContext env;
7402 v8::HandleScope scope(env->GetIsolate()); 7448 v8::HandleScope scope(env->GetIsolate());
7403 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true); 7449 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true);
7404 CompileRun("%LiveEditCompareStrings('', '')"); 7450 CompileRun("%LiveEditCompareStrings('', '')");
7405 } 7451 }
7406 7452
7407 7453
7408 TEST(LiveEditDisabled) { 7454 TEST(LiveEditDisabled) {
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
7672 "let y = 2; \n" 7718 "let y = 2; \n"
7673 "debugger; \n" 7719 "debugger; \n"
7674 "x * y", 7720 "x * y",
7675 30); 7721 30);
7676 ExpectInt32( 7722 ExpectInt32(
7677 "x = 1; y = 2; \n" 7723 "x = 1; y = 2; \n"
7678 "debugger;" 7724 "debugger;"
7679 "x * y", 7725 "x * y",
7680 30); 7726 30);
7681 } 7727 }
OLDNEW
« src/debug.h ('K') | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698