Skip to content

Commit

Permalink
Array.of has to use defineOwnProperty instead of set (found while wor…
Browse files Browse the repository at this point in the history
…king on proxy support)
  • Loading branch information
rbri authored and gbrail committed Aug 26, 2023
1 parent 6fe4ac6 commit b41a111
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/org/mozilla/javascript/NativeArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,16 @@ private static Object js_of(Context cx, Scriptable scope, Scriptable thisObj, Ob
final Scriptable result =
callConstructorOrCreateArray(cx, scope, thisObj, args.length, true);

for (int i = 0; i < args.length; i++) {
defineElem(cx, result, i, args[i]);
if (cx.getLanguageVersion() >= Context.VERSION_ES6 && result instanceof ScriptableObject) {
ScriptableObject desc = ScriptableObject.buildDataDescriptor(result, null, EMPTY);
for (int i = 0; i < args.length; i++) {
desc.put("value", desc, args[i]);
((ScriptableObject) result).defineOwnProperty(cx, i, desc);
}
} else {
for (int i = 0; i < args.length; i++) {
defineElem(cx, result, i, args[i]);
}
}
setLengthProperty(cx, result, args.length);

Expand Down
4 changes: 1 addition & 3 deletions testsrc/test262.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a configuration file for Test262SuiteTest.java. See ./README.md for more info about this file

built-ins/Array 179/2670 (6.7%)
built-ins/Array 177/2670 (6.63%)
from/calling-from-valid-1-noStrict.js non-strict Spec pretty clearly says this should be undefined
from/elements-deleted-after.js Checking to see if length changed, but spec says it should not
from/iter-map-fn-this-non-strict.js non-strict Error propagation needs work in general
Expand All @@ -18,9 +18,7 @@ built-ins/Array 179/2670 (6.7%)
length/define-own-prop-length-coercion-order-set.js {unsupported: [Reflect, Reflect.set]}
length/define-own-prop-length-no-value-order.js {unsupported: [Reflect]}
length/define-own-prop-length-overflow-order.js
of/does-not-use-set-for-indices.js
of/proto-from-ctor-realm.js
of/return-abrupt-from-data-property.js Object.preventExtensions doesn't seem to throw
of/return-abrupt-from-data-property-using-proxy.js {unsupported: [Proxy]}
prototype/concat/arg-length-exceeding-integer-limit.js {unsupported: [Proxy]}
prototype/concat/Array.prototype.concat_large-typed-array.js new
Expand Down

0 comments on commit b41a111

Please sign in to comment.