archives

« Bugzilla Issues Index

#104 — Missing coverage? https://bugzilla.mozilla.org/show_bug.cgi?id=637994


<Thanks>Mark Miller</Thanks>

We might be missing coverage for the following test scenario. Add test case(s) assuming this scenario can be mapped to ES5.1 somewhere
--------------------------------------------------------------------------
*See http://codereview.appspot.com/4547070/diff/6003/src/com/google/caja/ses/es5shim.js?context=10&column_width=80 for the original*

310 * Work arond for https://bugzilla.mozilla.org/show_bug.cgi?id=637994

311 *

312 * <p>On Firefoxes at least 4 through 7.0a1, an inherited

313 * non-configurable accessor property appears to be an own property

314 * of all objects which inherit this accessor property.

315 *

316 * <p>Our workaround wraps hasOwnProperty, getOwnPropertyNames, and

317 * getOwnPropertyDescriptor to heuristically decide when an accessor

318 * property looks like it is apparently own because of this bug, and

319 * suppress reporting its existence.

320 *

321 * <p>However, it is not feasible to likewise wrap JSON.stringify,

322 * and this bug will cause JSON.stringify to be misled by inherited

323 * enumerable non-configurable accessor properties. To prevent this,

324 * we wrap defineProperty, freeze, and seal to prevent the creation

325 * of <i>enumerable</i> non-configurable accessor properties on

326 * those platforms with this bug.

327 *

328 * <p>A little known fast about JavaScript is that

329 * Object.prototype.propertyIsEnumerable actually tests whether a

330 * property is both own and enumerable. Assuming that our wrapping

331 * of defineProperty, freeze, and seal prevents the occurrence of an

332 * enumerable non-configurable accessor property, it should also

333 * prevent the occurrence of this bug for any enumerable property,

334 * and so we do not need to wrap propertyIsEnumerable.

335 *

336 * <p>This kludge seems to be safety preserving, but the issues are

337 * delicate and not well understood.

338 */

339 function test_ACCESSORS_INHERIT_AS_OWN() {

340 var base = {};

341 var derived = Object.create(base);

342 function getter() { return 'gotten'; }

343 Object.defineProperty(base, 'foo', {get: getter});

344 if (!derived.hasOwnProperty('foo') &&

345 Object.getOwnPropertyDescriptor(derived, 'foo') === undefined &&

346 Object.getOwnPropertyNames(derived).indexOf('foo') < 0) {

347 return false;

348 }

349 if (derived.hasOwnProperty('foo') &&

350 Object.getOwnPropertyDescriptor(derived, 'foo').get === getter &&

351 Object.getOwnPropertyNames(derived).indexOf('foo') >= 0) {

352 log('Accessor properties inherit as own properties. ' +

353 'See https://bugzilla.mozilla.org/show_bug.cgi?id=637994');

354 } else {

355 log('New symptom: ' +

356 'Accessor properties partially inherit as own properties.');

357 }

358 Object.defineProperty(base, 'bar', {get: getter, configurable: true});

359 if (!derived.hasOwnProperty('bar') &&

360 Object.getOwnPropertyDescriptor(derived, 'bar') === undefined &&

361 Object.getOwnPropertyNames(derived).indexOf('bar') < 0) {

362 return true;

363 }

364 log('New symptom: ' +

365 'Accessor properties inherit as own even if configurable.');

366 return true;

367 }

368 //var TOLERATE_ACCESSORS_INHERIT_AS_OWN = false;

369 var TOLERATE_ACCESSORS_INHERIT_AS_OWN = test_ACCESSORS_INHERIT_AS_OWN();


I can find very little coverage for Object.hasOwnProperty (none for this scenario) and no targeted coverage for [[GetOwnProperty]].


About 50 new tests for 8.12.1 have been written. These will be distributed to test262 with the next set of test contributions from Microsoft.


Tests are now live on test262.ecmascript.org.