fasttime / JScrewIt

Write any JavaScript with six characters: ! ( ) + [ ]
https://jscrew.it
ISC License
161 stars 13 forks source link

Extend usage of object "self" for letter "W" #30

Closed Clayblockunova closed 3 years ago

Clayblockunova commented 3 years ago

Currently, (RP_3_WA + self)[11] only work as "W" when feature WINDOW available, i.e. outside web worker. if string representation of self in web worker is "[object WorkerGlobalScope]", you can add a new feature to make (RP_3_WA + self)[11] available as "W" in web worker. but, if string representation of self in web worker is "[object DedicatedWorkerGlobalScope]" etc., self may not be so useful for "W" in web worker.

fasttime commented 3 years ago

This can be useful in IE 10 and 11, where the string representation of self in web workers is actually "[object WorkerGlobalScope]". In most other browsers it is "[object DedicatedWorkerGlobalScope]".

Clayblockunova commented 3 years ago

sorry to bother you again. what is constructor of self in web worker? is it WorkerGlobalScope() or DedicatedWorkerGlobalScope etc.?

fasttime commented 3 years ago

It's WorkerGlobalScope in IE 10+, and it's Object in older versions of Safari (not sure when it changed). Most newer browsers recognize an additional type of web workers called shared workers. In these browsers, self.constructor is DedicatedWorkerGlobalScope in (regular) web workers and SharedWorkerGlobalScope in shared workers.

fasttime commented 3 years ago

Implemented in version 2.31.0.

Clayblockunova commented 2 years ago

Sorry to bother you again. In current code, only feature about global constructor is added (which is OBJECT_W_CTOR), and (RP_3_WA + self)[11] still only work as "W" when WINDOW active. When will you add new feature about existence of "W" at specified place in string representation of self?

fasttime commented 2 years ago

I think that DOMWINDOW and WINDOW cover the useful string representations of self in a browser, including the two positions of "W". Am I missing something?

Clayblockunova commented 2 years ago

IE 10 and 11 web worker missing.

fasttime commented 2 years ago

Ah okay. Actually the idea is that we don't create features just for web workers, only for the main thread, or for the main thread and web workers, or for the main thread in strict mode, etc. (those are all handles as restrictions to the feature set, not additions). Of course this mechanism could be changed if there is a use case, but it would require a lot of tweaks.