| 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 4021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4032 CompileRun("throw error;"); | 4032 CompileRun("throw error;"); |
| 4033 CHECK(message_received); | 4033 CHECK(message_received); |
| 4034 // clear out the message listener | 4034 // clear out the message listener |
| 4035 v8::V8::RemoveMessageListeners(check_message_2); | 4035 v8::V8::RemoveMessageListeners(check_message_2); |
| 4036 } | 4036 } |
| 4037 | 4037 |
| 4038 | 4038 |
| 4039 static void check_message_3(v8::Handle<v8::Message> message, | 4039 static void check_message_3(v8::Handle<v8::Message> message, |
| 4040 v8::Handle<Value> data) { | 4040 v8::Handle<Value> data) { |
| 4041 CHECK(message->IsSharedCrossOrigin()); | 4041 CHECK(message->IsSharedCrossOrigin()); |
| 4042 CHECK(message->GetScriptOrigin().ResourceIsSharedCrossOrigin()->Value()); | 4042 CHECK(message->GetScriptOrigin().Options().IsSharedCrossOrigin()); |
| 4043 CHECK(message->GetScriptOrigin().ResourceIsEmbedderDebugScript()->Value()); | 4043 CHECK(message->GetScriptOrigin().Options().IsEmbedderDebugScript()); |
| 4044 CHECK(message->GetScriptOrigin().Options().IsOpaque()); |
| 4044 CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue()); | 4045 CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue()); |
| 4045 CHECK_EQ(7.40, message->GetScriptOrigin().SourceMapUrl()->NumberValue()); | 4046 CHECK_EQ(7.40, message->GetScriptOrigin().SourceMapUrl()->NumberValue()); |
| 4046 message_received = true; | 4047 message_received = true; |
| 4047 } | 4048 } |
| 4048 | 4049 |
| 4049 | 4050 |
| 4050 TEST(MessageHandler3) { | 4051 TEST(MessageHandler3) { |
| 4051 message_received = false; | 4052 message_received = false; |
| 4052 v8::Isolate* isolate = CcTest::isolate(); | 4053 v8::Isolate* isolate = CcTest::isolate(); |
| 4053 v8::HandleScope scope(isolate); | 4054 v8::HandleScope scope(isolate); |
| 4054 CHECK(!message_received); | 4055 CHECK(!message_received); |
| 4055 v8::V8::AddMessageListener(check_message_3); | 4056 v8::V8::AddMessageListener(check_message_3); |
| 4056 LocalContext context; | 4057 LocalContext context; |
| 4057 v8::ScriptOrigin origin = v8::ScriptOrigin( | 4058 v8::ScriptOrigin origin = v8::ScriptOrigin( |
| 4058 v8_str("6.75"), v8::Integer::New(isolate, 1), | 4059 v8_str("6.75"), v8::Integer::New(isolate, 1), |
| 4059 v8::Integer::New(isolate, 2), v8::True(isolate), Handle<v8::Integer>(), | 4060 v8::Integer::New(isolate, 2), v8::True(isolate), Handle<v8::Integer>(), |
| 4060 v8::True(isolate), v8_str("7.40")); | 4061 v8::True(isolate), v8_str("7.40"), v8::True(isolate)); |
| 4061 v8::Handle<v8::Script> script = | 4062 v8::Handle<v8::Script> script = |
| 4062 Script::Compile(v8_str("throw 'error'"), &origin); | 4063 Script::Compile(v8_str("throw 'error'"), &origin); |
| 4063 script->Run(); | 4064 script->Run(); |
| 4064 CHECK(message_received); | 4065 CHECK(message_received); |
| 4065 // clear out the message listener | 4066 // clear out the message listener |
| 4066 v8::V8::RemoveMessageListeners(check_message_3); | 4067 v8::V8::RemoveMessageListeners(check_message_3); |
| 4067 } | 4068 } |
| 4068 | 4069 |
| 4069 | 4070 |
| 4070 static void check_message_4(v8::Handle<v8::Message> message, | 4071 static void check_message_4(v8::Handle<v8::Message> message, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4110 } | 4111 } |
| 4111 | 4112 |
| 4112 | 4113 |
| 4113 TEST(MessageHandler5) { | 4114 TEST(MessageHandler5) { |
| 4114 message_received = false; | 4115 message_received = false; |
| 4115 v8::Isolate* isolate = CcTest::isolate(); | 4116 v8::Isolate* isolate = CcTest::isolate(); |
| 4116 v8::HandleScope scope(isolate); | 4117 v8::HandleScope scope(isolate); |
| 4117 CHECK(!message_received); | 4118 CHECK(!message_received); |
| 4118 v8::V8::AddMessageListener(check_message_5a); | 4119 v8::V8::AddMessageListener(check_message_5a); |
| 4119 LocalContext context; | 4120 LocalContext context; |
| 4120 v8::ScriptOrigin origin = | 4121 v8::ScriptOrigin origin1 = |
| 4121 v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1), | 4122 v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1), |
| 4122 v8::Integer::New(isolate, 2), v8::True(isolate)); | 4123 v8::Integer::New(isolate, 2), v8::True(isolate)); |
| 4123 v8::Handle<v8::Script> script = | 4124 v8::Handle<v8::Script> script = |
| 4124 Script::Compile(v8_str("throw 'error'"), &origin); | 4125 Script::Compile(v8_str("throw 'error'"), &origin1); |
| 4125 script->Run(); | 4126 script->Run(); |
| 4126 CHECK(message_received); | 4127 CHECK(message_received); |
| 4127 // clear out the message listener | 4128 // clear out the message listener |
| 4128 v8::V8::RemoveMessageListeners(check_message_5a); | 4129 v8::V8::RemoveMessageListeners(check_message_5a); |
| 4129 | 4130 |
| 4130 message_received = false; | 4131 message_received = false; |
| 4131 v8::V8::AddMessageListener(check_message_5b); | 4132 v8::V8::AddMessageListener(check_message_5b); |
| 4132 origin = v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1), | 4133 v8::ScriptOrigin origin2 = |
| 4133 v8::Integer::New(isolate, 2), v8::False(isolate)); | 4134 v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1), |
| 4134 script = Script::Compile(v8_str("throw 'error'"), &origin); | 4135 v8::Integer::New(isolate, 2), v8::False(isolate)); |
| 4136 script = Script::Compile(v8_str("throw 'error'"), &origin2); |
| 4135 script->Run(); | 4137 script->Run(); |
| 4136 CHECK(message_received); | 4138 CHECK(message_received); |
| 4137 // clear out the message listener | 4139 // clear out the message listener |
| 4138 v8::V8::RemoveMessageListeners(check_message_5b); | 4140 v8::V8::RemoveMessageListeners(check_message_5b); |
| 4139 } | 4141 } |
| 4140 | 4142 |
| 4141 | 4143 |
| 4142 TEST(NativeWeakMap) { | 4144 TEST(NativeWeakMap) { |
| 4143 v8::Isolate* isolate = CcTest::isolate(); | 4145 v8::Isolate* isolate = CcTest::isolate(); |
| 4144 HandleScope scope(isolate); | 4146 HandleScope scope(isolate); |
| (...skipping 11459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15604 | 15606 |
| 15605 | 15607 |
| 15606 THREADED_TEST(ScriptOrigin) { | 15608 THREADED_TEST(ScriptOrigin) { |
| 15607 LocalContext env; | 15609 LocalContext env; |
| 15608 v8::HandleScope scope(env->GetIsolate()); | 15610 v8::HandleScope scope(env->GetIsolate()); |
| 15609 v8::ScriptOrigin origin = v8::ScriptOrigin( | 15611 v8::ScriptOrigin origin = v8::ScriptOrigin( |
| 15610 v8::String::NewFromUtf8(env->GetIsolate(), "test"), | 15612 v8::String::NewFromUtf8(env->GetIsolate(), "test"), |
| 15611 v8::Integer::New(env->GetIsolate(), 1), | 15613 v8::Integer::New(env->GetIsolate(), 1), |
| 15612 v8::Integer::New(env->GetIsolate(), 1), v8::True(env->GetIsolate()), | 15614 v8::Integer::New(env->GetIsolate(), 1), v8::True(env->GetIsolate()), |
| 15613 v8::Handle<v8::Integer>(), v8::True(env->GetIsolate()), | 15615 v8::Handle<v8::Integer>(), v8::True(env->GetIsolate()), |
| 15614 v8::String::NewFromUtf8(env->GetIsolate(), "http://sourceMapUrl")); | 15616 v8::String::NewFromUtf8(env->GetIsolate(), "http://sourceMapUrl"), |
| 15617 v8::True(env->GetIsolate())); |
| 15615 v8::Handle<v8::String> script = v8::String::NewFromUtf8( | 15618 v8::Handle<v8::String> script = v8::String::NewFromUtf8( |
| 15616 env->GetIsolate(), "function f() {}\n\nfunction g() {}"); | 15619 env->GetIsolate(), "function f() {}\n\nfunction g() {}"); |
| 15617 v8::Script::Compile(script, &origin)->Run(); | 15620 v8::Script::Compile(script, &origin)->Run(); |
| 15618 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 15621 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
| 15619 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); | 15622 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
| 15620 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 15623 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
| 15621 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); | 15624 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
| 15622 | 15625 |
| 15623 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin(); | 15626 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin(); |
| 15624 CHECK_EQ(0, strcmp("test", | 15627 CHECK_EQ(0, strcmp("test", |
| 15625 *v8::String::Utf8Value(script_origin_f.ResourceName()))); | 15628 *v8::String::Utf8Value(script_origin_f.ResourceName()))); |
| 15626 CHECK_EQ(1, script_origin_f.ResourceLineOffset()->Int32Value()); | 15629 CHECK_EQ(1, script_origin_f.ResourceLineOffset()->Int32Value()); |
| 15627 CHECK(script_origin_f.ResourceIsSharedCrossOrigin()->Value()); | 15630 CHECK(script_origin_f.Options().IsSharedCrossOrigin()); |
| 15628 CHECK(script_origin_f.ResourceIsEmbedderDebugScript()->Value()); | 15631 CHECK(script_origin_f.Options().IsEmbedderDebugScript()); |
| 15632 CHECK(script_origin_f.Options().IsOpaque()); |
| 15629 printf("is name = %d\n", script_origin_f.SourceMapUrl()->IsUndefined()); | 15633 printf("is name = %d\n", script_origin_f.SourceMapUrl()->IsUndefined()); |
| 15630 | 15634 |
| 15631 CHECK_EQ(0, strcmp("http://sourceMapUrl", | 15635 CHECK_EQ(0, strcmp("http://sourceMapUrl", |
| 15632 *v8::String::Utf8Value(script_origin_f.SourceMapUrl()))); | 15636 *v8::String::Utf8Value(script_origin_f.SourceMapUrl()))); |
| 15633 | 15637 |
| 15634 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin(); | 15638 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin(); |
| 15635 CHECK_EQ(0, strcmp("test", | 15639 CHECK_EQ(0, strcmp("test", |
| 15636 *v8::String::Utf8Value(script_origin_g.ResourceName()))); | 15640 *v8::String::Utf8Value(script_origin_g.ResourceName()))); |
| 15637 CHECK_EQ(1, script_origin_g.ResourceLineOffset()->Int32Value()); | 15641 CHECK_EQ(1, script_origin_g.ResourceLineOffset()->Int32Value()); |
| 15638 CHECK(script_origin_g.ResourceIsSharedCrossOrigin()->Value()); | 15642 CHECK(script_origin_g.Options().IsSharedCrossOrigin()); |
| 15639 CHECK(script_origin_g.ResourceIsEmbedderDebugScript()->Value()); | 15643 CHECK(script_origin_g.Options().IsEmbedderDebugScript()); |
| 15644 CHECK(script_origin_g.Options().IsOpaque()); |
| 15640 CHECK_EQ(0, strcmp("http://sourceMapUrl", | 15645 CHECK_EQ(0, strcmp("http://sourceMapUrl", |
| 15641 *v8::String::Utf8Value(script_origin_g.SourceMapUrl()))); | 15646 *v8::String::Utf8Value(script_origin_g.SourceMapUrl()))); |
| 15642 } | 15647 } |
| 15643 | 15648 |
| 15644 | 15649 |
| 15645 THREADED_TEST(FunctionGetInferredName) { | 15650 THREADED_TEST(FunctionGetInferredName) { |
| 15646 LocalContext env; | 15651 LocalContext env; |
| 15647 v8::HandleScope scope(env->GetIsolate()); | 15652 v8::HandleScope scope(env->GetIsolate()); |
| 15648 v8::ScriptOrigin origin = | 15653 v8::ScriptOrigin origin = |
| 15649 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); | 15654 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
| (...skipping 5444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21094 CHECK(!try_catch.HasCaught()); | 21099 CHECK(!try_catch.HasCaught()); |
| 21095 } | 21100 } |
| 21096 | 21101 |
| 21097 { | 21102 { |
| 21098 v8::TryCatch try_catch; | 21103 v8::TryCatch try_catch; |
| 21099 v8::Handle<Value> args[] = {v8_num(42), v8_num(555)}; | 21104 v8::Handle<Value> args[] = {v8_num(42), v8_num(555)}; |
| 21100 fun->Call(v8::Undefined(isolate), arraysize(args), args); | 21105 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21101 CHECK(!try_catch.HasCaught()); | 21106 CHECK(!try_catch.HasCaught()); |
| 21102 } | 21107 } |
| 21103 } | 21108 } |
| OLD | NEW |