NEW247427
Setting [[Prototype]] of global object in JSC shell should not throw `TypeError`
https://bugs.webkit.org/show_bug.cgi?id=247427
Summary Setting [[Prototype]] of global object in JSC shell should not throw `TypeError`
Kanguk Lee
Reported 2022-11-03 08:51:01 PDT
// input.js Object . setPrototypeOf ( this , { } ) ; __________________________________________ Hello, Executing the input.js using JSC throws TypeError, but it is expected to terminate normally. Running the input.js with JSC gives --- $ jsc input.js Exception: TypeError: Cannot set prototype of immutable prototype object setPrototypeOf@[native code] global code@input.js:1:24 --- while other engines behave like --- # V8 $ node input.js // no error # GraalJS $ js input.js // no error --- WebKit version: 615.1.10
Attachments
Radar WebKit Bug Importer
Comment 1 2022-11-03 18:15:41 PDT
Alexey Shvayka
Comment 2 2022-11-03 18:49:21 PDT
Great catch, thank you! Indeed the ECMA-262 doesn't require global object to have immutable prototype; it's the WebIDL spec which makes global objects' [[Prototype]] slots immutable: https://webidl.spec.whatwg.org/#platform-object-setprototypeof. That shouldn't affect the JSC shell of course. When fixing that we need to ensure that scope resolution is sane when `globalThis.__proto__` is modified, which might get a little tricky.
Yusuke Suzuki
Comment 3 2022-11-10 13:03:37 PST
I wonder if we should fix this. Since DOM window is super more common in various places, should we just keep our behavior aligned to DOM window?
Alexey Shvayka
Comment 4 2022-11-11 09:10:01 PST
(In reply to Yusuke Suzuki from comment #3) > I wonder if we should fix this. Since DOM window is super more common in > various places, should we just keep our behavior aligned to DOM window? I would say we should fix this (not prioritize of course) just for the spec purity and non-browser environments like Bun, which claims to be functionally-equivalent to Node.js.
Note You need to log in before you can comment on or make changes to this bug.