Prohibit freezing/sealing module namespace objects (#160)

This commit is contained in:
Ben Noordhuis 2023-11-30 00:42:36 +01:00 committed by GitHub
parent b6b70e471c
commit 3f10651dc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -35101,6 +35101,12 @@ static JSValue js_object_seal(JSContext *ctx, JSValueConst this_val,
if (!JS_IsObject(obj))
return js_dup(obj);
p = JS_VALUE_GET_OBJ(obj);
if (p->class_id == JS_CLASS_MODULE_NS) {
return JS_ThrowTypeError(ctx, "cannot %s module namespace",
freeze_flag ? "freeze" : "seal");
}
res = JS_PreventExtensions(ctx, obj);
if (res < 0)
return JS_EXCEPTION;
@ -35108,7 +35114,6 @@ static JSValue js_object_seal(JSContext *ctx, JSValueConst this_val,
return JS_ThrowTypeError(ctx, "proxy preventExtensions handler returned false");
}
p = JS_VALUE_GET_OBJ(obj);
flags = JS_GPN_STRING_MASK | JS_GPN_SYMBOL_MASK;
if (JS_GetOwnPropertyNamesInternal(ctx, &props, &len, p, flags))
return JS_EXCEPTION;

View file

@ -139,7 +139,6 @@ test262/test/language/expressions/logical-assignment/left-hand-side-private-refe
test262/test/language/expressions/optional-chaining/optional-call-preserves-this.js:21: TypeError: cannot read property 'c' of undefined
test262/test/language/expressions/optional-chaining/optional-call-preserves-this.js:15: strict mode: TypeError: cannot read property '_b' of undefined
test262/test/language/global-code/script-decl-lex-var-declared-via-eval-sloppy.js:13: Test262Error: variable Expected a SyntaxError to be thrown but no exception was thrown at all
test262/test/language/module-code/namespace/internals/define-own-property.js:30: Test262Error: Object.freeze: 1 Expected a TypeError to be thrown but no exception was thrown at all
test262/test/language/statements/async-generator/yield-star-promise-not-unwrapped.js:25: TypeError: $DONE() not called
test262/test/language/statements/async-generator/yield-star-promise-not-unwrapped.js:25: strict mode: TypeError: $DONE() not called
test262/test/language/statements/async-generator/yield-star-return-then-getter-ticks.js:131: TypeError: $DONE() not called