| 426 | } |
| 427 | |
| 428 | defineProperty_(obj, propertyKey, descriptor) { |
| 429 | this.defineProperties_.push({ |
| 430 | obj, |
| 431 | propertyKey, |
| 432 | descriptor: Object.getOwnPropertyDescriptor(obj, propertyKey), |
| 433 | }); |
| 434 | |
| 435 | if (descriptor) { |
| 436 | if (descriptor.configurable === false) { |
| 437 | throw new Error( |
| 438 | `sandbox.defineProperty(${obj.constructor.name},${propertyKey},{configurable=false}); ` + |
| 439 | `With configurable=false, you will not be able to restore the property!` |
| 440 | ); |
| 441 | } |
| 442 | descriptor.configurable = true; |
| 443 | Object.defineProperty(obj, propertyKey, descriptor); |
| 444 | } else { |
| 445 | delete obj[propertyKey]; |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | restoreDefineProperty_() { |
| 450 | this.defineProperties_.forEach((item) => { |