| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 CHECK(v8::V8::IsExecutionTerminating()); | 317 CHECK(v8::V8::IsExecutionTerminating()); |
| 318 CHECK(try_catch.HasTerminated()); | 318 CHECK(try_catch.HasTerminated()); |
| 319 v8::V8::CancelTerminateExecution(v8::Isolate::GetCurrent()); | 319 v8::V8::CancelTerminateExecution(v8::Isolate::GetCurrent()); |
| 320 CHECK(!v8::V8::IsExecutionTerminating()); | 320 CHECK(!v8::V8::IsExecutionTerminating()); |
| 321 } | 321 } |
| 322 | 322 |
| 323 | 323 |
| 324 // Test that a single thread of JavaScript execution can terminate | 324 // Test that a single thread of JavaScript execution can terminate |
| 325 // itself and then resume execution. | 325 // itself and then resume execution. |
| 326 TEST(TerminateCancelTerminateFromThreadItself) { | 326 TEST(TerminateCancelTerminateFromThreadItself) { |
| 327 v8::HandleScope scope; | 327 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 328 v8::HandleScope scope(isolate); |
| 328 v8::Handle<v8::ObjectTemplate> global = | 329 v8::Handle<v8::ObjectTemplate> global = |
| 329 CreateGlobalTemplate(TerminateCurrentThread, DoLoopCancelTerminate); | 330 CreateGlobalTemplate(TerminateCurrentThread, DoLoopCancelTerminate); |
| 330 v8::Handle<v8::Context> context = | 331 v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global); |
| 331 v8::Context::New(v8::Isolate::GetCurrent(), NULL, global); | |
| 332 v8::Context::Scope context_scope(context); | 332 v8::Context::Scope context_scope(context); |
| 333 CHECK(!v8::V8::IsExecutionTerminating()); | 333 CHECK(!v8::V8::IsExecutionTerminating()); |
| 334 v8::Handle<v8::String> source = | 334 v8::Handle<v8::String> source = |
| 335 v8::String::New("try { doloop(); } catch(e) { fail(); } 'completed';"); | 335 v8::String::New("try { doloop(); } catch(e) { fail(); } 'completed';"); |
| 336 // Check that execution completed with correct return value. | 336 // Check that execution completed with correct return value. |
| 337 CHECK(v8::Script::Compile(source)->Run()->Equals(v8_str("completed"))); | 337 CHECK(v8::Script::Compile(source)->Run()->Equals(v8_str("completed"))); |
| 338 } | 338 } |
| 339 | |
| OLD | NEW |