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

Unified 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 side-by-side diff with in-line comments
Download patch
« src/v8natives.js ('K') | « src/v8natives.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-object-observe.cc
diff --git a/test/cctest/test-object-observe.cc b/test/cctest/test-object-observe.cc
index 7e9992c19d277c658566dd9f682ca852cc18fe08..2766a4f239cf35f2b307707a66f7a0a59d98b540 100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -805,3 +805,33 @@ TEST(ObjectObserveCallsFunctionTemplateInstance) {
"obj.bar = 2;");
CHECK_EQ(2, numRecordsSent);
}
+
+
+static void AccessorGetter(Local<String> property,
+ const PropertyCallbackInfo<Value>& info) {
+ info.GetReturnValue().Set(Integer::New(info.GetIsolate(), 42));
+}
+
+
+static void AccessorSetter(Local<String> property, Local<Value> value,
+ const PropertyCallbackInfo<void>& info) {
+ info.GetReturnValue().SetUndefined();
+}
+
+
+TEST(APIAccessorsShouldNotNotify) {
+ Isolate* isolate = CcTest::isolate();
+ HandleScope handle_scope(isolate);
+ LocalContext context(isolate);
+ Handle<Object> object = Object::New(isolate);
+ object->SetAccessor(String::NewFromUtf8(isolate, "accessor"), &AccessorGetter,
+ &AccessorSetter);
+ context->Global()->Set(String::NewFromUtf8(isolate, "obj"), object);
+ CompileRun(
+ "var records = null;"
+ "Object.observe(obj, function(r) { records = r });"
+ "obj.accessor = 43;");
+ CHECK(CompileRun("records")->IsNull());
+ CompileRun("Object.defineProperty(obj, 'accessor', { value: 44 });");
+ CHECK(CompileRun("records")->IsNull());
+}
« 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