On Thu Oct 17 10:39:05 2024 +0000, Jacek Caban wrote:
How would you delete something that's not on the window itself? I mean
if you delete a GLOBAL_SCRIPTVAR, it will just get re-created when accessed, so it still "exists" (since it's just a reference to the one in the js global). Well, unless we add a new type like GLOBAL_DELETED to override it. You could probably just delete it in script dispatch with `DeleteMemberByDispID` (like we forward `InvokeEx` calls). Unless I'm missing something, frames' code for exposing global variable would be broken with this patch as it depends on those being global properties.
By the way, the current approach with find_dispid doesn't work with
getOwnPropertyNames (not just in window and document, but also in stuff like prototypes and constructors and wherever else it is used). If they haven't been looked up yet, they aren't created, and thus won't be enumerated. I think it's easier to make them closer to actual js objects and avoid corner cases like this since the jscript code will handle it normally. If they are indeed intended to be enumerated, it should be doable with `next_dispid`. AFAIR, we still need to support mixing script languages in newer compat modes, so some form of `GLOBAL_SCRIPTVAR` is still needed. This MR is pushing the corner case deeper into the corner, deep enough to avoid being covered by tests, not removing it. More generally, moving more things closer to js sounds good, but we most likely will need to handle "special" properties one way or another.
Well this is a bit more hairy than I anticipated, so I'm looking into fixing some related/required stuff first. Some stuff was already broken. Anyway just handling deletion is not enough by itself.
But with respect to the "intended to be enumerated", well they aren't enumerable, but getOwnPropertyNames retrieves all props, not just enumerable ones. But it's not related to this MR anymore since I'm trying the different approach.