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