@@ -346,14 +346,21 @@ class ContextifyContext {
346
346
return ;
347
347
348
348
auto attributes = PropertyAttribute::None;
349
- bool is_declared = ctx->global_proxy ()
349
+ bool is_declared_on_global_proxy = ctx->global_proxy ()
350
350
->GetRealNamedPropertyAttributes (ctx->context (), property)
351
351
.To (&attributes);
352
352
bool read_only =
353
353
static_cast <int >(attributes) &
354
354
static_cast <int >(PropertyAttribute::ReadOnly);
355
355
356
- if (is_declared && read_only)
356
+ bool is_declared_on_sandbox = ctx->sandbox ()
357
+ ->GetRealNamedPropertyAttributes (ctx->context (), property)
358
+ .To (&attributes);
359
+ read_only = read_only ||
360
+ (static_cast <int >(attributes) &
361
+ static_cast <int >(PropertyAttribute::ReadOnly));
362
+
363
+ if (read_only)
357
364
return ;
358
365
359
366
// true for x = 5
@@ -371,10 +378,20 @@ class ContextifyContext {
371
378
// this.f = function() {}, is_contextual_store = false.
372
379
bool is_function = value->IsFunction ();
373
380
381
+ bool is_declared = is_declared_on_global_proxy || is_declared_on_sandbox;
374
382
if (!is_declared && args.ShouldThrowOnError () && is_contextual_store &&
375
383
!is_function)
376
384
return ;
377
385
386
+ if (!is_declared_on_global_proxy && is_declared_on_sandbox &&
387
+ args.ShouldThrowOnError () && is_contextual_store && !is_function) {
388
+ // The property exists on the sandbox but not on the global
389
+ // proxy. Setting it would throw because we are in strict mode.
390
+ // Don't attempt to set it by signaling that the call was
391
+ // intercepted. Only change the value on the sandbox.
392
+ args.GetReturnValue ().Set (false );
393
+ }
394
+
378
395
ctx->sandbox ()->Set (property, value);
379
396
}
380
397
0 commit comments