| 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 3876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3887 v8::V8::RemoveMessageListeners(check_message_2); | 3887 v8::V8::RemoveMessageListeners(check_message_2); |
| 3888 } | 3888 } |
| 3889 | 3889 |
| 3890 | 3890 |
| 3891 static void check_message_3(v8::Handle<v8::Message> message, | 3891 static void check_message_3(v8::Handle<v8::Message> message, |
| 3892 v8::Handle<Value> data) { | 3892 v8::Handle<Value> data) { |
| 3893 CHECK(message->IsSharedCrossOrigin()); | 3893 CHECK(message->IsSharedCrossOrigin()); |
| 3894 CHECK(message->GetScriptOrigin().ResourceIsSharedCrossOrigin()->Value()); | 3894 CHECK(message->GetScriptOrigin().ResourceIsSharedCrossOrigin()->Value()); |
| 3895 CHECK(message->GetScriptOrigin().ResourceIsEmbedderDebugScript()->Value()); | 3895 CHECK(message->GetScriptOrigin().ResourceIsEmbedderDebugScript()->Value()); |
| 3896 CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue()); | 3896 CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue()); |
| 3897 CHECK_EQ(7.40, message->GetScriptOrigin().SourceMapUrl()->NumberValue()); |
| 3897 message_received = true; | 3898 message_received = true; |
| 3898 } | 3899 } |
| 3899 | 3900 |
| 3900 | 3901 |
| 3901 TEST(MessageHandler3) { | 3902 TEST(MessageHandler3) { |
| 3902 message_received = false; | 3903 message_received = false; |
| 3903 v8::Isolate* isolate = CcTest::isolate(); | 3904 v8::Isolate* isolate = CcTest::isolate(); |
| 3904 v8::HandleScope scope(isolate); | 3905 v8::HandleScope scope(isolate); |
| 3905 CHECK(!message_received); | 3906 CHECK(!message_received); |
| 3906 v8::V8::AddMessageListener(check_message_3); | 3907 v8::V8::AddMessageListener(check_message_3); |
| 3907 LocalContext context; | 3908 LocalContext context; |
| 3908 v8::ScriptOrigin origin = | 3909 v8::ScriptOrigin origin = v8::ScriptOrigin( |
| 3909 v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1), | 3910 v8_str("6.75"), v8::Integer::New(isolate, 1), |
| 3910 v8::Integer::New(isolate, 2), v8::True(isolate), | 3911 v8::Integer::New(isolate, 2), v8::True(isolate), Handle<v8::Integer>(), |
| 3911 Handle<v8::Integer>(), v8::True(isolate)); | 3912 v8::True(isolate), v8_str("7.40")); |
| 3912 v8::Handle<v8::Script> script = | 3913 v8::Handle<v8::Script> script = |
| 3913 Script::Compile(v8_str("throw 'error'"), &origin); | 3914 Script::Compile(v8_str("throw 'error'"), &origin); |
| 3914 script->Run(); | 3915 script->Run(); |
| 3915 CHECK(message_received); | 3916 CHECK(message_received); |
| 3916 // clear out the message listener | 3917 // clear out the message listener |
| 3917 v8::V8::RemoveMessageListeners(check_message_3); | 3918 v8::V8::RemoveMessageListeners(check_message_3); |
| 3918 } | 3919 } |
| 3919 | 3920 |
| 3920 | 3921 |
| 3921 static void check_message_4(v8::Handle<v8::Message> message, | 3922 static void check_message_4(v8::Handle<v8::Message> message, |
| (...skipping 12351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16273 } | 16274 } |
| 16274 | 16275 |
| 16275 | 16276 |
| 16276 THREADED_TEST(ScriptOrigin) { | 16277 THREADED_TEST(ScriptOrigin) { |
| 16277 LocalContext env; | 16278 LocalContext env; |
| 16278 v8::HandleScope scope(env->GetIsolate()); | 16279 v8::HandleScope scope(env->GetIsolate()); |
| 16279 v8::ScriptOrigin origin = v8::ScriptOrigin( | 16280 v8::ScriptOrigin origin = v8::ScriptOrigin( |
| 16280 v8::String::NewFromUtf8(env->GetIsolate(), "test"), | 16281 v8::String::NewFromUtf8(env->GetIsolate(), "test"), |
| 16281 v8::Integer::New(env->GetIsolate(), 1), | 16282 v8::Integer::New(env->GetIsolate(), 1), |
| 16282 v8::Integer::New(env->GetIsolate(), 1), v8::True(env->GetIsolate()), | 16283 v8::Integer::New(env->GetIsolate(), 1), v8::True(env->GetIsolate()), |
| 16283 v8::Handle<v8::Integer>(), v8::True(env->GetIsolate())); | 16284 v8::Handle<v8::Integer>(), v8::True(env->GetIsolate()), |
| 16285 v8::String::NewFromUtf8(env->GetIsolate(), "http://sourceMapUrl")); |
| 16284 v8::Handle<v8::String> script = v8::String::NewFromUtf8( | 16286 v8::Handle<v8::String> script = v8::String::NewFromUtf8( |
| 16285 env->GetIsolate(), "function f() {}\n\nfunction g() {}"); | 16287 env->GetIsolate(), "function f() {}\n\nfunction g() {}"); |
| 16286 v8::Script::Compile(script, &origin)->Run(); | 16288 v8::Script::Compile(script, &origin)->Run(); |
| 16287 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 16289 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
| 16288 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); | 16290 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
| 16289 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 16291 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
| 16290 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); | 16292 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
| 16291 | 16293 |
| 16292 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin(); | 16294 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin(); |
| 16293 CHECK_EQ(0, strcmp("test", | 16295 CHECK_EQ(0, strcmp("test", |
| 16294 *v8::String::Utf8Value(script_origin_f.ResourceName()))); | 16296 *v8::String::Utf8Value(script_origin_f.ResourceName()))); |
| 16295 CHECK_EQ(1, script_origin_f.ResourceLineOffset()->Int32Value()); | 16297 CHECK_EQ(1, script_origin_f.ResourceLineOffset()->Int32Value()); |
| 16296 CHECK(script_origin_f.ResourceIsSharedCrossOrigin()->Value()); | 16298 CHECK(script_origin_f.ResourceIsSharedCrossOrigin()->Value()); |
| 16297 CHECK(script_origin_f.ResourceIsEmbedderDebugScript()->Value()); | 16299 CHECK(script_origin_f.ResourceIsEmbedderDebugScript()->Value()); |
| 16300 printf("is name = %d\n", script_origin_f.SourceMapUrl()->IsUndefined()); |
| 16301 |
| 16302 CHECK_EQ(0, strcmp("http://sourceMapUrl", |
| 16303 *v8::String::Utf8Value(script_origin_f.SourceMapUrl()))); |
| 16298 | 16304 |
| 16299 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin(); | 16305 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin(); |
| 16300 CHECK_EQ(0, strcmp("test", | 16306 CHECK_EQ(0, strcmp("test", |
| 16301 *v8::String::Utf8Value(script_origin_g.ResourceName()))); | 16307 *v8::String::Utf8Value(script_origin_g.ResourceName()))); |
| 16302 CHECK_EQ(1, script_origin_g.ResourceLineOffset()->Int32Value()); | 16308 CHECK_EQ(1, script_origin_g.ResourceLineOffset()->Int32Value()); |
| 16303 CHECK(script_origin_g.ResourceIsSharedCrossOrigin()->Value()); | 16309 CHECK(script_origin_g.ResourceIsSharedCrossOrigin()->Value()); |
| 16304 CHECK(script_origin_g.ResourceIsEmbedderDebugScript()->Value()); | 16310 CHECK(script_origin_g.ResourceIsEmbedderDebugScript()->Value()); |
| 16311 CHECK_EQ(0, strcmp("http://sourceMapUrl", |
| 16312 *v8::String::Utf8Value(script_origin_g.SourceMapUrl()))); |
| 16305 } | 16313 } |
| 16306 | 16314 |
| 16307 | 16315 |
| 16308 THREADED_TEST(FunctionGetInferredName) { | 16316 THREADED_TEST(FunctionGetInferredName) { |
| 16309 LocalContext env; | 16317 LocalContext env; |
| 16310 v8::HandleScope scope(env->GetIsolate()); | 16318 v8::HandleScope scope(env->GetIsolate()); |
| 16311 v8::ScriptOrigin origin = | 16319 v8::ScriptOrigin origin = |
| 16312 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); | 16320 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
| 16313 v8::Handle<v8::String> script = v8::String::NewFromUtf8( | 16321 v8::Handle<v8::String> script = v8::String::NewFromUtf8( |
| 16314 env->GetIsolate(), | 16322 env->GetIsolate(), |
| (...skipping 5268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21583 } | 21591 } |
| 21584 { | 21592 { |
| 21585 v8::TryCatch try_catch; | 21593 v8::TryCatch try_catch; |
| 21586 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); | 21594 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); |
| 21587 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, | 21595 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, |
| 21588 length).IsEmpty()); | 21596 length).IsEmpty()); |
| 21589 CHECK(try_catch.HasCaught()); | 21597 CHECK(try_catch.HasCaught()); |
| 21590 } | 21598 } |
| 21591 free(buffer); | 21599 free(buffer); |
| 21592 } | 21600 } |
| OLD | NEW |