Skip to content

Prohibit freezing/sealing module namespace objects #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2023
Merged
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
7 changes: 6 additions & 1 deletion quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -35101,14 +35101,19 @@ 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;
if (!res) {
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;
Expand Down
1 change: 0 additions & 1 deletion test262_errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down