Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 } |
| OLD | NEW |