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 22381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22392 V8::RunMicrotasks(isolate); | 22392 V8::RunMicrotasks(isolate); |
22393 CHECK_EQ(3, global->Get(v8_str("x1"))->Int32Value()); | 22393 CHECK_EQ(3, global->Get(v8_str("x1"))->Int32Value()); |
22394 CHECK_EQ(4, global->Get(v8_str("x2"))->Int32Value()); | 22394 CHECK_EQ(4, global->Get(v8_str("x2"))->Int32Value()); |
22395 } | 22395 } |
22396 | 22396 |
22397 | 22397 |
22398 TEST(DisallowJavascriptExecutionScope) { | 22398 TEST(DisallowJavascriptExecutionScope) { |
22399 LocalContext context; | 22399 LocalContext context; |
22400 v8::Isolate* isolate = context->GetIsolate(); | 22400 v8::Isolate* isolate = context->GetIsolate(); |
22401 v8::HandleScope scope(isolate); | 22401 v8::HandleScope scope(isolate); |
22402 v8::Isolate::DisallowJavascriptExecutionScope no_js(isolate); | 22402 v8::Isolate::DisallowJavascriptExecutionScope no_js( |
| 22403 isolate, v8::Isolate::DisallowJavascriptExecutionScope::CRASH_ON_FAILURE); |
22403 CompileRun("2+2"); | 22404 CompileRun("2+2"); |
22404 } | 22405 } |
22405 | 22406 |
22406 | 22407 |
22407 TEST(AllowJavascriptExecutionScope) { | 22408 TEST(AllowJavascriptExecutionScope) { |
22408 LocalContext context; | 22409 LocalContext context; |
22409 v8::Isolate* isolate = context->GetIsolate(); | 22410 v8::Isolate* isolate = context->GetIsolate(); |
22410 v8::HandleScope scope(isolate); | 22411 v8::HandleScope scope(isolate); |
22411 v8::Isolate::DisallowJavascriptExecutionScope no_js(isolate); | 22412 v8::Isolate::DisallowJavascriptExecutionScope no_js( |
| 22413 isolate, v8::Isolate::DisallowJavascriptExecutionScope::CRASH_ON_FAILURE); |
| 22414 v8::Isolate::DisallowJavascriptExecutionScope throw_js( |
| 22415 isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); |
22412 { v8::Isolate::AllowJavascriptExecutionScope yes_js(isolate); | 22416 { v8::Isolate::AllowJavascriptExecutionScope yes_js(isolate); |
22413 CompileRun("1+1"); | 22417 CompileRun("1+1"); |
22414 } | 22418 } |
22415 } | 22419 } |
| 22420 |
| 22421 |
| 22422 TEST(ThrowOnJavascriptExecution) { |
| 22423 LocalContext context; |
| 22424 v8::Isolate* isolate = context->GetIsolate(); |
| 22425 v8::HandleScope scope(isolate); |
| 22426 v8::TryCatch try_catch; |
| 22427 v8::Isolate::DisallowJavascriptExecutionScope throw_js( |
| 22428 isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); |
| 22429 CompileRun("1+1"); |
| 22430 CHECK(try_catch.HasCaught()); |
| 22431 } |
OLD | NEW |