summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Meta/Lagom/Fuzzers/FuzzilliJs.cpp2
-rw-r--r--Tests/LibWasm/test-wasm.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/JSIntegration.cpp15
-rw-r--r--Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp21
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.h6
-rw-r--r--Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/WindowObject.cpp23
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp2
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp4
-rw-r--r--Userland/Utilities/js.cpp12
10 files changed, 48 insertions, 43 deletions
diff --git a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp
index 21f679c77a..ea8824d6dc 100644
--- a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp
@@ -178,7 +178,7 @@ void TestRunnerGlobalObject::initialize_global_object()
{
Base::initialize_global_object();
define_direct_property("global", this, JS::Attribute::Enumerable);
- define_native_function("fuzzilli", fuzzilli, 2);
+ define_native_function("fuzzilli", fuzzilli, 2, JS::default_attributes);
}
int main(int, char**)
diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp
index 62b5f3e49b..2cb6abe619 100644
--- a/Tests/LibWasm/test-wasm.cpp
+++ b/Tests/LibWasm/test-wasm.cpp
@@ -157,8 +157,8 @@ TESTJS_GLOBAL_FUNCTION(compare_typed_arrays, compareTypedArrays)
void WebAssemblyModule::initialize(JS::GlobalObject& global_object)
{
Base::initialize(global_object);
- define_native_function("getExport", get_export);
- define_native_function("invoke", wasm_invoke);
+ define_native_function("getExport", get_export, 1, JS::default_attributes);
+ define_native_function("invoke", wasm_invoke, 1, JS::default_attributes);
}
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export)
diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp
index 7fe9a2a77f..b40f1fa976 100644
--- a/Userland/Applications/Spreadsheet/JSIntegration.cpp
+++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp
@@ -139,12 +139,13 @@ bool SheetGlobalObject::internal_set(const JS::PropertyName& property_name, JS::
void SheetGlobalObject::initialize_global_object()
{
Base::initialize_global_object();
- define_native_function("get_real_cell_contents", get_real_cell_contents, 1);
- define_native_function("set_real_cell_contents", set_real_cell_contents, 2);
- define_native_function("parse_cell_name", parse_cell_name, 1);
- define_native_function("current_cell_position", current_cell_position, 0);
- define_native_function("column_arithmetic", column_arithmetic, 2);
- define_native_function("column_index", column_index, 1);
+ u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
+ define_native_function("get_real_cell_contents", get_real_cell_contents, 1, attr);
+ define_native_function("set_real_cell_contents", set_real_cell_contents, 2, attr);
+ define_native_function("parse_cell_name", parse_cell_name, 1, attr);
+ define_native_function("current_cell_position", current_cell_position, 0, attr);
+ define_native_function("column_arithmetic", column_arithmetic, 2, attr);
+ define_native_function("column_index", column_index, 1, attr);
}
void SheetGlobalObject::visit_edges(Visitor& visitor)
@@ -389,7 +390,7 @@ WorkbookObject::~WorkbookObject()
void WorkbookObject::initialize(JS::GlobalObject& global_object)
{
Object::initialize(global_object);
- define_native_function("sheet", sheet, 1);
+ define_native_function("sheet", sheet, 1, JS::default_attributes);
}
void WorkbookObject::visit_edges(Visitor& visitor)
diff --git a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp
index 02e4f3ae0c..06778dd99f 100644
--- a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp
@@ -21,16 +21,17 @@ void ConsoleObject::initialize(GlobalObject& global_object)
{
auto& vm = this->vm();
Object::initialize(global_object);
- define_native_function(vm.names.log, log);
- define_native_function(vm.names.debug, debug);
- define_native_function(vm.names.info, info);
- define_native_function(vm.names.warn, warn);
- define_native_function(vm.names.error, error);
- define_native_function(vm.names.trace, trace);
- define_native_function(vm.names.count, count);
- define_native_function(vm.names.countReset, count_reset);
- define_native_function(vm.names.clear, clear);
- define_native_function(vm.names.assert, assert_);
+ u8 attr = Attribute::Writable | Attribute::Enumerable | Attribute::Configurable;
+ define_native_function(vm.names.log, log, 0, attr);
+ define_native_function(vm.names.debug, debug, 0, attr);
+ define_native_function(vm.names.info, info, 0, attr);
+ define_native_function(vm.names.warn, warn, 0, attr);
+ define_native_function(vm.names.error, error, 0, attr);
+ define_native_function(vm.names.trace, trace, 0, attr);
+ define_native_function(vm.names.count, count, 0, attr);
+ define_native_function(vm.names.countReset, count_reset, 0, attr);
+ define_native_function(vm.names.clear, clear, 0, attr);
+ define_native_function(vm.names.assert, assert_, 0, attr);
}
ConsoleObject::~ConsoleObject()
diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h
index 9510e2084c..d36a117089 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.h
+++ b/Userland/Libraries/LibJS/Runtime/Object.h
@@ -131,9 +131,9 @@ public:
void define_direct_property(PropertyName const& property_name, Value value, PropertyAttributes attributes) { storage_set(property_name, { value, attributes }); };
void define_direct_accessor(PropertyName const&, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes);
- void define_native_function(PropertyName const&, Function<Value(VM&, GlobalObject&)>, i32 length = 0, PropertyAttributes attributes = default_attributes);
- void define_native_property(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<void(VM&, GlobalObject&, Value)> setter, PropertyAttributes attributes = default_attributes);
- void define_native_accessor(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<Value(VM&, GlobalObject&)> setter, PropertyAttributes attributes = default_attributes);
+ void define_native_function(PropertyName const&, Function<Value(VM&, GlobalObject&)>, i32 length, PropertyAttributes attributes);
+ void define_native_property(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<void(VM&, GlobalObject&, Value)> setter, PropertyAttributes attributes);
+ void define_native_accessor(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<Value(VM&, GlobalObject&)> setter, PropertyAttributes attributes);
virtual bool is_array() const { return false; }
virtual bool is_function() const { return false; }
diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp
index a7269eae65..3503d1bd36 100644
--- a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp
@@ -33,7 +33,7 @@ void NavigatorObject::initialize(JS::GlobalObject& global_object)
define_direct_property("platform", js_string(heap, "SerenityOS"), attr);
define_direct_property("product", js_string(heap, "Gecko"), attr);
- define_native_accessor("userAgent", user_agent_getter, {});
+ define_native_accessor("userAgent", user_agent_getter, {}, JS::Attribute::Configurable | JS::Attribute::Enumerable);
}
NavigatorObject::~NavigatorObject()
diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp
index 8fef8a4eca..ef18f4a861 100644
--- a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp
@@ -57,17 +57,18 @@ void WindowObject::initialize_global_object()
define_native_accessor("screen", screen_getter, {}, JS::Attribute::Enumerable);
define_native_accessor("innerWidth", inner_width_getter, {}, JS::Attribute::Enumerable);
define_native_accessor("innerHeight", inner_height_getter, {}, JS::Attribute::Enumerable);
- define_native_function("alert", alert);
- define_native_function("confirm", confirm);
- define_native_function("prompt", prompt);
- define_native_function("setInterval", set_interval, 1);
- define_native_function("setTimeout", set_timeout, 1);
- define_native_function("clearInterval", clear_interval, 1);
- define_native_function("clearTimeout", clear_timeout, 1);
- define_native_function("requestAnimationFrame", request_animation_frame, 1);
- define_native_function("cancelAnimationFrame", cancel_animation_frame, 1);
- define_native_function("atob", atob, 1);
- define_native_function("btoa", btoa, 1);
+ u8 attr = JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable;
+ define_native_function("alert", alert, 0, attr);
+ define_native_function("confirm", confirm, 0, attr);
+ define_native_function("prompt", prompt, 0, attr);
+ define_native_function("setInterval", set_interval, 1, attr);
+ define_native_function("setTimeout", set_timeout, 1, attr);
+ define_native_function("clearInterval", clear_interval, 1, attr);
+ define_native_function("clearTimeout", clear_timeout, 1, attr);
+ define_native_function("requestAnimationFrame", request_animation_frame, 1, attr);
+ define_native_function("cancelAnimationFrame", cancel_animation_frame, 1, attr);
+ define_native_function("atob", atob, 1, attr);
+ define_native_function("btoa", btoa, 1, attr);
// Legacy
define_native_accessor("event", event_getter, {}, JS::Attribute::Enumerable);
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp
index 8eaf4e1251..91fe6541ac 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp
@@ -12,7 +12,7 @@ namespace Web::Bindings {
void WebAssemblyInstancePrototype::initialize(JS::GlobalObject& global_object)
{
Object::initialize(global_object);
- define_native_accessor("exports", exports_getter, {});
+ define_native_accessor("exports", exports_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
}
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyInstancePrototype::exports_getter)
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp
index d98b384636..0655cdcc3a 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp
@@ -13,8 +13,8 @@ namespace Web::Bindings {
void WebAssemblyMemoryPrototype::initialize(JS::GlobalObject& global_object)
{
Object::initialize(global_object);
- define_native_accessor("buffer", buffer_getter, {});
- define_native_function("grow", grow);
+ define_native_accessor("buffer", buffer_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
+ define_native_function("grow", grow, 1, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable);
}
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyMemoryPrototype::grow)
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index 65d99bc6c3..8716fef063 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -654,10 +654,11 @@ void ReplObject::initialize_global_object()
{
Base::initialize_global_object();
define_direct_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);
- define_native_function("save", save_to_file, 1);
+ u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
+ define_native_function("exit", exit_interpreter, 0, attr);
+ define_native_function("help", repl_help, 0, attr);
+ define_native_function("load", load_file, 1, attr);
+ define_native_function("save", save_to_file, 1, attr);
}
JS_DEFINE_NATIVE_FUNCTION(ReplObject::save_to_file)
@@ -701,7 +702,8 @@ void ScriptObject::initialize_global_object()
{
Base::initialize_global_object();
define_direct_property("global", this, JS::Attribute::Enumerable);
- define_native_function("load", load_file, 1);
+ u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
+ define_native_function("load", load_file, 1, attr);
}
JS_DEFINE_NATIVE_FUNCTION(ScriptObject::load_file)