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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 CHECK(v8::V8::IsExecutionTerminating()); | 384 CHECK(v8::V8::IsExecutionTerminating()); |
385 CHECK(try_catch.HasTerminated()); | 385 CHECK(try_catch.HasTerminated()); |
386 v8::V8::CancelTerminateExecution(v8::Isolate::GetCurrent()); | 386 v8::V8::CancelTerminateExecution(v8::Isolate::GetCurrent()); |
387 CHECK(!v8::V8::IsExecutionTerminating()); | 387 CHECK(!v8::V8::IsExecutionTerminating()); |
388 } | 388 } |
389 | 389 |
390 | 390 |
391 // Test that a single thread of JavaScript execution can terminate | 391 // Test that a single thread of JavaScript execution can terminate |
392 // itself and then resume execution. | 392 // itself and then resume execution. |
393 TEST(TerminateCancelTerminateFromThreadItself) { | 393 TEST(TerminateCancelTerminateFromThreadItself) { |
394 v8::HandleScope scope; | 394 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 395 v8::HandleScope scope(isolate); |
395 v8::Handle<v8::ObjectTemplate> global = | 396 v8::Handle<v8::ObjectTemplate> global = |
396 CreateGlobalTemplate(TerminateCurrentThread, DoLoopCancelTerminate); | 397 CreateGlobalTemplate(TerminateCurrentThread, DoLoopCancelTerminate); |
397 v8::Handle<v8::Context> context = | 398 v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global); |
398 v8::Context::New(v8::Isolate::GetCurrent(), NULL, global); | |
399 v8::Context::Scope context_scope(context); | 399 v8::Context::Scope context_scope(context); |
400 CHECK(!v8::V8::IsExecutionTerminating()); | 400 CHECK(!v8::V8::IsExecutionTerminating()); |
401 v8::Handle<v8::String> source = | 401 v8::Handle<v8::String> source = |
402 v8::String::New("try { doloop(); } catch(e) { fail(); } 'completed';"); | 402 v8::String::New("try { doloop(); } catch(e) { fail(); } 'completed';"); |
403 // Check that execution completed with correct return value. | 403 // Check that execution completed with correct return value. |
404 CHECK(v8::Script::Compile(source)->Run()->Equals(v8_str("completed"))); | 404 CHECK(v8::Script::Compile(source)->Run()->Equals(v8_str("completed"))); |
405 } | 405 } |
406 | |
OLD | NEW |