Skip to content
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

New feature CALL_ON_GLOBAL, new global objects and functions related definitions #53

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

Clayblockunova
Copy link
Contributor

IDK how to simulate it, tho.

@fasttime
Copy link
Owner

fasttime commented Sep 2, 2024

Thanks for the PR. How did you test these definitions? They're all failing for me. Even just running [].sort.call() in a browser in non-strict mode is throwing an error.

@Clayblockunova
Copy link
Contributor Author

Clayblockunova commented Sep 2, 2024

I just simulate it with [].sort.call(self) since I think that's the intended behavior. does INCR_CHAR work under your rest environment? nether CALL_ON_GLOBAL nor INCR_CHAR work when I tried to execute JS code with data URI.

@fasttime
Copy link
Owner

fasttime commented Sep 2, 2024

INCR_CHAR says for example that ++"0"[0] will evaluate to 1. You can see that this is happening in non-strict mode here. In strict mode, the same code will throw an error (here). Now, [].sort.call() throws an error no matter how it is called.

@Clayblockunova
Copy link
Contributor Author

Clayblockunova commented Sep 3, 2024

as someone mentioned in 2012, CALL_ON_GLOBAL would be a feature working on super-legacy platforms. IDK whether are those platforms beyond this project's support.

@Clayblockunova
Copy link
Contributor Author

should I close this PR now? or should I do anything else?

@fasttime
Copy link
Owner

fasttime commented Sep 4, 2024

Maybe CALL_ON_GLOBAL would be available in ES3 compliant browsers (that don't support strict mode at all). At least this is what the spec suggests at https://tc39.es/ecma262/#sec-function.prototype.call (NOTE 1):

The thisArg value is passed without modification as the this value. This is a change from Edition 3, where an undefined or null thisArg is replaced with the global object and ToObject is applied to all other values and that result is passed as the this value. Even though the thisArg is passed without modification, non-strict functions still perform these transformations upon entry to the function.

I appreciate the idea of this PR but I don't think that JScrewIt would run on such old browsers. Feel free to close if you don't have any other use cases.

@Clayblockunova
Copy link
Contributor Author

Clayblockunova commented Sep 8, 2024

AFAIK from caniuse.com, Android browser 4.0 does not support zero-width chars in identifiers & Immutable undefined. so I reopened the PR, but I still don't know how to simulate.

@Clayblockunova Clayblockunova reopened this Sep 8, 2024
@fasttime
Copy link
Owner

fasttime commented Sep 9, 2024

AFAIK from caniuse.com, Android browser 4.0 does not support zero-width chars in identifiers & Immutable undefined. so I reopened the PR, but I still don't know how to simulate.

I use Android Studio on Windows x64 to emulate old Android devices. Then I usually start a server on the host from the JScrewIt folder, and enter the URL http://10.0.2.2/JScrewIt.html in Android browser. I haven't been able to check this PR yet.

@Clayblockunova
Copy link
Contributor Author

so, what should I do now?

@Clayblockunova
Copy link
Contributor Author

should I do some change to the makefile? or just leave that for you?

@fasttime
Copy link
Owner

Sorry, being a little busy at the moment. I checked on Android Browser 4.0 and CALL_ON_GLOBAL is available! But the character definitions are still not working. If you leave this open I could have a later look to see what is wrong.

@Clayblockunova
Copy link
Contributor Author

Clayblockunova commented Sep 16, 2024

should I change Array.prototype.fill definition or just leave it for you?

@fasttime
Copy link
Owner

Array.prototype.fill does not exist in Android Browser, but even Array.prototype.sort seems unsafe because if window.length is greater than zero, it will overwrite global values window[0], window[1], etc.

@Clayblockunova
Copy link
Contributor Author

Clayblockunova commented Sep 17, 2024

according to MDN, window.length means number of frames in the page. what does window[0] mean? should I close the PR anyway?

@fasttime
Copy link
Owner

according to MDN, window.length means number of frames in the page. what does window[0] mean?

Yes, those are IFRAME objects. window[0] is the first IFRAME. The value can be overwritten in JavaScript but the DOM doesn't change accordingly (at least not in Android Browser).

should I close the PR anyway?

We can't introduce side effects in the code. If Array.prototype.sort is the only alternative then we can't use this feature, sorry.

@Clayblockunova
Copy link
Contributor Author

Clayblockunova commented Sep 18, 2024

just tried Array.prototype.concat.

Copy link
Owner

@fasttime fasttime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, thanks!

src/lib/features.js Outdated Show resolved Hide resolved
src/lib/features.js Outdated Show resolved Hide resolved
src/lib/definitions.js Outdated Show resolved Hide resolved
src/lib/definitions.js Outdated Show resolved Hide resolved
@Clayblockunova
Copy link
Contributor Author

Just added self based variant of global objects and functions.

@Clayblockunova Clayblockunova changed the title New feature CALL_ON_GLOBAL, new definitions of "W" and "w" New feature CALL_ON_GLOBAL, new global objects and functions definitions Sep 18, 2024
@Clayblockunova Clayblockunova changed the title New feature CALL_ON_GLOBAL, new global objects and functions definitions New feature CALL_ON_GLOBAL, new global objects and functions related definitions Sep 18, 2024
src/lib/definitions.js Outdated Show resolved Hide resolved
src/lib/definitions.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants