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

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

Issue 1432543002: Treat failed access checks for @@toStringTag as undefined (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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/heap/heap.h ('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 1d38756438e319ce0a66af324bd80b403406281f..646f868968737b06a0a70eb0ca969ca6bed41ab8 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -22018,6 +22018,34 @@ TEST(AccessCheckedIsConcatSpreadable) {
}
+TEST(AccessCheckedToStringTag) {
+ i::FLAG_harmony_tostring = true;
+ v8::Isolate* isolate = CcTest::isolate();
+ HandleScope scope(isolate);
+ LocalContext env;
+
+ // Object with access check
+ Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate);
+ object_template->SetAccessCheckCallback(AccessBlocker);
+ Local<Object> object = object_template->NewInstance();
+
+ allowed_access = true;
+ env->Global()->Set(v8_str("object"), object);
+ object->Set(v8::Symbol::GetToStringTag(isolate), v8_str("hello"));
+
+ // Access check is allowed, and the toStringTag is read
+ CompileRun("var result = Object.prototype.toString.call(object)");
+ ExpectString("result", "[object hello]");
+ ExpectString("object[Symbol.toStringTag]", "hello");
+
+ // If access check fails, the value of @@toStringTag is ignored
+ allowed_access = false;
+ CompileRun("var result = Object.prototype.toString.call(object)");
+ ExpectString("result", "[object Object]");
+ ExpectTrue("object[Symbol.toStringTag] === undefined");
+}
+
+
TEST(ObjectTemplateIntrinsics) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698