(ExecutionContext context, String name, PropertyDescriptor desc, boolean shouldThrow)
| 322 | } |
| 323 | |
| 324 | @Override |
| 325 | public boolean defineOwnProperty(ExecutionContext context, String name, PropertyDescriptor desc, boolean shouldThrow) { |
| 326 | // 8.12.9 |
| 327 | Object c = getOwnProperty(context, name, false); |
| 328 | |
| 329 | if (c == Types.UNDEFINED) { |
| 330 | if (!isExtensible()) { |
| 331 | return reject(context, shouldThrow); |
| 332 | } else { |
| 333 | // System.err.println("DEF.initial: " + name + " > " + newDesc); |
| 334 | this.properties.put(name, desc.duplicateWithDefaults()); |
| 335 | return true; |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | if (desc.isEmpty()) { |
| 340 | return true; |
| 341 | } |
| 342 | |
| 343 | PropertyDescriptor current = (PropertyDescriptor) c; |
| 344 | |
| 345 | if (current.hasConfigurable() && !current.isConfigurable()) { |
| 346 | if (desc.hasConfigurable() && desc.isConfigurable()) { |
| 347 | return reject(context, shouldThrow); |
| 348 | } |
| 349 | |
| 350 | if (current.hasEnumerable() && desc.hasEnumerable() && current.isEnumerable() != desc.isEnumerable()) { |
| 351 | return reject(context, shouldThrow); |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | PropertyDescriptor newDesc = null; |
| 356 | |
| 357 | if (desc.isGenericDescriptor()) { |
| 358 | newDesc = new PropertyDescriptor(); |
| 359 | newDesc.copyAll(current); |
| 360 | // System.err.println("DEF.generic: " + name + " > " + newDesc); |
| 361 | } else if (current.isDataDescriptor() != desc.isDataDescriptor()) { |
| 362 | if (!current.isConfigurable()) { |
| 363 | return reject(context, shouldThrow); |
| 364 | } |
| 365 | if (current.isDataDescriptor()) { |
| 366 | // System.err.println("accessor"); |
| 367 | newDesc = PropertyDescriptor.newAccessorPropertyDescriptor(); |
| 368 | } else { |
| 369 | // System.err.println("data"); |
| 370 | newDesc = PropertyDescriptor.newDataPropertyDescriptor(); |
| 371 | } |
| 372 | // System.err.println("DEF.mismatch: " + name + " > " + newDesc); |
| 373 | } else if (current.isDataDescriptor() && desc.isDataDescriptor()) { |
| 374 | if (!current.isConfigurable()) { |
| 375 | if (current.hasWritable() && !current.isWritable()) { |
| 376 | if (desc.isWritable()) { |
| 377 | return reject(context, shouldThrow); |
| 378 | } |
| 379 | Object newValue = desc.getValue(); |
| 380 | if (newValue != null && !Types.sameValue(current.getValue(), newValue)) { |
| 381 | return reject(context, shouldThrow); |
no test coverage detected