(path, obj, permit)
| 4129 | * Visit all properties for a permit. |
| 4130 | */ |
| 4131 | function visitProperties(path, obj, permit) { |
| 4132 | if( obj=== undefined|| obj=== null) { |
| 4133 | return; |
| 4134 | } |
| 4135 | |
| 4136 | const protoName= permit['[[Proto]]']; |
| 4137 | visitPrototype(path, obj, protoName); |
| 4138 | |
| 4139 | if( typeof obj=== 'function') { |
| 4140 | markVirtualizedNativeFunction(obj); |
| 4141 | } |
| 4142 | |
| 4143 | for( const prop of ownKeys(obj)) { |
| 4144 | const propString= asStringPropertyName(path, prop); |
| 4145 | const subPath= `${path}.${propString}`; |
| 4146 | const subPermit= getSubPermit(obj, permit, propString); |
| 4147 | |
| 4148 | if( !subPermit|| !isAllowedProperty(subPath, obj, prop, subPermit)) { |
| 4149 | // Either the object lacks a permit or the object doesn't match the |
| 4150 | // permit. |
| 4151 | // If the permit is specifically false, not merely undefined, |
| 4152 | // this is a property we expect to see because we know it exists in |
| 4153 | // some environments and we have expressly decided to exclude it. |
| 4154 | // Any other disallowed property is one we have not audited and we log |
| 4155 | // that we are removing it so we know to look into it, as happens when |
| 4156 | // the language evolves new features to existing intrinsics. |
| 4157 | if( subPermit!== false) { |
| 4158 | inConsoleGroup('warn', `Removing ${subPath}`); |
| 4159 | } |
| 4160 | try { |
| 4161 | delete obj[prop]; |
| 4162 | }catch( err) { |
| 4163 | if( prop in obj) { |
| 4164 | if( typeof obj=== 'function'&& prop=== 'prototype') { |
| 4165 | obj.prototype= undefined; |
| 4166 | if( obj.prototype=== undefined) { |
| 4167 | inConsoleGroup( |
| 4168 | 'warn', |
| 4169 | `Tolerating undeletable ${subPath} === undefined`); |
| 4170 | |
| 4171 | // eslint-disable-next-line no-continue |
| 4172 | continue; |
| 4173 | } |
| 4174 | } |
| 4175 | inConsoleGroup('error', `failed to delete ${subPath}`,err); |
| 4176 | }else { |
| 4177 | inConsoleGroup('error', `deleting ${subPath} threw`,err); |
| 4178 | } |
| 4179 | throw err; |
| 4180 | } |
| 4181 | } |
| 4182 | } |
| 4183 | } |
| 4184 | |
| 4185 | try { |
| 4186 | // Start path with 'intrinsics' to clarify that properties are not |
no test coverage detected