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

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

Issue 12092079: Object.observe: use JSWeakMaps instead of raw ObjectHashTables in observation state (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix test, also test notifierTargetMap Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.cc ('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 821d153f3d21435061a782d06e4bcc17fb673bd9..558b0d1a30050be4446e388ca5c6d4e801a6db10 100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -30,6 +30,7 @@
#include "cctest.h"
using namespace v8;
+namespace i = v8::internal;
namespace {
// Need to create a new isolate when FLAG_harmony_observation is on.
@@ -397,3 +398,37 @@ TEST(HiddenPrototypeObservation) {
};
EXPECT_RECORDS(CompileRun("records"), expected_records3);
}
+
+
+static int NumberOfElements(i::Handle<i::JSWeakMap> map) {
+ return i::ObjectHashTable::cast(map->table())->NumberOfElements();
+}
+
+
+TEST(ObservationWeakMap) {
+ HarmonyIsolate isolate;
+ HandleScope scope;
+ LocalContext context;
+ CompileRun(
+ "var obj = {};"
+ "Object.observe(obj, function(){});"
+ "Object.getNotifier(obj);"
+ "obj = null;");
+ i::Handle<i::JSObject> observation_state = FACTORY->observation_state();
+ i::Handle<i::JSWeakMap> observerInfoMap =
+ i::Handle<i::JSWeakMap>::cast(
+ i::GetProperty(observation_state, "observerInfoMap"));
+ i::Handle<i::JSWeakMap> objectInfoMap =
+ i::Handle<i::JSWeakMap>::cast(
+ i::GetProperty(observation_state, "objectInfoMap"));
+ i::Handle<i::JSWeakMap> notifierTargetMap =
+ i::Handle<i::JSWeakMap>::cast(
+ i::GetProperty(observation_state, "notifierTargetMap"));
+ CHECK_EQ(1, NumberOfElements(observerInfoMap));
+ CHECK_EQ(1, NumberOfElements(objectInfoMap));
+ CHECK_EQ(1, NumberOfElements(notifierTargetMap));
+ HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
+ CHECK_EQ(0, NumberOfElements(observerInfoMap));
+ CHECK_EQ(0, NumberOfElements(objectInfoMap));
+ CHECK_EQ(0, NumberOfElements(notifierTargetMap));
+}
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698