Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -42017,6 +42017,12 @@ static JSValue js_object_isSealed(JSContext *ctx, JSValueConst this_val,
return JS_TRUE;

p = JS_VALUE_GET_OBJ(obj);
res = JS_IsExtensible(ctx, obj);
if (res < 0)
return JS_EXCEPTION;
if (res)
return JS_FALSE;

flags = JS_GPN_STRING_MASK | JS_GPN_SYMBOL_MASK;
if (JS_GetOwnPropertyNamesInternal(ctx, &props, &len, p, flags))
return JS_EXCEPTION;
Expand All @@ -42036,10 +42042,7 @@ static JSValue js_object_isSealed(JSContext *ctx, JSValueConst this_val,
}
}
}
res = JS_IsExtensible(ctx, obj);
if (res < 0)
return JS_EXCEPTION;
res ^= 1;
res = true;
done:
js_free_prop_enum(ctx, props, len);
return js_bool(res);
Expand Down
31 changes: 31 additions & 0 deletions tests/test_builtin.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,36 @@ function test()
assertThrows(TypeError, () => Object.setPrototypeOf(Object.prototype, {}));
}

function test_object_integrity_check_proxy_order()
{
var log = [];
function logged(target) {
return new Proxy(target, {
isExtensible(t) {
log.push("isExtensible");
return Reflect.isExtensible(t);
},
ownKeys(t) {
log.push("ownKeys");
return Reflect.ownKeys(t);
},
getOwnPropertyDescriptor(t, k) {
log.push("getOwnPropertyDescriptor " + k);
return Reflect.getOwnPropertyDescriptor(t, k);
},
});
}

Object.isFrozen(logged({ x: 1 }));
assert(log.join(", "), "isExtensible", "isFrozen checks extensibility first");

log = [];
Object.isSealed(logged(Object.freeze({ x: 1 })));
assert(log.join(", "),
"isExtensible, ownKeys, getOwnPropertyDescriptor x",
"isSealed checks extensibility first");
}

function test_enum()
{
var a, tab;
Expand Down Expand Up @@ -1331,6 +1361,7 @@ function test_cur_pc()
}

test();
test_object_integrity_check_proxy_order();
test_function();
test_enum();
test_array();
Expand Down
Loading