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

Side by Side Diff: test/cctest/test-object-observe.cc

Issue 791243002: Stop sending Object.observe notifications for API accessor properties (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Restore most of v8natives Created 6 years 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
« src/v8natives.js ('K') | « src/v8natives.js ('k') | no next file » | 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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 isolate, ObserverCallback, External::New(isolate, &numRecordsSent)); 798 isolate, ObserverCallback, External::New(isolate, &numRecordsSent));
799 context->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "observer"), 799 context->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "observer"),
800 tmpl->GetFunction()); 800 tmpl->GetFunction());
801 CompileRun( 801 CompileRun(
802 "var obj = {};" 802 "var obj = {};"
803 "Object.observe(obj, observer);" 803 "Object.observe(obj, observer);"
804 "obj.foo = 1;" 804 "obj.foo = 1;"
805 "obj.bar = 2;"); 805 "obj.bar = 2;");
806 CHECK_EQ(2, numRecordsSent); 806 CHECK_EQ(2, numRecordsSent);
807 } 807 }
808
809
810 static void AccessorGetter(Local<String> property,
811 const PropertyCallbackInfo<Value>& info) {
812 info.GetReturnValue().Set(Integer::New(info.GetIsolate(), 42));
813 }
814
815
816 static void AccessorSetter(Local<String> property, Local<Value> value,
817 const PropertyCallbackInfo<void>& info) {
818 info.GetReturnValue().SetUndefined();
819 }
820
821
822 TEST(APIAccessorsShouldNotNotify) {
823 Isolate* isolate = CcTest::isolate();
824 HandleScope handle_scope(isolate);
825 LocalContext context(isolate);
826 Handle<Object> object = Object::New(isolate);
827 object->SetAccessor(String::NewFromUtf8(isolate, "accessor"), &AccessorGetter,
828 &AccessorSetter);
829 context->Global()->Set(String::NewFromUtf8(isolate, "obj"), object);
830 CompileRun(
831 "var records = null;"
832 "Object.observe(obj, function(r) { records = r });"
833 "obj.accessor = 43;");
834 CHECK(CompileRun("records")->IsNull());
835 CompileRun("Object.defineProperty(obj, 'accessor', { value: 44 });");
836 CHECK(CompileRun("records")->IsNull());
837 }
OLDNEW
« src/v8natives.js ('K') | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698