Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: test/cctest/test-api.cc

Issue 203223013: Introduce API to trigger exception on JS execution. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« include/v8.h ('K') | « src/execution.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« include/v8.h ('K') | « src/execution.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698