From eb165554e149f3aab2b06043e66e715bc7648bc5 Mon Sep 17 00:00:00 2001 From: Vishal Biswas Date: Thu, 17 Apr 2025 11:37:30 +0530 Subject: [PATCH] LibWeb: Use double type in ProgressEvent loaded and total should be double as per spec https://xhr.spec.whatwg.org/#progressevent --- Libraries/LibWeb/XHR/ProgressEvent.h | 12 +-- Libraries/LibWeb/XHR/ProgressEvent.idl | 8 +- .../xhr/progressevent-constructor.txt | 15 ++++ .../xhr/progressevent-constructor.html | 77 +++++++++++++++++++ 4 files changed, 102 insertions(+), 10 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/xhr/progressevent-constructor.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/xhr/progressevent-constructor.html diff --git a/Libraries/LibWeb/XHR/ProgressEvent.h b/Libraries/LibWeb/XHR/ProgressEvent.h index d2856fe4a15..47816d5248c 100644 --- a/Libraries/LibWeb/XHR/ProgressEvent.h +++ b/Libraries/LibWeb/XHR/ProgressEvent.h @@ -14,8 +14,8 @@ namespace Web::XHR { struct ProgressEventInit : public DOM::EventInit { bool length_computable { false }; - WebIDL::UnsignedLongLong loaded { 0 }; - WebIDL::UnsignedLongLong total { 0 }; + WebIDL::Double loaded { 0 }; + WebIDL::Double total { 0 }; }; class ProgressEvent final : public DOM::Event { @@ -29,8 +29,8 @@ public: virtual ~ProgressEvent() override; bool length_computable() const { return m_length_computable; } - WebIDL::UnsignedLongLong loaded() const { return m_loaded; } - WebIDL::UnsignedLongLong total() const { return m_total; } + WebIDL::Double loaded() const { return m_loaded; } + WebIDL::Double total() const { return m_total; } private: ProgressEvent(JS::Realm&, FlyString const& event_name, ProgressEventInit const& event_init); @@ -38,8 +38,8 @@ private: virtual void initialize(JS::Realm&) override; bool m_length_computable { false }; - WebIDL::UnsignedLongLong m_loaded { 0 }; - WebIDL::UnsignedLongLong m_total { 0 }; + WebIDL::Double m_loaded { 0 }; + WebIDL::Double m_total { 0 }; }; } diff --git a/Libraries/LibWeb/XHR/ProgressEvent.idl b/Libraries/LibWeb/XHR/ProgressEvent.idl index f0b796ac65f..f01e5027222 100644 --- a/Libraries/LibWeb/XHR/ProgressEvent.idl +++ b/Libraries/LibWeb/XHR/ProgressEvent.idl @@ -6,12 +6,12 @@ interface ProgressEvent : Event { constructor(DOMString type, optional ProgressEventInit eventInitDict = {}); readonly attribute boolean lengthComputable; - readonly attribute unsigned long long loaded; - readonly attribute unsigned long long total; + readonly attribute double loaded; + readonly attribute double total; }; dictionary ProgressEventInit : EventInit { boolean lengthComputable = false; - unsigned long long loaded = 0; - unsigned long long total = 0; + double loaded = 0; + double total = 0; }; diff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/progressevent-constructor.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/progressevent-constructor.txt new file mode 100644 index 00000000000..1eddf4d6fb1 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/progressevent-constructor.txt @@ -0,0 +1,15 @@ +Harness status: OK + +Found 10 tests + +10 Pass +Pass Default event values. +Pass There must not be a initProgressEvent(). +Pass Basic test. +Pass ECMAScript value conversion test. +Pass Positive integer number test. +Pass Zero test. +Pass Decimal number test. +Pass Mixed integer and decimal number test. +Pass Negative number. +Pass ProgressEventInit members must be matched case-sensitively. \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/xhr/progressevent-constructor.html b/Tests/LibWeb/Text/input/wpt-import/xhr/progressevent-constructor.html new file mode 100644 index 00000000000..924a22244fb --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/xhr/progressevent-constructor.html @@ -0,0 +1,77 @@ + +ProgressEvent constructor + + + + + +
+