| 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 4011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4022 v8::HandleScope scope; | 4022 v8::HandleScope scope; |
| 4023 LocalContext current; | 4023 LocalContext current; |
| 4024 | 4024 |
| 4025 // Test that un-aliased eval uses local context. | 4025 // Test that un-aliased eval uses local context. |
| 4026 Local<Script> script = | 4026 Local<Script> script = |
| 4027 Script::Compile(v8_str("foo = 0;" | 4027 Script::Compile(v8_str("foo = 0;" |
| 4028 "(function() {" | 4028 "(function() {" |
| 4029 " var foo = 2;" | 4029 " var foo = 2;" |
| 4030 " return eval('foo');" | 4030 " return eval('foo');" |
| 4031 "})();")); | 4031 "})();")); |
| 4032 Local<Value> foo = script->Run(); | 4032 Local<Value> result = script->Run(); |
| 4033 CHECK_EQ(2, foo->Int32Value()); | 4033 CHECK_EQ(2, result->Int32Value()); |
| 4034 |
| 4035 // Test that un-aliased eval has right this. |
| 4036 script = |
| 4037 Script::Compile(v8_str("function MyObject() { this.self = eval('this'); }" |
| 4038 "var o = new MyObject();" |
| 4039 "o === o.self")); |
| 4040 result = script->Run(); |
| 4041 CHECK(result->IsTrue()); |
| 4034 } | 4042 } |
| 4035 | 4043 |
| 4036 | 4044 |
| 4037 THREADED_TEST(CrossEval) { | 4045 THREADED_TEST(CrossEval) { |
| 4038 v8::HandleScope scope; | 4046 v8::HandleScope scope; |
| 4039 LocalContext other; | 4047 LocalContext other; |
| 4040 LocalContext current; | 4048 LocalContext current; |
| 4041 | 4049 |
| 4042 Local<String> token = v8_str("<security token>"); | 4050 Local<String> token = v8_str("<security token>"); |
| 4043 other->SetSecurityToken(token); | 4051 other->SetSecurityToken(token); |
| (...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5306 // multi-threaded setup. | 5314 // multi-threaded setup. |
| 5307 TEST(PreCompile) { | 5315 TEST(PreCompile) { |
| 5308 // TODO(155): This test would break without the initialization of V8. This is | 5316 // TODO(155): This test would break without the initialization of V8. This is |
| 5309 // a workaround for now to make this test not fail. | 5317 // a workaround for now to make this test not fail. |
| 5310 v8::V8::Initialize(); | 5318 v8::V8::Initialize(); |
| 5311 const char *script = "function foo(a) { return a+1; }"; | 5319 const char *script = "function foo(a) { return a+1; }"; |
| 5312 v8::ScriptData *sd = v8::ScriptData::PreCompile(script, strlen(script)); | 5320 v8::ScriptData *sd = v8::ScriptData::PreCompile(script, strlen(script)); |
| 5313 CHECK_NE(sd->Length(), 0); | 5321 CHECK_NE(sd->Length(), 0); |
| 5314 CHECK_NE(sd->Data(), NULL); | 5322 CHECK_NE(sd->Data(), NULL); |
| 5315 } | 5323 } |
| OLD | NEW |