Skip to content

Commit

Permalink
Fix for #616 (#617)
Browse files Browse the repository at this point in the history
No longer prematurely throws a TypeError for non-extensible objects.

Affects strict mode only.

No longer prematurely throws a TypeError in ScriptableObject.putImpl(Object,int,Scriptable,Object) when instance member isExtensible is false.

Instead, now it first queries the slotmap, so that if a GetterSlot instance is returned, any present setter may be called. All other outcomes of this method should be unaffected.
  • Loading branch information
stijnkliemesch authored and gbrail committed Nov 25, 2019
1 parent bee350c commit 7c68424
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
10 changes: 4 additions & 6 deletions src/org/mozilla/javascript/ScriptableObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -2804,20 +2804,18 @@ private boolean putImpl(Object key, int index, Scriptable start,
{
// This method is very hot (basically called on each assignment)
// so we inline the extensible/sealed checks below.
if (!isExtensible) {
Context cx = Context.getContext();
if (cx.isStrictMode()) {
throw ScriptRuntime.typeError0("msg.not.extensible");
}
}
Slot slot;
if (this != start) {
slot = slotMap.query(key, index);
if(!isExtensible && Context.getContext().isStrictMode() && (slot == null || !(slot instanceof GetterSlot)))
throw ScriptRuntime.typeError0("msg.not.extensible");
if (slot == null) {
return false;
}
} else if (!isExtensible) {
slot = slotMap.query(key, index);
if(Context.getContext().isStrictMode() && (slot == null || !(slot instanceof GetterSlot)))
throw ScriptRuntime.typeError0("msg.not.extensible");
if (slot == null) {
return true;
}
Expand Down
3 changes: 0 additions & 3 deletions testsrc/test262.properties
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,6 @@ built-ins/Object
! entries/tamper-with-object-keys.js
! freeze/15.2.3.9-2-a-12.js
! freeze/15.2.3.9-2-a-8.js
! freeze/15.2.3.9-2-c-2.js
! freeze/15.2.3.9-2-c-3.js
! freeze/15.2.3.9-2-c-4.js
! freeze/15.2.3.9-2-d-3.js
! freeze/frozen-object-contains-symbol-properties-non-strict.js
! getOwnPropertyDescriptor/15.2.3.3-3-14.js
Expand Down

0 comments on commit 7c68424

Please sign in to comment.