Skip to content

Commit

Permalink
IE 9 preventExtensions doesn't throw, even in strict mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed May 31, 2015
1 parent 8c1af05 commit d0edcc8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions test/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,23 @@ describe('Object', function () {

// Firefox 37 still has "pending exception" logic in its Object.assign implementation,
// which is 72% slower than our shim, and Firefox 40's native implementation.
var thrower = Object.preventExtensions({ 1: 2 });
var thrower = Object.preventExtensions({ 1: 2, 2: 3, 3: 4 });
Object.defineProperty(thrower, 2, {
get: function () { return 3; },
set: function (v) { throw new RangeError('IE 9 does not throw on preventExtensions'); }
});
var error;
try { Object.assign(thrower, 'xy'); } catch (e) { error = e; }
expect(error).to.be.an.instanceOf(TypeError);
expect(thrower).to.have.property(1, 2);
try { Object.assign(thrower, 'wxyz'); } catch (e) { error = e; }
expect(thrower).not.to.have.property(0);
if (thrower[1] === 'x') {
// IE 9 doesn't throw in strict mode with preventExtensions
expect(error).to.be.an.instanceOf(RangeError);
} else {
expect(error).to.be.an.instanceOf(TypeError);
expect(thrower).to.have.property(1, 2);
}
expect(thrower).to.have.property(2, 3);
expect(thrower).to.have.property(3, 4);
});

ifSymbolsIt('includes enumerable symbols, after keys', function () {
Expand Down

0 comments on commit d0edcc8

Please sign in to comment.