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 { | |
Sven Panne
2014/12/18 14:53:31
Use OVERRIDE, not all our toolchains support overr
alph
2014/12/18 15:05:01
Done.
| |
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 { | |
Sven Panne
2014/12/18 14:53:31
Same here.
alph
2014/12/18 15:05:01
Done.
| |
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 // Delaying the task increases probability the task is injected while the | |
7432 // loop is already running. | |
Sven Panne
2014/12/18 14:53:31
Remove the comment, there's no delay anymore.
alph
2014/12/18 15:05:01
Done.
| |
7433 AsyncTask async_task(env->GetIsolate(), task); | |
7434 CompileRun("var stop = false;"); | |
7435 async_task.Start(); | |
7436 CompileRun("while (!stop) {}"); | |
Sven Panne
2014/12/18 14:53:31
Well, without any kind of handshake (via a native
alph
2014/12/18 15:05:01
Technically the test doesn't care what was the VM
| |
7437 } | |
7438 | |
7439 | |
7399 TEST(LiveEditEnabled) { | 7440 TEST(LiveEditEnabled) { |
7400 v8::internal::FLAG_allow_natives_syntax = true; | 7441 v8::internal::FLAG_allow_natives_syntax = true; |
7401 LocalContext env; | 7442 LocalContext env; |
7402 v8::HandleScope scope(env->GetIsolate()); | 7443 v8::HandleScope scope(env->GetIsolate()); |
7403 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true); | 7444 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true); |
7404 CompileRun("%LiveEditCompareStrings('', '')"); | 7445 CompileRun("%LiveEditCompareStrings('', '')"); |
7405 } | 7446 } |
7406 | 7447 |
7407 | 7448 |
7408 TEST(LiveEditDisabled) { | 7449 TEST(LiveEditDisabled) { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7672 "let y = 2; \n" | 7713 "let y = 2; \n" |
7673 "debugger; \n" | 7714 "debugger; \n" |
7674 "x * y", | 7715 "x * y", |
7675 30); | 7716 30); |
7676 ExpectInt32( | 7717 ExpectInt32( |
7677 "x = 1; y = 2; \n" | 7718 "x = 1; y = 2; \n" |
7678 "debugger;" | 7719 "debugger;" |
7679 "x * y", | 7720 "x * y", |
7680 30); | 7721 30); |
7681 } | 7722 } |
OLD | NEW |