OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 } | 1387 } |
1388 | 1388 |
1389 | 1389 |
1390 bool message_received; | 1390 bool message_received; |
1391 | 1391 |
1392 | 1392 |
1393 static void check_message(v8::Handle<v8::Message> message, | 1393 static void check_message(v8::Handle<v8::Message> message, |
1394 v8::Handle<Value> data) { | 1394 v8::Handle<Value> data) { |
1395 CHECK_EQ(5.76, data->NumberValue()); | 1395 CHECK_EQ(5.76, data->NumberValue()); |
1396 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); | 1396 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); |
| 1397 CHECK_EQ(7.56, message->GetScriptData()->NumberValue()); |
1397 message_received = true; | 1398 message_received = true; |
1398 } | 1399 } |
1399 | 1400 |
1400 | 1401 |
1401 THREADED_TEST(MessageHandlerData) { | 1402 THREADED_TEST(MessageHandlerData) { |
1402 message_received = false; | 1403 message_received = false; |
1403 v8::HandleScope scope; | 1404 v8::HandleScope scope; |
1404 CHECK(!message_received); | 1405 CHECK(!message_received); |
1405 v8::V8::AddMessageListener(check_message, v8_num(5.76)); | 1406 v8::V8::AddMessageListener(check_message, v8_num(5.76)); |
1406 LocalContext context; | 1407 LocalContext context; |
1407 v8::ScriptOrigin origin = | 1408 v8::ScriptOrigin origin = |
1408 v8::ScriptOrigin(v8_str("6.75")); | 1409 v8::ScriptOrigin(v8_str("6.75")); |
1409 Script::Compile(v8_str("throw 'error'"), &origin)->Run(); | 1410 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
| 1411 &origin); |
| 1412 script->SetData(v8_str("7.56")); |
| 1413 script->Run(); |
1410 CHECK(message_received); | 1414 CHECK(message_received); |
1411 // clear out the message listener | 1415 // clear out the message listener |
1412 v8::V8::RemoveMessageListeners(check_message); | 1416 v8::V8::RemoveMessageListeners(check_message); |
1413 } | 1417 } |
1414 | 1418 |
1415 | 1419 |
1416 THREADED_TEST(GetSetProperty) { | 1420 THREADED_TEST(GetSetProperty) { |
1417 v8::HandleScope scope; | 1421 v8::HandleScope scope; |
1418 LocalContext context; | 1422 LocalContext context; |
1419 context->Global()->Set(v8_str("foo"), v8_num(14)); | 1423 context->Global()->Set(v8_str("foo"), v8_num(14)); |
(...skipping 4807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6227 // Check without 'eval' or 'with'. | 6231 // Check without 'eval' or 'with'. |
6228 v8::Handle<v8::Value> res = | 6232 v8::Handle<v8::Value> res = |
6229 CompileRun("function f() { x = 42; return x; }; f()"); | 6233 CompileRun("function f() { x = 42; return x; }; f()"); |
6230 // Check with 'eval'. | 6234 // Check with 'eval'. |
6231 res = CompileRun("function f() { eval('1'); y = 42; return y; }; f()"); | 6235 res = CompileRun("function f() { eval('1'); y = 42; return y; }; f()"); |
6232 CHECK_EQ(v8::Integer::New(42), res); | 6236 CHECK_EQ(v8::Integer::New(42), res); |
6233 // Check with 'with'. | 6237 // Check with 'with'. |
6234 res = CompileRun("function f() { with (this) { y = 42 }; return y; }; f()"); | 6238 res = CompileRun("function f() { with (this) { y = 42 }; return y; }; f()"); |
6235 CHECK_EQ(v8::Integer::New(42), res); | 6239 CHECK_EQ(v8::Integer::New(42), res); |
6236 } | 6240 } |
OLD | NEW |