Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: test/cctest/test-api.cc

Issue 262053011: Confusion on changing data property callback attributes (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/regress/regress-3334.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 LocalContext env; 1997 LocalContext env;
1998 env->Global()->Set(v8_str("Child"), child->GetFunction()); 1998 env->Global()->Set(v8_str("Child"), child->GetFunction());
1999 CompileRun("var child = new Child;" 1999 CompileRun("var child = new Child;"
2000 "child.age = 10;"); 2000 "child.age = 10;");
2001 ExpectBoolean("child.hasOwnProperty('age')", false); 2001 ExpectBoolean("child.hasOwnProperty('age')", false);
2002 ExpectInt32("child.age", 10); 2002 ExpectInt32("child.age", 10);
2003 ExpectInt32("child.accessor_age", 10); 2003 ExpectInt32("child.accessor_age", 10);
2004 } 2004 }
2005 2005
2006 2006
2007 THREADED_TEST(ExecutableAccessorIsPreservedOnAttributeChange) {
2008 v8::Isolate* isolate = CcTest::isolate();
2009 v8::HandleScope scope(isolate);
2010 LocalContext env;
2011 v8::Local<v8::Value> res = CompileRun("var a = []; a;");
2012 i::Handle<i::JSObject> a(v8::Utils::OpenHandle(v8::Object::Cast(*res)));
2013 CHECK(a->map()->instance_descriptors()->IsFixedArray());
2014 CHECK_GT(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0);
2015 CompileRun("Object.defineProperty(a, 'length', { writable: false });");
2016 CHECK_EQ(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0);
2017 // But we should still have an ExecutableAccessorInfo.
2018 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
2019 i::LookupResult lookup(i_isolate);
2020 i::Handle<i::String> name(v8::Utils::OpenHandle(*v8_str("length")));
2021 a->LookupOwnRealNamedProperty(name, &lookup);
2022 CHECK(lookup.IsPropertyCallbacks());
2023 i::Handle<i::Object> callback(lookup.GetCallbackObject(), i_isolate);
2024 CHECK(callback->IsExecutableAccessorInfo());
2025 }
2026
2027
2007 THREADED_TEST(EmptyInterceptorBreakTransitions) { 2028 THREADED_TEST(EmptyInterceptorBreakTransitions) {
2008 v8::HandleScope scope(CcTest::isolate()); 2029 v8::HandleScope scope(CcTest::isolate());
2009 Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); 2030 Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate());
2010 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); 2031 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter);
2011 LocalContext env; 2032 LocalContext env;
2012 env->Global()->Set(v8_str("Constructor"), templ->GetFunction()); 2033 env->Global()->Set(v8_str("Constructor"), templ->GetFunction());
2013 CompileRun("var o1 = new Constructor;" 2034 CompileRun("var o1 = new Constructor;"
2014 "o1.a = 1;" // Ensure a and x share the descriptor array. 2035 "o1.a = 1;" // Ensure a and x share the descriptor array.
2015 "Object.defineProperty(o1, 'x', {value: 10});"); 2036 "Object.defineProperty(o1, 'x', {value: 10});");
2016 CompileRun("var o2 = new Constructor;" 2037 CompileRun("var o2 = new Constructor;"
(...skipping 20621 matching lines...) Expand 10 before | Expand all | Expand 10 after
22638 Local<Script> script = v8::ScriptCompiler::Compile( 22659 Local<Script> script = v8::ScriptCompiler::Compile(
22639 isolate, &script_source); 22660 isolate, &script_source);
22640 Local<Value> script_name = script->GetUnboundScript()->GetScriptName(); 22661 Local<Value> script_name = script->GetUnboundScript()->GetScriptName();
22641 CHECK(!script_name.IsEmpty()); 22662 CHECK(!script_name.IsEmpty());
22642 CHECK(script_name->IsString()); 22663 CHECK(script_name->IsString());
22643 String::Utf8Value utf8_name(script_name); 22664 String::Utf8Value utf8_name(script_name);
22644 CHECK_EQ(url, *utf8_name); 22665 CHECK_EQ(url, *utf8_name);
22645 int line_number = script->GetUnboundScript()->GetLineNumber(0); 22666 int line_number = script->GetUnboundScript()->GetLineNumber(0);
22646 CHECK_EQ(13, line_number); 22667 CHECK_EQ(13, line_number);
22647 } 22668 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/regress/regress-3334.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698