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

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

Issue 1856123005: Convert receiver when calling an Api accessor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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/execution.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 506894a96a385d0acc0cbdf687e1f0144c9689e3..6bea3eaefee603ed7bc02a56be251082ba6ad27a 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -24658,6 +24658,53 @@ TEST(CompatibleReceiverCheckOnCachedICHandler) {
0);
}
+THREADED_TEST(ReceiverConversionForAccessors) {
+ LocalContext env;
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ Local<v8::FunctionTemplate> acc =
+ v8::FunctionTemplate::New(isolate, Returns42);
+ CHECK(env->Global()
+ ->Set(env.local(), v8_str("acc"),
+ acc->GetFunction(env.local()).ToLocalChecked())
+ .FromJust());
+
+ Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
+ templ->SetAccessorProperty(v8_str("acc"), acc, acc);
+ Local<v8::Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
+
+ CHECK(env->Global()->Set(env.local(), v8_str("p"), instance).FromJust());
+ CHECK(CompileRun("(p.acc == 42)")->BooleanValue(env.local()).FromJust());
+ CHECK(CompileRun("(p.acc = 7) == 7")->BooleanValue(env.local()).FromJust());
+
+ CHECK(!CompileRun("Number.prototype.__proto__ = p;"
+ "var a = 1;")
+ .IsEmpty());
+ CHECK(CompileRun("(a.acc == 42)")->BooleanValue(env.local()).FromJust());
+ CHECK(CompileRun("(a.acc = 7) == 7")->BooleanValue(env.local()).FromJust());
+
+ CHECK(!CompileRun("Boolean.prototype.__proto__ = p;"
+ "var a = true;")
+ .IsEmpty());
+ CHECK(CompileRun("(a.acc == 42)")->BooleanValue(env.local()).FromJust());
+ CHECK(CompileRun("(a.acc = 7) == 7")->BooleanValue(env.local()).FromJust());
+
+ CHECK(!CompileRun("String.prototype.__proto__ = p;"
+ "var a = 'foo';")
+ .IsEmpty());
+ CHECK(CompileRun("(a.acc == 42)")->BooleanValue(env.local()).FromJust());
+ CHECK(CompileRun("(a.acc = 7) == 7")->BooleanValue(env.local()).FromJust());
+
+ CHECK(CompileRun("acc.call(1) == 42")->BooleanValue(env.local()).FromJust());
+ CHECK(CompileRun("acc.call(true)==42")->BooleanValue(env.local()).FromJust());
+ CHECK(CompileRun("acc.call('aa')==42")->BooleanValue(env.local()).FromJust());
+ CHECK(
+ CompileRun("acc.call(null) == 42")->BooleanValue(env.local()).FromJust());
+ CHECK(CompileRun("acc.call(undefined) == 42")
+ ->BooleanValue(env.local())
+ .FromJust());
+}
+
class FutexInterruptionThread : public v8::base::Thread {
public:
explicit FutexInterruptionThread(v8::Isolate* isolate)
« no previous file with comments | « src/execution.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698