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

Unified Diff: test/cctest/test-object-observe.cc

Issue 11410046: Object.deliverChangeRecords should remove the observer from activeObservers (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rename activeObservers to pendingObservers Created 8 years, 1 month 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
« no previous file with comments | « src/object-observe.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 374dca43474cbe701855749e96cac8cdee53b683..9decf1768f30904c1a9c5f03cdd977e39af68c62 100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -166,6 +166,30 @@ TEST(DeliveryOrderingReentrant) {
CHECK_EQ(2, CompileRun("ordering[1]")->Int32Value());
}
+TEST(DeliveryOrderingDeliverChangeRecords) {
+ HarmonyIsolate isolate;
+ HandleScope scope;
+ LocalContext context;
+ CompileRun(
+ "var obj = {};"
+ "var ordering = [];"
+ "function observer1() { ordering.push(1); if (!obj.b) obj.b = true };"
+ "function observer2() { ordering.push(2); };"
+ "Object.observe(obj, observer1);"
+ "Object.observe(obj, observer2);"
+ "obj.a = 1;"
+ "Object.deliverChangeRecords(observer2);");
+ CHECK_EQ(4, CompileRun("ordering.length")->Int32Value());
+ // First, observer2 is called due to deliverChangeRecords
+ CHECK_EQ(2, CompileRun("ordering[0]")->Int32Value());
+ // Then, observer1 is called when the stack unwinds
+ CHECK_EQ(1, CompileRun("ordering[1]")->Int32Value());
+ // observer1's mutation causes both 1 and 2 to be reactivated,
+ // with 1 having priority.
+ CHECK_EQ(1, CompileRun("ordering[2]")->Int32Value());
+ CHECK_EQ(2, CompileRun("ordering[3]")->Int32Value());
+}
+
TEST(ObjectHashTableGrowth) {
HarmonyIsolate isolate;
HandleScope scope;
« no previous file with comments | « src/object-observe.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698