| 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 7644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7655 Script::Compile(v8_str("this.propertyIsEnumerable(0)"))->Run(); | 7655 Script::Compile(v8_str("this.propertyIsEnumerable(0)"))->Run(); |
| 7656 CHECK(value->IsBoolean()); | 7656 CHECK(value->IsBoolean()); |
| 7657 CHECK(!value->BooleanValue()); | 7657 CHECK(!value->BooleanValue()); |
| 7658 | 7658 |
| 7659 value = Script::Compile(v8_str("x"))->Run(); | 7659 value = Script::Compile(v8_str("x"))->Run(); |
| 7660 CHECK_EQ(12, value->Int32Value()); | 7660 CHECK_EQ(12, value->Int32Value()); |
| 7661 | 7661 |
| 7662 value = Script::Compile(v8_str("f()"))->Run(); | 7662 value = Script::Compile(v8_str("f()"))->Run(); |
| 7663 CHECK_EQ(42, value->Int32Value()); | 7663 CHECK_EQ(42, value->Int32Value()); |
| 7664 | 7664 |
| 7665 Script::Compile(v8_str("y = 42"))->Run(); | 7665 Script::Compile(v8_str("y = 43"))->Run(); |
| 7666 CHECK_EQ(1, shadow_y_setter_call_count); | 7666 CHECK_EQ(1, shadow_y_setter_call_count); |
| 7667 value = Script::Compile(v8_str("y"))->Run(); | 7667 value = Script::Compile(v8_str("y"))->Run(); |
| 7668 CHECK_EQ(1, shadow_y_getter_call_count); | 7668 CHECK_EQ(1, shadow_y_getter_call_count); |
| 7669 CHECK_EQ(42, value->Int32Value()); | 7669 CHECK_EQ(42, value->Int32Value()); |
| 7670 } | 7670 } |
| 7671 | 7671 |
| 7672 | 7672 |
| 7673 THREADED_TEST(HiddenPrototype) { | 7673 THREADED_TEST(HiddenPrototype) { |
| 7674 v8::HandleScope handle_scope; | 7674 v8::HandleScope handle_scope; |
| 7675 LocalContext context; | 7675 LocalContext context; |
| (...skipping 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10299 Local<v8::Object> instance = child_templ->GetFunction()->NewInstance(); | 10299 Local<v8::Object> instance = child_templ->GetFunction()->NewInstance(); |
| 10300 | 10300 |
| 10301 // Check that the child function overrides the parent one. | 10301 // Check that the child function overrides the parent one. |
| 10302 context->Global()->Set(v8_str("o"), instance); | 10302 context->Global()->Set(v8_str("o"), instance); |
| 10303 Local<Value> value = v8_compile("o.f")->Run(); | 10303 Local<Value> value = v8_compile("o.f")->Run(); |
| 10304 // Check that the 'g' that was added last is hit. | 10304 // Check that the 'g' that was added last is hit. |
| 10305 CHECK_EQ(42, value->Int32Value()); | 10305 CHECK_EQ(42, value->Int32Value()); |
| 10306 value = v8_compile("o.g")->Run(); | 10306 value = v8_compile("o.g")->Run(); |
| 10307 CHECK_EQ(42, value->Int32Value()); | 10307 CHECK_EQ(42, value->Int32Value()); |
| 10308 | 10308 |
| 10309 // Check 'h' can be shadowed. | 10309 // Check that 'h' cannot be shadowed. |
| 10310 value = v8_compile("o.h = 3; o.h")->Run(); | 10310 value = v8_compile("o.h = 3; o.h")->Run(); |
| 10311 CHECK_EQ(3, value->Int32Value()); | 10311 CHECK_EQ(1, value->Int32Value()); |
| 10312 | 10312 |
| 10313 // Check 'i' is cannot be shadowed or changed. | 10313 // Check that 'i' cannot be shadowed or changed. |
| 10314 value = v8_compile("o.i = 3; o.i")->Run(); | 10314 value = v8_compile("o.i = 3; o.i")->Run(); |
| 10315 CHECK_EQ(42, value->Int32Value()); | 10315 CHECK_EQ(42, value->Int32Value()); |
| 10316 } | 10316 } |
| 10317 | 10317 |
| 10318 | 10318 |
| 10319 static v8::Handle<Value> IsConstructHandler(const v8::Arguments& args) { | 10319 static v8::Handle<Value> IsConstructHandler(const v8::Arguments& args) { |
| 10320 ApiTestFuzzer::Fuzz(); | 10320 ApiTestFuzzer::Fuzz(); |
| 10321 return v8::Boolean::New(args.IsConstructCall()); | 10321 return v8::Boolean::New(args.IsConstructCall()); |
| 10322 } | 10322 } |
| 10323 | 10323 |
| (...skipping 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12141 CHECK(!local_env.IsEmpty()); | 12141 CHECK(!local_env.IsEmpty()); |
| 12142 local_env->Enter(); | 12142 local_env->Enter(); |
| 12143 | 12143 |
| 12144 // Should complete without problems. | 12144 // Should complete without problems. |
| 12145 RegExpStringModificationTest().RunTest(); | 12145 RegExpStringModificationTest().RunTest(); |
| 12146 | 12146 |
| 12147 local_env->Exit(); | 12147 local_env->Exit(); |
| 12148 } | 12148 } |
| 12149 | 12149 |
| 12150 | 12150 |
| 12151 // Test that we can set a property on the global object even if there | 12151 // Test that we cannot set a property on the global object if there |
| 12152 // is a read-only property in the prototype chain. | 12152 // is a read-only property in the prototype chain. |
| 12153 TEST(ReadOnlyPropertyInGlobalProto) { | 12153 TEST(ReadOnlyPropertyInGlobalProto) { |
| 12154 v8::HandleScope scope; | 12154 v8::HandleScope scope; |
| 12155 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 12155 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 12156 LocalContext context(0, templ); | 12156 LocalContext context(0, templ); |
| 12157 v8::Handle<v8::Object> global = context->Global(); | 12157 v8::Handle<v8::Object> global = context->Global(); |
| 12158 v8::Handle<v8::Object> global_proto = | 12158 v8::Handle<v8::Object> global_proto = |
| 12159 v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__"))); | 12159 v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__"))); |
| 12160 global_proto->Set(v8_str("x"), v8::Integer::New(0), v8::ReadOnly); | 12160 global_proto->Set(v8_str("x"), v8::Integer::New(0), v8::ReadOnly); |
| 12161 global_proto->Set(v8_str("y"), v8::Integer::New(0), v8::ReadOnly); | 12161 global_proto->Set(v8_str("y"), v8::Integer::New(0), v8::ReadOnly); |
| 12162 // Check without 'eval' or 'with'. | 12162 // Check without 'eval' or 'with'. |
| 12163 v8::Handle<v8::Value> res = | 12163 v8::Handle<v8::Value> res = |
| 12164 CompileRun("function f() { x = 42; return x; }; f()"); | 12164 CompileRun("function f() { x = 42; return x; }; f()"); |
| 12165 CHECK_EQ(v8::Integer::New(0), res); |
| 12165 // Check with 'eval'. | 12166 // Check with 'eval'. |
| 12166 res = CompileRun("function f() { eval('1'); y = 42; return y; }; f()"); | 12167 res = CompileRun("function f() { eval('1'); y = 43; return y; }; f()"); |
| 12167 CHECK_EQ(v8::Integer::New(42), res); | 12168 CHECK_EQ(v8::Integer::New(0), res); |
| 12168 // Check with 'with'. | 12169 // Check with 'with'. |
| 12169 res = CompileRun("function f() { with (this) { y = 42 }; return y; }; f()"); | 12170 res = CompileRun("function f() { with (this) { y = 44 }; return y; }; f()"); |
| 12170 CHECK_EQ(v8::Integer::New(42), res); | 12171 CHECK_EQ(v8::Integer::New(0), res); |
| 12171 } | 12172 } |
| 12172 | 12173 |
| 12173 static int force_set_set_count = 0; | 12174 static int force_set_set_count = 0; |
| 12174 static int force_set_get_count = 0; | 12175 static int force_set_get_count = 0; |
| 12175 bool pass_on_get = false; | 12176 bool pass_on_get = false; |
| 12176 | 12177 |
| 12177 static v8::Handle<v8::Value> ForceSetGetter(v8::Local<v8::String> name, | 12178 static v8::Handle<v8::Value> ForceSetGetter(v8::Local<v8::String> name, |
| 12178 const v8::AccessorInfo& info) { | 12179 const v8::AccessorInfo& info) { |
| 12179 force_set_get_count++; | 12180 force_set_get_count++; |
| 12180 if (pass_on_get) { | 12181 if (pass_on_get) { |
| (...skipping 4405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16586 v8::V8::SetFatalErrorHandler(CountingErrorCallback); | 16587 v8::V8::SetFatalErrorHandler(CountingErrorCallback); |
| 16587 v8::Utils::ReportApiFailure("StringEmpty()", "Kill V8"); | 16588 v8::Utils::ReportApiFailure("StringEmpty()", "Kill V8"); |
| 16588 i::Isolate::Current()->TearDown(); | 16589 i::Isolate::Current()->TearDown(); |
| 16589 CHECK(!i::Internals::IsInitialized(isolate)); | 16590 CHECK(!i::Internals::IsInitialized(isolate)); |
| 16590 CHECK_EQ(1, fatal_error_callback_counter); | 16591 CHECK_EQ(1, fatal_error_callback_counter); |
| 16591 CHECK(v8::String::Empty().IsEmpty()); | 16592 CHECK(v8::String::Empty().IsEmpty()); |
| 16592 CHECK_EQ(2, fatal_error_callback_counter); | 16593 CHECK_EQ(2, fatal_error_callback_counter); |
| 16593 CHECK(v8::String::Empty(isolate).IsEmpty()); | 16594 CHECK(v8::String::Empty(isolate).IsEmpty()); |
| 16594 CHECK_EQ(3, fatal_error_callback_counter); | 16595 CHECK_EQ(3, fatal_error_callback_counter); |
| 16595 } | 16596 } |
| OLD | NEW |