Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow Harmony Proxies to work correctly as sandboxes #23

Closed
wants to merge 4 commits into from

2 participants

@Benvie

It didn't take much to get this working correctly. There may be some other stuff that should be updated to work more "correctly" with proxies but this at least gets them working and hitting the right traps.

@brianmcd
Owner

@Benvie I'm a terrible person and let this sit for a year. Is this still something you'd like to see in Contextify?

@brianmcd brianmcd closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 5 deletions.
  1. +8 −5 src/contextify.cc
View
13 src/contextify.cc
@@ -92,11 +92,12 @@ class ContextifyContext : ObjectWrap {
Local<String> msg = String::New("Wrong number of arguments passed to ContextifyContext constructor");
return ThrowException(Exception::Error(msg));
}
- if (!args[0]->IsObject()) {
+ Local<Object> sandbox = args[0]->ToObject();
+ if (sandbox->IsNull() || sandbox->IsUndefined()) {
Local<String> msg = String::New("Argument to ContextifyContext constructor must be an object.");
return ThrowException(Exception::Error(msg));
}
- ContextifyContext* ctx = new ContextifyContext(args[0]->ToObject());
+ ContextifyContext* ctx = new ContextifyContext(sandbox);
ctx->Wrap(args.This());
return args.This();
}
@@ -161,8 +162,10 @@ class ContextifyContext : ObjectWrap {
HandleScope scope;
Local<Object> data = accessInfo.Data()->ToObject();
ContextifyContext* ctx = ObjectWrap::Unwrap<ContextifyContext>(data);
- Local<Value> rv = ctx->sandbox->GetRealNamedProperty(property);
- if (rv.IsEmpty()) {
+ Local<Value> rv;
+ if (ctx->sandbox->Has(property)) {
+ rv = ctx->sandbox->Get(property);
+ } else {
rv = ctx->proxyGlobal->GetRealNamedProperty(property);
}
return scope.Close(rv);
@@ -183,7 +186,7 @@ class ContextifyContext : ObjectWrap {
HandleScope scope;
Local<Object> data = accessInfo.Data()->ToObject();
ContextifyContext* ctx = ObjectWrap::Unwrap<ContextifyContext>(data);
- if (!ctx->sandbox->GetRealNamedProperty(property).IsEmpty() ||
+ if (ctx->sandbox->Has(property) ||
!ctx->proxyGlobal->GetRealNamedProperty(property).IsEmpty()) {
return scope.Close(Integer::New(None));
}
Something went wrong with that request. Please try again.