File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,14 @@ class ContextifyContext {
125
125
int length = names->Length ();
126
126
for (int i = 0 ; i < length; i++) {
127
127
Local<String> key = names->Get (i)->ToString (env ()->isolate ());
128
- bool has = sandbox_obj->HasOwnProperty (context, key).FromJust ();
128
+ auto maybe_has = sandbox_obj->HasOwnProperty (context, key);
129
+
130
+ // Check for pending exceptions
131
+ if (!maybe_has.IsJust ())
132
+ break ;
133
+
134
+ bool has = maybe_has.FromJust ();
135
+
129
136
if (!has) {
130
137
// Could also do this like so:
131
138
//
Original file line number Diff line number Diff line change @@ -16,3 +16,16 @@ sandbox = { Proxy: Proxy };
16
16
vm . runInNewContext ( 'this.Proxy = Proxy' , sandbox ) ;
17
17
assert . strictEqual ( typeof sandbox . Proxy , 'function' ) ;
18
18
assert . strictEqual ( sandbox . Proxy , Proxy ) ;
19
+
20
+ // Handle a sandbox that throws while copying properties
21
+ assert . throws ( ( ) => {
22
+ const handler = {
23
+ getOwnPropertyDescriptor : ( target , prop ) => {
24
+ throw new Error ( 'whoops' ) ;
25
+ }
26
+ } ;
27
+ const sandbox = new Proxy ( { foo : 'bar' } , handler ) ;
28
+ const context = vm . createContext ( sandbox ) ;
29
+
30
+ vm . runInContext ( '' , context ) ;
31
+ } , / w h o o p s / ) ;
You can’t perform that action at this time.
0 commit comments