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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 165 |
166 private: | 166 private: |
167 v8::Isolate* isolate_; | 167 v8::Isolate* isolate_; |
168 }; | 168 }; |
169 | 169 |
170 | 170 |
171 // Test that a single thread of JavaScript execution can be terminated | 171 // Test that a single thread of JavaScript execution can be terminated |
172 // from the side by another thread. | 172 // from the side by another thread. |
173 TEST(TerminateOnlyV8ThreadFromOtherThread) { | 173 TEST(TerminateOnlyV8ThreadFromOtherThread) { |
174 semaphore = new v8::internal::Semaphore(0); | 174 semaphore = new v8::internal::Semaphore(0); |
175 TerminatorThread thread(i::Isolate::Current()); | 175 TerminatorThread thread(CcTest::i_isolate()); |
176 thread.Start(); | 176 thread.Start(); |
177 | 177 |
178 v8::HandleScope scope(CcTest::isolate()); | 178 v8::HandleScope scope(CcTest::isolate()); |
179 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(Signal, DoLoop); | 179 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(Signal, DoLoop); |
180 v8::Handle<v8::Context> context = | 180 v8::Handle<v8::Context> context = |
181 v8::Context::New(CcTest::isolate(), NULL, global); | 181 v8::Context::New(CcTest::isolate(), NULL, global); |
182 v8::Context::Scope context_scope(context); | 182 v8::Context::Scope context_scope(context); |
183 CHECK(!v8::V8::IsExecutionTerminating()); | 183 CHECK(!v8::V8::IsExecutionTerminating()); |
184 // Run a loop that will be infinite if thread termination does not work. | 184 // Run a loop that will be infinite if thread termination does not work. |
185 v8::Handle<v8::String> source = | 185 v8::Handle<v8::String> source = |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 v8::Handle<v8::ObjectTemplate> global = | 329 v8::Handle<v8::ObjectTemplate> global = |
330 CreateGlobalTemplate(TerminateCurrentThread, DoLoopCancelTerminate); | 330 CreateGlobalTemplate(TerminateCurrentThread, DoLoopCancelTerminate); |
331 v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global); | 331 v8::Handle<v8::Context> context = v8::Context::New(isolate, 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 } |
OLD | NEW |