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 AsyncTask : public v8::base::Thread { |
| 7400 public: |
| 7401 AsyncTask(v8::Isolate* isolate, v8::Task* task) |
| 7402 : Thread(Options("AsyncTask")), isolate_(isolate), task_(task) {} |
| 7403 void Run() OVERRIDE { |
| 7404 v8::Debug::BreakAndRun(isolate_, task_); |
| 7405 task_ = NULL; |
| 7406 } |
| 7407 |
| 7408 private: |
| 7409 v8::Isolate* isolate_; |
| 7410 v8::Task* task_; |
| 7411 }; |
| 7412 |
| 7413 |
| 7414 class StopExecutionTask : public v8::Task { |
| 7415 public: |
| 7416 explicit StopExecutionTask(LocalContext& context) : context_(context) {} |
| 7417 void Run() OVERRIDE { |
| 7418 context_->Global()->Set(v8_str("stop"), v8::True(context_->GetIsolate())); |
| 7419 } |
| 7420 |
| 7421 private: |
| 7422 LocalContext& context_; |
| 7423 }; |
| 7424 |
| 7425 |
| 7426 TEST(RunTaskWhileLooping) { |
| 7427 LocalContext env; |
| 7428 v8::HandleScope scope(env->GetIsolate()); |
| 7429 |
| 7430 v8::Task* task = new StopExecutionTask(env); |
| 7431 AsyncTask async_task(env->GetIsolate(), task); |
| 7432 CompileRun("var stop = false;"); |
| 7433 async_task.Start(); |
| 7434 CompileRun("while (!stop) {}"); |
| 7435 } |
| 7436 |
| 7437 |
7399 TEST(LiveEditEnabled) { | 7438 TEST(LiveEditEnabled) { |
7400 v8::internal::FLAG_allow_natives_syntax = true; | 7439 v8::internal::FLAG_allow_natives_syntax = true; |
7401 LocalContext env; | 7440 LocalContext env; |
7402 v8::HandleScope scope(env->GetIsolate()); | 7441 v8::HandleScope scope(env->GetIsolate()); |
7403 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true); | 7442 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true); |
7404 CompileRun("%LiveEditCompareStrings('', '')"); | 7443 CompileRun("%LiveEditCompareStrings('', '')"); |
7405 } | 7444 } |
7406 | 7445 |
7407 | 7446 |
7408 TEST(LiveEditDisabled) { | 7447 TEST(LiveEditDisabled) { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7672 "let y = 2; \n" | 7711 "let y = 2; \n" |
7673 "debugger; \n" | 7712 "debugger; \n" |
7674 "x * y", | 7713 "x * y", |
7675 30); | 7714 30); |
7676 ExpectInt32( | 7715 ExpectInt32( |
7677 "x = 1; y = 2; \n" | 7716 "x = 1; y = 2; \n" |
7678 "debugger;" | 7717 "debugger;" |
7679 "x * y", | 7718 "x * y", |
7680 30); | 7719 30); |
7681 } | 7720 } |
OLD | NEW |