Allow eval in detached contexts
BUG= Review URL: https://codereview.chromium.org/781953002 Cr-Commit-Position: refs/heads/master@{#25686}
This commit is contained in:
parent
4c7effe56e
commit
7fb5f74d20
@ -1368,16 +1368,6 @@ RUNTIME_FUNCTION(Runtime_GlobalProxy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RUNTIME_FUNCTION(Runtime_IsAttachedGlobal) {
|
|
||||||
SealHandleScope shs(isolate);
|
|
||||||
DCHECK(args.length() == 1);
|
|
||||||
CONVERT_ARG_CHECKED(Object, global, 0);
|
|
||||||
if (!global->IsJSGlobalObject()) return isolate->heap()->false_value();
|
|
||||||
return isolate->heap()->ToBoolean(
|
|
||||||
!JSGlobalObject::cast(global)->IsDetached());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RUNTIME_FUNCTION(Runtime_LookupAccessor) {
|
RUNTIME_FUNCTION(Runtime_LookupAccessor) {
|
||||||
HandleScope scope(isolate);
|
HandleScope scope(isolate);
|
||||||
DCHECK(args.length() == 3);
|
DCHECK(args.length() == 3);
|
||||||
|
@ -254,7 +254,6 @@ namespace internal {
|
|||||||
\
|
\
|
||||||
/* Eval */ \
|
/* Eval */ \
|
||||||
F(GlobalProxy, 1, 1) \
|
F(GlobalProxy, 1, 1) \
|
||||||
F(IsAttachedGlobal, 1, 1) \
|
|
||||||
\
|
\
|
||||||
F(AddNamedProperty, 4, 1) \
|
F(AddNamedProperty, 4, 1) \
|
||||||
F(AddPropertyForTemplate, 4, 1) \
|
F(AddPropertyForTemplate, 4, 1) \
|
||||||
|
@ -163,16 +163,6 @@ function GlobalParseFloat(string) {
|
|||||||
function GlobalEval(x) {
|
function GlobalEval(x) {
|
||||||
if (!IS_STRING(x)) return x;
|
if (!IS_STRING(x)) return x;
|
||||||
|
|
||||||
// For consistency with JSC we require the global object passed to
|
|
||||||
// eval to be the global object from which 'eval' originated. This
|
|
||||||
// is not mandated by the spec.
|
|
||||||
// We only throw if the global has been detached, since we need the
|
|
||||||
// receiver as this-value for the call.
|
|
||||||
if (!%IsAttachedGlobal(global)) {
|
|
||||||
throw new $EvalError('The "this" value passed to eval must ' +
|
|
||||||
'be the global object from which eval originated');
|
|
||||||
}
|
|
||||||
|
|
||||||
var global_proxy = %GlobalProxy(global);
|
var global_proxy = %GlobalProxy(global);
|
||||||
|
|
||||||
var f = %CompileString(x, false, 0);
|
var f = %CompileString(x, false, 0);
|
||||||
|
@ -11549,8 +11549,7 @@ THREADED_TEST(CrossEval) {
|
|||||||
|
|
||||||
|
|
||||||
// Test that calling eval in a context which has been detached from
|
// Test that calling eval in a context which has been detached from
|
||||||
// its global throws an exception. This behavior is consistent with
|
// its global proxy works.
|
||||||
// other JavaScript implementations.
|
|
||||||
THREADED_TEST(EvalInDetachedGlobal) {
|
THREADED_TEST(EvalInDetachedGlobal) {
|
||||||
v8::Isolate* isolate = CcTest::isolate();
|
v8::Isolate* isolate = CcTest::isolate();
|
||||||
v8::HandleScope scope(isolate);
|
v8::HandleScope scope(isolate);
|
||||||
@ -11578,8 +11577,7 @@ THREADED_TEST(EvalInDetachedGlobal) {
|
|||||||
context0->DetachGlobal();
|
context0->DetachGlobal();
|
||||||
v8::TryCatch catcher;
|
v8::TryCatch catcher;
|
||||||
x_value = CompileRun("fun('x')");
|
x_value = CompileRun("fun('x')");
|
||||||
CHECK(x_value.IsEmpty());
|
CHECK_EQ(42, x_value->Int32Value());
|
||||||
CHECK(catcher.HasCaught());
|
|
||||||
context1->Exit();
|
context1->Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user