Index: test/cctest/test-object-observe.cc |
diff --git a/test/cctest/test-object-observe.cc b/test/cctest/test-object-observe.cc |
index 0a30d4e275b8e96864076234e5c0890c954b25db..6bde5b37e12d29c7132d36b1bbde473f4b97ae15 100644 |
--- a/test/cctest/test-object-observe.cc |
+++ b/test/cctest/test-object-observe.cc |
@@ -32,33 +32,10 @@ |
using namespace v8; |
namespace i = v8::internal; |
-namespace { |
-// Need to create a new isolate when FLAG_harmony_observation is on. |
-class HarmonyIsolate { |
- public: |
- HarmonyIsolate() { |
- i::FLAG_harmony_observation = true; |
- isolate_ = Isolate::New(); |
- isolate_->Enter(); |
- } |
- |
- ~HarmonyIsolate() { |
- isolate_->Exit(); |
- isolate_->Dispose(); |
- } |
- |
- Isolate* GetIsolate() const { return isolate_; } |
- |
- private: |
- Isolate* isolate_; |
-}; |
-} |
- |
TEST(PerIsolateState) { |
- HarmonyIsolate isolate; |
- HandleScope scope(isolate.GetIsolate()); |
- LocalContext context1(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
+ LocalContext context1(CcTest::isolate()); |
CompileRun( |
"var count = 0;" |
"var calls = 0;" |
@@ -71,29 +48,29 @@ TEST(PerIsolateState) { |
"(function() { obj.foo = 'bar'; })"); |
Handle<Value> notify_fun2; |
{ |
- LocalContext context2(isolate.GetIsolate()); |
- context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"), |
+ LocalContext context2(CcTest::isolate()); |
+ context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
obj); |
notify_fun2 = CompileRun( |
"(function() { obj.foo = 'baz'; })"); |
} |
Handle<Value> notify_fun3; |
{ |
- LocalContext context3(isolate.GetIsolate()); |
- context3->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"), |
+ LocalContext context3(CcTest::isolate()); |
+ context3->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
obj); |
notify_fun3 = CompileRun( |
"(function() { obj.foo = 'bat'; })"); |
} |
{ |
- LocalContext context4(isolate.GetIsolate()); |
+ LocalContext context4(CcTest::isolate()); |
context4->Global()->Set( |
- String::NewFromUtf8(isolate.GetIsolate(), "observer"), observer); |
- context4->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "fun1"), |
+ String::NewFromUtf8(CcTest::isolate(), "observer"), observer); |
+ context4->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "fun1"), |
notify_fun1); |
- context4->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "fun2"), |
+ context4->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "fun2"), |
notify_fun2); |
- context4->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "fun3"), |
+ context4->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "fun3"), |
notify_fun3); |
CompileRun("fun1(); fun2(); fun3(); Object.deliverChangeRecords(observer)"); |
} |
@@ -103,9 +80,8 @@ TEST(PerIsolateState) { |
TEST(EndOfMicrotaskDelivery) { |
- HarmonyIsolate isolate; |
- HandleScope scope(isolate.GetIsolate()); |
- LocalContext context(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
+ LocalContext context(CcTest::isolate()); |
CompileRun( |
"var obj = {};" |
"var count = 0;" |
@@ -117,9 +93,8 @@ TEST(EndOfMicrotaskDelivery) { |
TEST(DeliveryOrdering) { |
- HarmonyIsolate isolate; |
- HandleScope scope(isolate.GetIsolate()); |
- LocalContext context(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
+ LocalContext context(CcTest::isolate()); |
CompileRun( |
"var obj1 = {};" |
"var obj2 = {};" |
@@ -149,9 +124,8 @@ TEST(DeliveryOrdering) { |
TEST(DeliveryOrderingReentrant) { |
- HarmonyIsolate isolate; |
- HandleScope scope(isolate.GetIsolate()); |
- LocalContext context(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
+ LocalContext context(CcTest::isolate()); |
CompileRun( |
"var obj = {};" |
"var reentered = false;" |
@@ -181,9 +155,8 @@ TEST(DeliveryOrderingReentrant) { |
TEST(DeliveryOrderingDeliverChangeRecords) { |
- HarmonyIsolate isolate; |
- HandleScope scope(isolate.GetIsolate()); |
- LocalContext context(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
+ LocalContext context(CcTest::isolate()); |
CompileRun( |
"var obj = {};" |
"var ordering = [];" |
@@ -206,21 +179,20 @@ TEST(DeliveryOrderingDeliverChangeRecords) { |
TEST(ObjectHashTableGrowth) { |
- HarmonyIsolate isolate; |
- HandleScope scope(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
// Initializing this context sets up initial hash tables. |
- LocalContext context(isolate.GetIsolate()); |
+ LocalContext context(CcTest::isolate()); |
Handle<Value> obj = CompileRun("obj = {};"); |
Handle<Value> observer = CompileRun( |
"var ran = false;" |
"(function() { ran = true })"); |
{ |
// As does initializing this context. |
- LocalContext context2(isolate.GetIsolate()); |
- context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"), |
+ LocalContext context2(CcTest::isolate()); |
+ context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
obj); |
context2->Global()->Set( |
- String::NewFromUtf8(isolate.GetIsolate(), "observer"), observer); |
+ String::NewFromUtf8(CcTest::isolate(), "observer"), observer); |
CompileRun( |
"var objArr = [];" |
// 100 objects should be enough to make the hash table grow |
@@ -238,9 +210,8 @@ TEST(ObjectHashTableGrowth) { |
TEST(GlobalObjectObservation) { |
- HarmonyIsolate isolate; |
- LocalContext context(isolate.GetIsolate()); |
- HandleScope scope(isolate.GetIsolate()); |
+ LocalContext context(CcTest::isolate()); |
+ HandleScope scope(CcTest::isolate()); |
Handle<Object> global_proxy = context->Global(); |
CompileRun( |
"var records = [];" |
@@ -261,7 +232,7 @@ TEST(GlobalObjectObservation) { |
// to the old context. |
context->DetachGlobal(); |
{ |
- LocalContext context2(isolate.GetIsolate()); |
+ LocalContext context2(CcTest::isolate()); |
CompileRun( |
"var records2 = [];" |
"var global = this;" |
@@ -279,7 +250,7 @@ TEST(GlobalObjectObservation) { |
{ |
// Delegates to Context::New |
LocalContext context3( |
- isolate.GetIsolate(), NULL, Handle<ObjectTemplate>(), global_proxy); |
+ CcTest::isolate(), NULL, Handle<ObjectTemplate>(), global_proxy); |
CompileRun( |
"var records3 = [];" |
"Object.observe(this, function(r) { [].push.apply(records3, r) });" |
@@ -327,12 +298,11 @@ static void ExpectRecords(v8::Isolate* isolate, |
} |
#define EXPECT_RECORDS(records, expectations) \ |
- ExpectRecords(isolate.GetIsolate(), records, expectations, \ |
+ ExpectRecords(CcTest::isolate(), records, expectations, \ |
ARRAY_SIZE(expectations)) |
TEST(APITestBasicMutation) { |
- HarmonyIsolate isolate; |
- v8::Isolate* v8_isolate = isolate.GetIsolate(); |
+ v8::Isolate* v8_isolate = CcTest::isolate(); |
HandleScope scope(v8_isolate); |
LocalContext context(v8_isolate); |
Handle<Object> obj = Handle<Object>::Cast(CompileRun( |
@@ -379,8 +349,7 @@ TEST(APITestBasicMutation) { |
TEST(HiddenPrototypeObservation) { |
- HarmonyIsolate isolate; |
- v8::Isolate* v8_isolate = isolate.GetIsolate(); |
+ v8::Isolate* v8_isolate = CcTest::isolate(); |
HandleScope scope(v8_isolate); |
LocalContext context(v8_isolate); |
Handle<FunctionTemplate> tmpl = FunctionTemplate::New(v8_isolate); |
@@ -431,15 +400,14 @@ static int NumberOfElements(i::Handle<i::JSWeakMap> map) { |
TEST(ObservationWeakMap) { |
- HarmonyIsolate isolate; |
- HandleScope scope(isolate.GetIsolate()); |
- LocalContext context(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
+ LocalContext context(CcTest::isolate()); |
CompileRun( |
"var obj = {};" |
"Object.observe(obj, function(){});" |
"Object.getNotifier(obj);" |
"obj = null;"); |
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate.GetIsolate()); |
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(CcTest::isolate()); |
i::Handle<i::JSObject> observation_state = |
i_isolate->factory()->observation_state(); |
i::Handle<i::JSWeakMap> callbackInfoMap = |
@@ -528,17 +496,16 @@ static Handle<Object> CreateAccessCheckedObject( |
TEST(NamedAccessCheck) { |
- HarmonyIsolate isolate; |
const AccessType types[] = { ACCESS_GET, ACCESS_HAS }; |
for (size_t i = 0; i < ARRAY_SIZE(types); ++i) { |
- HandleScope scope(isolate.GetIsolate()); |
- LocalContext context(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
+ LocalContext context(CcTest::isolate()); |
g_access_block_type = types[i]; |
Handle<Object> instance = CreateAccessCheckedObject( |
- isolate.GetIsolate(), |
+ CcTest::isolate(), |
NamedAccessAllowUnlessBlocked, |
IndexedAccessAlwaysAllowed, |
- String::NewFromUtf8(isolate.GetIsolate(), "foo")); |
+ String::NewFromUtf8(CcTest::isolate(), "foo")); |
CompileRun("var records = null;" |
"var objNoCheck = {};" |
"var observer = function(r) { records = r };" |
@@ -546,11 +513,11 @@ TEST(NamedAccessCheck) { |
"Object.observe(objNoCheck, observer);"); |
Handle<Value> obj_no_check = CompileRun("objNoCheck"); |
{ |
- LocalContext context2(isolate.GetIsolate()); |
- context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"), |
+ LocalContext context2(CcTest::isolate()); |
+ context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
instance); |
context2->Global()->Set( |
- String::NewFromUtf8(isolate.GetIsolate(), "objNoCheck"), |
+ String::NewFromUtf8(CcTest::isolate(), "objNoCheck"), |
obj_no_check); |
CompileRun("var records2 = null;" |
"var observer2 = function(r) { records2 = r };" |
@@ -564,9 +531,9 @@ TEST(NamedAccessCheck) { |
const RecordExpectation expected_records2[] = { |
{ instance, "add", "foo", Handle<Value>() }, |
{ instance, "update", "foo", |
- String::NewFromUtf8(isolate.GetIsolate(), "bar") }, |
+ String::NewFromUtf8(CcTest::isolate(), "bar") }, |
{ instance, "reconfigure", "foo", |
- Number::New(isolate.GetIsolate(), 5) }, |
+ Number::New(CcTest::isolate(), 5) }, |
{ instance, "add", "bar", Handle<Value>() }, |
{ obj_no_check, "add", "baz", Handle<Value>() }, |
}; |
@@ -582,15 +549,14 @@ TEST(NamedAccessCheck) { |
TEST(IndexedAccessCheck) { |
- HarmonyIsolate isolate; |
const AccessType types[] = { ACCESS_GET, ACCESS_HAS }; |
for (size_t i = 0; i < ARRAY_SIZE(types); ++i) { |
- HandleScope scope(isolate.GetIsolate()); |
- LocalContext context(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
+ LocalContext context(CcTest::isolate()); |
g_access_block_type = types[i]; |
Handle<Object> instance = CreateAccessCheckedObject( |
- isolate.GetIsolate(), NamedAccessAlwaysAllowed, |
- IndexedAccessAllowUnlessBlocked, Number::New(isolate.GetIsolate(), 7)); |
+ CcTest::isolate(), NamedAccessAlwaysAllowed, |
+ IndexedAccessAllowUnlessBlocked, Number::New(CcTest::isolate(), 7)); |
CompileRun("var records = null;" |
"var objNoCheck = {};" |
"var observer = function(r) { records = r };" |
@@ -598,11 +564,11 @@ TEST(IndexedAccessCheck) { |
"Object.observe(objNoCheck, observer);"); |
Handle<Value> obj_no_check = CompileRun("objNoCheck"); |
{ |
- LocalContext context2(isolate.GetIsolate()); |
- context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"), |
+ LocalContext context2(CcTest::isolate()); |
+ context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
instance); |
context2->Global()->Set( |
- String::NewFromUtf8(isolate.GetIsolate(), "objNoCheck"), |
+ String::NewFromUtf8(CcTest::isolate(), "objNoCheck"), |
obj_no_check); |
CompileRun("var records2 = null;" |
"var observer2 = function(r) { records2 = r };" |
@@ -616,8 +582,8 @@ TEST(IndexedAccessCheck) { |
const RecordExpectation expected_records2[] = { |
{ instance, "add", "7", Handle<Value>() }, |
{ instance, "update", "7", |
- String::NewFromUtf8(isolate.GetIsolate(), "foo") }, |
- { instance, "reconfigure", "7", Number::New(isolate.GetIsolate(), 5) }, |
+ String::NewFromUtf8(CcTest::isolate(), "foo") }, |
+ { instance, "reconfigure", "7", Number::New(CcTest::isolate(), 5) }, |
{ instance, "add", "8", Handle<Value>() }, |
{ obj_no_check, "add", "42", Handle<Value>() } |
}; |
@@ -633,13 +599,12 @@ TEST(IndexedAccessCheck) { |
TEST(SpliceAccessCheck) { |
- HarmonyIsolate isolate; |
- HandleScope scope(isolate.GetIsolate()); |
- LocalContext context(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
+ LocalContext context(CcTest::isolate()); |
g_access_block_type = ACCESS_GET; |
Handle<Object> instance = CreateAccessCheckedObject( |
- isolate.GetIsolate(), NamedAccessAlwaysAllowed, |
- IndexedAccessAllowUnlessBlocked, Number::New(isolate.GetIsolate(), 1)); |
+ CcTest::isolate(), NamedAccessAlwaysAllowed, |
+ IndexedAccessAllowUnlessBlocked, Number::New(CcTest::isolate(), 1)); |
CompileRun("var records = null;" |
"obj[1] = 'foo';" |
"obj.length = 2;" |
@@ -649,11 +614,11 @@ TEST(SpliceAccessCheck) { |
"Array.observe(objNoCheck, observer);"); |
Handle<Value> obj_no_check = CompileRun("objNoCheck"); |
{ |
- LocalContext context2(isolate.GetIsolate()); |
- context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"), |
+ LocalContext context2(CcTest::isolate()); |
+ context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
instance); |
context2->Global()->Set( |
- String::NewFromUtf8(isolate.GetIsolate(), "objNoCheck"), obj_no_check); |
+ String::NewFromUtf8(CcTest::isolate(), "objNoCheck"), obj_no_check); |
CompileRun("var records2 = null;" |
"var observer2 = function(r) { records2 = r };" |
"Array.observe(obj, observer2);" |
@@ -680,11 +645,10 @@ TEST(SpliceAccessCheck) { |
TEST(DisallowAllForAccessKeys) { |
- HarmonyIsolate isolate; |
- HandleScope scope(isolate.GetIsolate()); |
- LocalContext context(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
+ LocalContext context(CcTest::isolate()); |
Handle<Object> instance = CreateAccessCheckedObject( |
- isolate.GetIsolate(), BlockAccessKeys, IndexedAccessAlwaysAllowed); |
+ CcTest::isolate(), BlockAccessKeys, IndexedAccessAlwaysAllowed); |
CompileRun("var records = null;" |
"var objNoCheck = {};" |
"var observer = function(r) { records = r };" |
@@ -692,11 +656,11 @@ TEST(DisallowAllForAccessKeys) { |
"Object.observe(objNoCheck, observer);"); |
Handle<Value> obj_no_check = CompileRun("objNoCheck"); |
{ |
- LocalContext context2(isolate.GetIsolate()); |
- context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"), |
+ LocalContext context2(CcTest::isolate()); |
+ context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
instance); |
context2->Global()->Set( |
- String::NewFromUtf8(isolate.GetIsolate(), "objNoCheck"), obj_no_check); |
+ String::NewFromUtf8(CcTest::isolate(), "objNoCheck"), obj_no_check); |
CompileRun("var records2 = null;" |
"var observer2 = function(r) { records2 = r };" |
"Object.observe(obj, observer2);" |
@@ -719,24 +683,23 @@ TEST(DisallowAllForAccessKeys) { |
TEST(AccessCheckDisallowApiModifications) { |
- HarmonyIsolate isolate; |
- HandleScope scope(isolate.GetIsolate()); |
- LocalContext context(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
+ LocalContext context(CcTest::isolate()); |
Handle<Object> instance = CreateAccessCheckedObject( |
- isolate.GetIsolate(), BlockAccessKeys, IndexedAccessAlwaysAllowed); |
+ CcTest::isolate(), BlockAccessKeys, IndexedAccessAlwaysAllowed); |
CompileRun("var records = null;" |
"var observer = function(r) { records = r };" |
"Object.observe(obj, observer);"); |
{ |
- LocalContext context2(isolate.GetIsolate()); |
- context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"), |
+ LocalContext context2(CcTest::isolate()); |
+ context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "obj"), |
instance); |
CompileRun("var records2 = null;" |
"var observer2 = function(r) { records2 = r };" |
"Object.observe(obj, observer2);"); |
- instance->Set(5, String::NewFromUtf8(isolate.GetIsolate(), "bar")); |
- instance->Set(String::NewFromUtf8(isolate.GetIsolate(), "foo"), |
- String::NewFromUtf8(isolate.GetIsolate(), "bar")); |
+ instance->Set(5, String::NewFromUtf8(CcTest::isolate(), "bar")); |
+ instance->Set(String::NewFromUtf8(CcTest::isolate(), "foo"), |
+ String::NewFromUtf8(CcTest::isolate(), "bar")); |
CompileRun(""); // trigger delivery |
const RecordExpectation expected_records2[] = { |
{ instance, "add", "5", Handle<Value>() }, |
@@ -749,18 +712,17 @@ TEST(AccessCheckDisallowApiModifications) { |
TEST(HiddenPropertiesLeakage) { |
- HarmonyIsolate isolate; |
- HandleScope scope(isolate.GetIsolate()); |
- LocalContext context(isolate.GetIsolate()); |
+ HandleScope scope(CcTest::isolate()); |
+ LocalContext context(CcTest::isolate()); |
CompileRun("var obj = {};" |
"var records = null;" |
"var observer = function(r) { records = r };" |
"Object.observe(obj, observer);"); |
Handle<Value> obj = |
- context->Global()->Get(String::NewFromUtf8(isolate.GetIsolate(), "obj")); |
+ context->Global()->Get(String::NewFromUtf8(CcTest::isolate(), "obj")); |
Handle<Object>::Cast(obj) |
- ->SetHiddenValue(String::NewFromUtf8(isolate.GetIsolate(), "foo"), |
- Null(isolate.GetIsolate())); |
+ ->SetHiddenValue(String::NewFromUtf8(CcTest::isolate(), "foo"), |
+ Null(CcTest::isolate())); |
CompileRun(""); // trigger delivery |
CHECK(CompileRun("records")->IsNull()); |
} |