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

Unified Diff: test/cctest/test-api.cc

Issue 1230793002: [es6] silence access-check failure for well-known symbol properties (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: change test slightly Created 5 years, 5 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
« src/objects.h ('K') | « src/runtime/runtime-array.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-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 2bfdeabd42cd606a40e8242d120465dc0414a0ab..6b27f9c8d4f4df8543580e180acf308b4c8eea5e 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -21855,3 +21855,61 @@ TEST(CompatibleReceiverCheckOnCachedICHandler) {
"result;\n",
0);
}
+
+
+static bool AccessSymbolsAlwaysBlocked(Local<v8::Object> global,
+ Local<Value> name, v8::AccessType type,
+ Local<Value> data) {
+ if (!name->IsSymbol()) return true;
+ i::PrintF("Access blocked.\n");
+ return false;
+}
+
+
+THREADED_TEST(Regress507553) {
+ v8::Isolate* isolate = CcTest::isolate();
+ HandleScope scope(isolate);
+
+ // Template for object with security check.
+ Local<ObjectTemplate> spreadable_template = v8::ObjectTemplate::New(isolate);
+ spreadable_template->SetAccessCheckCallbacks(AccessSymbolsAlwaysBlocked,
+ NULL);
+
+ // Context for "foreign" objects used in test.
+ Local<Context> context = v8::Context::New(isolate);
+ context->Enter();
+
+ // Object with explicit security check.
+ Local<Object> protected_object = spreadable_template->NewInstance();
+
+ // JSGlobalProxy object, always have security check.
+ Local<Object> proxy_object = context->Global();
+
+ // Global object, the prototype of proxy_object. No security checks.
+ Local<Object> global_object = proxy_object->GetPrototype()->ToObject(isolate);
+
+ spreadable_template->Set(v8::Symbol::GetIsConcatSpreadable(isolate),
+ v8::Boolean::New(isolate, true));
+
+ protected_object->Set(v8_str("length"), v8::Integer::New(isolate, 2));
+ protected_object->Set(0U, v8_str("a"));
+ protected_object->Set(1U, v8_str("b"));
+
+ Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate);
+ global_template->Set(v8_str("protected"), protected_object);
+ global_template->Set(v8_str("global"), global_object);
+
+ context->Exit();
+
+ LocalContext context2(NULL, global_template);
+
+ Local<Value> result1 = CompileRun("[].concat(protected)");
+ CHECK(result1->IsArray());
+ CHECK(result1.As<Object>()->Get(0)->Equals(protected_object));
+
+ Local<Value> result2 = CompileRun("[].concat([global, global], protected)");
caitp (gmail) 2015/07/09 14:49:41 This is probably not doing what I want it to do I
adamk 2015/07/09 15:56:04 Is the idea just to check that the check is doing
caitp (gmail) 2015/07/09 16:02:09 Per spec, if @@isConcatSpreadable is undefined, bu
adamk 2015/07/09 17:17:25 I see what you're aiming for, but Arrays are never
caitp (gmail) 2015/07/09 18:43:15 oops, https://codereview.chromium.org/1230793002/#
+ CHECK(result2->IsArray());
+ CHECK(result2.As<Object>()->Get(0)->Equals(global_object));
+ CHECK(result2.As<Object>()->Get(1)->Equals(global_object));
+ CHECK(result2.As<Object>()->Get(2)->Equals(protected_object));
+}
« src/objects.h ('K') | « src/runtime/runtime-array.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698