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

Unified Diff: test/unittests/api/v8-object-unittest.cc

Issue 2973593002: Revert of Set the current context to the function's context when entering to LAP. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « src/x87/code-stubs-x87.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/api/v8-object-unittest.cc
diff --git a/test/unittests/api/v8-object-unittest.cc b/test/unittests/api/v8-object-unittest.cc
index 4f4d9e87de714dee0cea60f7be64506f019e3f45..2e7ab350ea38c5283a8574275457642284201f6e 100644
--- a/test/unittests/api/v8-object-unittest.cc
+++ b/test/unittests/api/v8-object-unittest.cc
@@ -3,8 +3,6 @@
// found in the LICENSE file.
#include "include/v8.h"
-#include "src/api.h"
-#include "src/objects-inl.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -35,74 +33,5 @@
ASSERT_FALSE(try_catch.HasCaught());
}
-using LapContextTest = TestWithIsolate;
-
-TEST_F(LapContextTest, CurrentContextMustBeFunctionContext) {
- // The receiver object is created in |receiver_context|, but its prototype
- // object is created in |prototype_context|, and the property is accessed
- // from |caller_context|.
- Local<Context> receiver_context = Context::New(isolate());
- Local<Context> prototype_context = Context::New(isolate());
- Local<Context> caller_context = Context::New(isolate());
-
- Local<FunctionTemplate> function_template = FunctionTemplate::New(isolate());
- Local<Signature> signature = Signature::New(isolate(), function_template);
- Local<String> property_key =
- String::NewFromUtf8(isolate(), "property", NewStringType::kNormal)
- .ToLocalChecked();
- Local<FunctionTemplate> get_or_set = FunctionTemplate::New(
- isolate(),
- [](const FunctionCallbackInfo<Value>& info) {
- Local<Context> prototype_context = *reinterpret_cast<Local<Context>*>(
- info.Data().As<External>()->Value());
- EXPECT_EQ(prototype_context, info.GetIsolate()->GetCurrentContext());
- },
- External::New(isolate(), &prototype_context), signature);
- function_template->PrototypeTemplate()->SetAccessorProperty(
- property_key, get_or_set, get_or_set);
-
- // |object| is created in |receiver_context|, and |prototype| is created
- // in |prototype_context|. And then, object.__proto__ = prototype.
- Local<Function> interface_for_receiver =
- function_template->GetFunction(receiver_context).ToLocalChecked();
- Local<Function> interface_for_prototype =
- function_template->GetFunction(prototype_context).ToLocalChecked();
- Local<String> prototype_key =
- String::NewFromUtf8(isolate(), "prototype", NewStringType::kNormal)
- .ToLocalChecked();
- Local<Object> prototype =
- interface_for_prototype->Get(caller_context, prototype_key)
- .ToLocalChecked()
- .As<Object>();
- Local<Object> object =
- interface_for_receiver->NewInstance(receiver_context).ToLocalChecked();
- object->SetPrototype(caller_context, prototype).ToChecked();
- EXPECT_EQ(receiver_context, object->CreationContext());
- EXPECT_EQ(prototype_context, prototype->CreationContext());
-
- object->Get(caller_context, property_key).ToLocalChecked();
- object->Set(caller_context, property_key, Null(isolate())).ToChecked();
-
- // Test with a compiled version.
- Local<String> object_key =
- String::NewFromUtf8(isolate(), "object", NewStringType::kNormal)
- .ToLocalChecked();
- caller_context->Global()->Set(caller_context, object_key, object).ToChecked();
- const char script[] =
- "function f() { object.property; object.property = 0; } "
- "f(); f(); "
- "%OptimizeFunctionOnNextCall(f); "
- "f();";
- Context::Scope scope(caller_context);
- internal::FLAG_allow_natives_syntax = true;
- Script::Compile(
- caller_context,
- String::NewFromUtf8(isolate(), script, v8::NewStringType::kNormal)
- .ToLocalChecked())
- .ToLocalChecked()
- ->Run(caller_context)
- .ToLocalChecked();
-}
-
} // namespace
} // namespace v8
« no previous file with comments | « src/x87/code-stubs-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698