🐛 lazy added non-configurable props should be reported as configurable to avoid TypeError (#953)
This commit is contained in:
parent
969761a11b
commit
b0f5a73f87
|
|
@ -135,6 +135,13 @@ test('descriptor of non-configurable and non-enumerable property existed in raw
|
|||
});
|
||||
});
|
||||
|
||||
test('A property cannot be reported as non-configurable, if it does not exists as an own property of the target object', () => {
|
||||
const { proxy } = new ProxySandbox('non-configurable');
|
||||
Object.defineProperty(window, 'nonConfigurablePropAfterSandboxCreated', { value: 'test', configurable: false });
|
||||
const descriptor = Object.getOwnPropertyDescriptor(proxy, 'nonConfigurablePropAfterSandboxCreated');
|
||||
expect(descriptor?.configurable).toBeTruthy();
|
||||
});
|
||||
|
||||
test('property added by Object.defineProperty should works as expect', () => {
|
||||
const { proxy } = new ProxySandbox('object-define-property-test');
|
||||
|
||||
|
|
|
|||
|
|
@ -219,6 +219,10 @@ export default class ProxySandbox implements SandBox {
|
|||
if (rawWindow.hasOwnProperty(p)) {
|
||||
const descriptor = Object.getOwnPropertyDescriptor(rawWindow, p);
|
||||
descriptorTargetMap.set(p, 'rawWindow');
|
||||
// A property cannot be reported as non-configurable, if it does not exists as an own property of the target object
|
||||
if (descriptor && !descriptor.configurable) {
|
||||
descriptor.configurable = true;
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user