Skip to content

Commit 3f10651

Browse files
authored
Prohibit freezing/sealing module namespace objects (#160)
1 parent b6b70e4 commit 3f10651

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

quickjs.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35101,14 +35101,19 @@ static JSValue js_object_seal(JSContext *ctx, JSValueConst this_val,
3510135101
if (!JS_IsObject(obj))
3510235102
return js_dup(obj);
3510335103

35104+
p = JS_VALUE_GET_OBJ(obj);
35105+
if (p->class_id == JS_CLASS_MODULE_NS) {
35106+
return JS_ThrowTypeError(ctx, "cannot %s module namespace",
35107+
freeze_flag ? "freeze" : "seal");
35108+
}
35109+
3510435110
res = JS_PreventExtensions(ctx, obj);
3510535111
if (res < 0)
3510635112
return JS_EXCEPTION;
3510735113
if (!res) {
3510835114
return JS_ThrowTypeError(ctx, "proxy preventExtensions handler returned false");
3510935115
}
3511035116

35111-
p = JS_VALUE_GET_OBJ(obj);
3511235117
flags = JS_GPN_STRING_MASK | JS_GPN_SYMBOL_MASK;
3511335118
if (JS_GetOwnPropertyNamesInternal(ctx, &props, &len, p, flags))
3511435119
return JS_EXCEPTION;

test262_errors.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ test262/test/language/expressions/logical-assignment/left-hand-side-private-refe
139139
test262/test/language/expressions/optional-chaining/optional-call-preserves-this.js:21: TypeError: cannot read property 'c' of undefined
140140
test262/test/language/expressions/optional-chaining/optional-call-preserves-this.js:15: strict mode: TypeError: cannot read property '_b' of undefined
141141
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
142-
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
143142
test262/test/language/statements/async-generator/yield-star-promise-not-unwrapped.js:25: TypeError: $DONE() not called
144143
test262/test/language/statements/async-generator/yield-star-promise-not-unwrapped.js:25: strict mode: TypeError: $DONE() not called
145144
test262/test/language/statements/async-generator/yield-star-return-then-getter-ticks.js:131: TypeError: $DONE() not called

0 commit comments

Comments
 (0)