mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 11:42:38 +03:00
Userland/js: Add global
property to the global object + help fix
This adds a `global` property to the global object so that `global == this` when typed into the REPL. This matches what Node.js does and helps with testing on existing JS code that uses `global` to detect its environment.
This commit is contained in:
parent
59adccb987
commit
a60a5bc70a
Notes:
sideshowbarker
2024-07-19 05:53:55 +09:00
Author: https://github.com/nooga Commit: https://github.com/SerenityOS/serenity/commit/a60a5bc70a4 Pull-request: https://github.com/SerenityOS/serenity/pull/2477
@ -359,6 +359,7 @@ ReplObject::ReplObject()
|
||||
void ReplObject::initialize()
|
||||
{
|
||||
GlobalObject::initialize();
|
||||
define_property("global", this, JS::Attribute::Enumerable);
|
||||
define_native_function("exit", exit_interpreter);
|
||||
define_native_function("help", repl_help);
|
||||
define_native_function("load", load_file, 1);
|
||||
@ -396,7 +397,8 @@ JS::Value ReplObject::repl_help(JS::Interpreter&)
|
||||
printf("REPL commands:\n");
|
||||
printf(" exit(code): exit the REPL with specified code. Defaults to 0.\n");
|
||||
printf(" help(): display this menu\n");
|
||||
printf(" load(files): Accepts file names as params to load into running session. For example load(\"js/1.js\", \"js/2.js\", \"js/3.js\")\n");
|
||||
printf(" load(files): accepts file names as params to load into running session. For example load(\"js/1.js\", \"js/2.js\", \"js/3.js\")\n");
|
||||
printf(" save(file): accepts a file name, writes REPL input history to a file. For example: save(\"foo.txt\")\n");
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user