diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 406a323218..d31829eba7 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -808,6 +808,13 @@ ThrowCompletionOr> Object::internal_get_own_propert // 3. Let X be O's own property whose key is P. auto [value, attributes, property_offset] = *maybe_storage_entry; + // AD-HOC: Properties with the [[Unimplemented]] attribute are used for reporting unimplemented IDL interfaces. + if (attributes.is_unimplemented()) { + if (vm().on_unimplemented_property_access) + vm().on_unimplemented_property_access(*this, property_key); + descriptor.unimplemented = true; + } + // 4. If X is a data property, then if (!value.is_accessor()) { // a. Set D.[[Value]] to the value of X's [[Value]] attribute. diff --git a/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h b/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h index 1ab8a251fb..fa15a21ba6 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h +++ b/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h @@ -19,6 +19,8 @@ struct Attribute { Writable = 1 << 0, Enumerable = 1 << 1, Configurable = 1 << 2, + // AD-HOC: This is used for reporting unimplemented IDL interfaces. + Unimplemented = 1 << 3, }; }; @@ -33,6 +35,7 @@ public: [[nodiscard]] bool is_writable() const { return m_bits & Attribute::Writable; } [[nodiscard]] bool is_enumerable() const { return m_bits & Attribute::Enumerable; } [[nodiscard]] bool is_configurable() const { return m_bits & Attribute::Configurable; } + [[nodiscard]] bool is_unimplemented() const { return m_bits & Attribute::Unimplemented; } void set_writable(bool writable = true) { diff --git a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h index d8888ce628..9eea4de315 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h +++ b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h @@ -31,7 +31,7 @@ public: // Not a standard abstract operation, but "If every field in Desc is absent". [[nodiscard]] bool is_empty() const { - return !value.has_value() && !get.has_value() && !set.has_value() && !writable.has_value() && !enumerable.has_value() && !configurable.has_value(); + return !value.has_value() && !get.has_value() && !set.has_value() && !writable.has_value() && !enumerable.has_value() && !configurable.has_value() && !unimplemented.has_value(); } Optional value {}; @@ -40,6 +40,7 @@ public: Optional writable {}; Optional enumerable {}; Optional configurable {}; + Optional unimplemented {}; Optional property_offset {}; }; @@ -65,6 +66,8 @@ struct Formatter : Formatter { TRY(parts.try_append(TRY(String::formatted("[[Enumerable]]: {}", *property_descriptor.enumerable)))); if (property_descriptor.configurable.has_value()) TRY(parts.try_append(TRY(String::formatted("[[Configurable]]: {}", *property_descriptor.configurable)))); + if (property_descriptor.unimplemented.has_value()) + TRY(parts.try_append(TRY(String::formatted("[[Unimplemented]]: {}", *property_descriptor.unimplemented)))); return Formatter::format(builder, TRY(String::formatted("PropertyDescriptor {{ {} }}", TRY(String::join(", "sv, parts))))); } }; diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index 80c247f559..646c1eca3e 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -223,6 +223,7 @@ public: Function on_call_stack_emptied; Function on_promise_unhandled_rejection; Function on_promise_rejection_handled; + Function on_unimplemented_property_access; CustomData* custom_data() { return m_custom_data; }