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 20742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20753 CompileRun("1+1;"); | 20753 CompileRun("1+1;"); |
20754 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); | 20754 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); |
20755 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); | 20755 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); |
20756 | 20756 |
20757 CompileRun("1+1;"); | 20757 CompileRun("1+1;"); |
20758 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); | 20758 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); |
20759 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); | 20759 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); |
20760 } | 20760 } |
20761 | 20761 |
20762 | 20762 |
| 20763 static void MicrotaskExceptionOne( |
| 20764 const v8::FunctionCallbackInfo<Value>& info) { |
| 20765 v8::HandleScope scope(info.GetIsolate()); |
| 20766 CompileRun("exception1Calls++;"); |
| 20767 info.GetIsolate()->ThrowException( |
| 20768 v8::Exception::Error(v8_str("first"))); |
| 20769 } |
| 20770 |
| 20771 |
| 20772 static void MicrotaskExceptionTwo( |
| 20773 const v8::FunctionCallbackInfo<Value>& info) { |
| 20774 v8::HandleScope scope(info.GetIsolate()); |
| 20775 CompileRun("exception2Calls++;"); |
| 20776 info.GetIsolate()->ThrowException( |
| 20777 v8::Exception::Error(v8_str("second"))); |
| 20778 } |
| 20779 |
| 20780 |
| 20781 TEST(RunMicrotasksIgnoresThrownExceptions) { |
| 20782 LocalContext env; |
| 20783 v8::Isolate* isolate = env->GetIsolate(); |
| 20784 v8::HandleScope scope(isolate); |
| 20785 CompileRun( |
| 20786 "var exception1Calls = 0;" |
| 20787 "var exception2Calls = 0;"); |
| 20788 isolate->EnqueueMicrotask( |
| 20789 Function::New(isolate, MicrotaskExceptionOne)); |
| 20790 isolate->EnqueueMicrotask( |
| 20791 Function::New(isolate, MicrotaskExceptionTwo)); |
| 20792 TryCatch try_catch; |
| 20793 CompileRun("1+1;"); |
| 20794 CHECK(!try_catch.HasCaught()); |
| 20795 CHECK_EQ(1, CompileRun("exception1Calls")->Int32Value()); |
| 20796 CHECK_EQ(1, CompileRun("exception2Calls")->Int32Value()); |
| 20797 } |
| 20798 |
| 20799 |
20763 TEST(SetAutorunMicrotasks) { | 20800 TEST(SetAutorunMicrotasks) { |
20764 LocalContext env; | 20801 LocalContext env; |
20765 v8::HandleScope scope(env->GetIsolate()); | 20802 v8::HandleScope scope(env->GetIsolate()); |
20766 CompileRun( | 20803 CompileRun( |
20767 "var ext1Calls = 0;" | 20804 "var ext1Calls = 0;" |
20768 "var ext2Calls = 0;"); | 20805 "var ext2Calls = 0;"); |
20769 CompileRun("1+1;"); | 20806 CompileRun("1+1;"); |
20770 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value()); | 20807 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value()); |
20771 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value()); | 20808 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value()); |
20772 | 20809 |
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22626 Local<Script> script = v8::ScriptCompiler::Compile( | 22663 Local<Script> script = v8::ScriptCompiler::Compile( |
22627 isolate, &script_source); | 22664 isolate, &script_source); |
22628 Local<Value> script_name = script->GetUnboundScript()->GetScriptName(); | 22665 Local<Value> script_name = script->GetUnboundScript()->GetScriptName(); |
22629 CHECK(!script_name.IsEmpty()); | 22666 CHECK(!script_name.IsEmpty()); |
22630 CHECK(script_name->IsString()); | 22667 CHECK(script_name->IsString()); |
22631 String::Utf8Value utf8_name(script_name); | 22668 String::Utf8Value utf8_name(script_name); |
22632 CHECK_EQ(url, *utf8_name); | 22669 CHECK_EQ(url, *utf8_name); |
22633 int line_number = script->GetUnboundScript()->GetLineNumber(0); | 22670 int line_number = script->GetUnboundScript()->GetLineNumber(0); |
22634 CHECK_EQ(13, line_number); | 22671 CHECK_EQ(13, line_number); |
22635 } | 22672 } |
OLD | NEW |