summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb
diff options
context:
space:
mode:
authormattco98 <matthewcolsson@gmail.com>2020-04-27 23:05:02 -0700
committerAndreas Kling <kling@serenityos.org>2020-04-28 09:29:50 +0200
commit23ec578a016d5d8b4e55553924d3d37d899854c8 (patch)
treeac0f63ca92b68205d47fe46b127717ecee3dfa33 /Libraries/LibWeb
parentc4d05049c478980e3087c4043ec36ec315ee0f71 (diff)
downloadserenity-23ec578a016d5d8b4e55553924d3d37d899854c8.zip
LibJS: Implement correct attributes for (almost) all properties
Added the ability to include a u8 attributes parameter with all of the various put methods in the Object class. They can be omitted, in which case it defaults to "Writable | Enumerable | Configurable", just like before this commit. All of the attribute values for each property were gathered from SpiderMonkey in the Firefox console. Some properties (e.g. all of the canvas element properties) have undefined property descriptors... not quite sure what that means. Those were left as the default specified above.
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r--Libraries/LibWeb/Bindings/WindowObject.cpp11
-rw-r--r--Libraries/LibWeb/Bindings/XMLHttpRequestConstructor.cpp13
-rw-r--r--Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp14
3 files changed, 20 insertions, 18 deletions
diff --git a/Libraries/LibWeb/Bindings/WindowObject.cpp b/Libraries/LibWeb/Bindings/WindowObject.cpp
index 66867d4ed9..0e00bb6861 100644
--- a/Libraries/LibWeb/Bindings/WindowObject.cpp
+++ b/Libraries/LibWeb/Bindings/WindowObject.cpp
@@ -29,6 +29,7 @@
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/Error.h>
#include <LibJS/Runtime/Function.h>
+#include <LibJS/Runtime/Shape.h>
#include <LibWeb/Bindings/DocumentWrapper.h>
#include <LibWeb/Bindings/NavigatorObject.h>
#include <LibWeb/Bindings/WindowObject.h>
@@ -49,8 +50,8 @@ void WindowObject::initialize()
{
GlobalObject::initialize();
- put("window", this);
- put_native_property("document", document_getter, document_setter);
+ put("window", this, JS::Attribute::Enumerable);
+ put_native_property("document", document_getter, document_setter, JS::Attribute::Enumerable);
put_native_function("alert", alert);
put_native_function("confirm", confirm);
put_native_function("setInterval", set_interval, 1);
@@ -58,12 +59,12 @@ void WindowObject::initialize()
put_native_function("requestAnimationFrame", request_animation_frame, 1);
put_native_function("cancelAnimationFrame", cancel_animation_frame, 1);
- put("navigator", heap().allocate<NavigatorObject>());
+ put("navigator", heap().allocate<NavigatorObject>(), JS::Attribute::Enumerable | JS::Attribute::Configurable);
m_xhr_prototype = heap().allocate<XMLHttpRequestPrototype>();
m_xhr_constructor = heap().allocate<XMLHttpRequestConstructor>();
- m_xhr_constructor->put("prototype", m_xhr_prototype);
- put("XMLHttpRequest", m_xhr_constructor);
+ m_xhr_constructor->put("prototype", m_xhr_prototype, 0);
+ put("XMLHttpRequest", m_xhr_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
}
WindowObject::~WindowObject()
diff --git a/Libraries/LibWeb/Bindings/XMLHttpRequestConstructor.cpp b/Libraries/LibWeb/Bindings/XMLHttpRequestConstructor.cpp
index 7fea4c1cc1..2a2acb829c 100644
--- a/Libraries/LibWeb/Bindings/XMLHttpRequestConstructor.cpp
+++ b/Libraries/LibWeb/Bindings/XMLHttpRequestConstructor.cpp
@@ -27,6 +27,7 @@
#include <LibJS/Heap/Heap.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/GlobalObject.h>
+#include <LibJS/Runtime/Shape.h>
#include <LibWeb/Bindings/WindowObject.h>
#include <LibWeb/Bindings/XMLHttpRequestConstructor.h>
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
@@ -38,13 +39,13 @@ namespace Bindings {
XMLHttpRequestConstructor::XMLHttpRequestConstructor()
: NativeFunction(*interpreter().global_object().function_prototype())
{
- put("length", JS::Value(1));
+ put("length", JS::Value(1), JS::Attribute::Configurable);
- put("UNSENT", JS::Value((i32)XMLHttpRequest::ReadyState::Unsent));
- put("OPENED", JS::Value((i32)XMLHttpRequest::ReadyState::Opened));
- put("HEADERS_RECEIVED", JS::Value((i32)XMLHttpRequest::ReadyState::HeadersReceived));
- put("LOADING", JS::Value((i32)XMLHttpRequest::ReadyState::Loading));
- put("DONE", JS::Value((i32)XMLHttpRequest::ReadyState::Done));
+ put("UNSENT", JS::Value((i32)XMLHttpRequest::ReadyState::Unsent), JS::Attribute::Enumerable);
+ put("OPENED", JS::Value((i32)XMLHttpRequest::ReadyState::Opened), JS::Attribute::Enumerable);
+ put("HEADERS_RECEIVED", JS::Value((i32)XMLHttpRequest::ReadyState::HeadersReceived), JS::Attribute::Enumerable);
+ put("LOADING", JS::Value((i32)XMLHttpRequest::ReadyState::Loading), JS::Attribute::Enumerable);
+ put("DONE", JS::Value((i32)XMLHttpRequest::ReadyState::Done), JS::Attribute::Enumerable);
}
XMLHttpRequestConstructor::~XMLHttpRequestConstructor()
diff --git a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp
index d749663c20..a5d95c302e 100644
--- a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp
+++ b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp
@@ -40,14 +40,14 @@ XMLHttpRequestPrototype::XMLHttpRequestPrototype()
{
put_native_function("open", open, 2);
put_native_function("send", send, 0);
- put_native_property("readyState", ready_state_getter, nullptr);
- put_native_property("responseText", response_text_getter, nullptr);
+ put_native_property("readyState", ready_state_getter, nullptr, JS::Attribute::Enumerable | JS::Attribute::Configurable);
+ put_native_property("responseText", response_text_getter, nullptr, JS::Attribute::Enumerable | JS::Attribute::Configurable);
- put("UNSENT", JS::Value((i32)XMLHttpRequest::ReadyState::Unsent));
- put("OPENED", JS::Value((i32)XMLHttpRequest::ReadyState::Opened));
- put("HEADERS_RECEIVED", JS::Value((i32)XMLHttpRequest::ReadyState::HeadersReceived));
- put("LOADING", JS::Value((i32)XMLHttpRequest::ReadyState::Loading));
- put("DONE", JS::Value((i32)XMLHttpRequest::ReadyState::Done));
+ put("UNSENT", JS::Value((i32)XMLHttpRequest::ReadyState::Unsent), JS::Attribute::Enumerable);
+ put("OPENED", JS::Value((i32)XMLHttpRequest::ReadyState::Opened), JS::Attribute::Enumerable);
+ put("HEADERS_RECEIVED", JS::Value((i32)XMLHttpRequest::ReadyState::HeadersReceived), JS::Attribute::Enumerable);
+ put("LOADING", JS::Value((i32)XMLHttpRequest::ReadyState::Loading), JS::Attribute::Enumerable);
+ put("DONE", JS::Value((i32)XMLHttpRequest::ReadyState::Done), JS::Attribute::Enumerable);
}
XMLHttpRequestPrototype::~XMLHttpRequestPrototype()