|
@@ -11,6 +11,7 @@
|
|
#include <AK/JsonObject.h>
|
|
#include <AK/JsonObject.h>
|
|
#include <AK/JsonValue.h>
|
|
#include <AK/JsonValue.h>
|
|
#include <AK/Vector.h>
|
|
#include <AK/Vector.h>
|
|
|
|
+#include <LibJS/Runtime/Value.h>
|
|
#include <LibWeb/DOM/Document.h>
|
|
#include <LibWeb/DOM/Document.h>
|
|
#include <LibWeb/DOM/Element.h>
|
|
#include <LibWeb/DOM/Element.h>
|
|
#include <LibWeb/HTML/AttributeNames.h>
|
|
#include <LibWeb/HTML/AttributeNames.h>
|
|
@@ -524,6 +525,36 @@ Messages::WebDriverClient::GetElementAttributeResponse WebDriverConnection::get_
|
|
return make_success_response({});
|
|
return make_success_response({});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 12.4.3 Get Element Property, https://w3c.github.io/webdriver/#dfn-get-element-property
|
|
|
|
+Messages::WebDriverClient::GetElementPropertyResponse WebDriverConnection::get_element_property(String const& element_id, String const& name)
|
|
|
|
+{
|
|
|
|
+ // 1. If the current browsing context is no longer open, return error with error code no such window.
|
|
|
|
+ TRY(ensure_open_top_level_browsing_context());
|
|
|
|
+
|
|
|
|
+ // FIXME: 2. Handle any user prompts and return its value if it is an error.
|
|
|
|
+
|
|
|
|
+ // 3. Let element be the result of trying to get a known connected element with url variable element id.
|
|
|
|
+ auto* element = TRY(get_known_connected_element(element_id));
|
|
|
|
+
|
|
|
|
+ Optional<String> result;
|
|
|
|
+
|
|
|
|
+ // 4. Let property be the result of calling the Object.[[GetProperty]](name) on element.
|
|
|
|
+ if (auto property_or_error = element->get(name); !property_or_error.is_throw_completion()) {
|
|
|
|
+ auto property = property_or_error.release_value();
|
|
|
|
+
|
|
|
|
+ // 5. Let result be the value of property if not undefined, or null.
|
|
|
|
+ if (!property.is_undefined()) {
|
|
|
|
+ if (auto string_or_error = property.to_string(element->vm()); !string_or_error.is_error())
|
|
|
|
+ result = string_or_error.release_value();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 6. Return success with data result.
|
|
|
|
+ if (result.has_value())
|
|
|
|
+ return make_success_response(result.release_value());
|
|
|
|
+ return make_success_response({});
|
|
|
|
+}
|
|
|
|
+
|
|
// https://w3c.github.io/webdriver/#dfn-no-longer-open
|
|
// https://w3c.github.io/webdriver/#dfn-no-longer-open
|
|
ErrorOr<void, Web::WebDriver::Error> WebDriverConnection::ensure_open_top_level_browsing_context()
|
|
ErrorOr<void, Web::WebDriver::Error> WebDriverConnection::ensure_open_top_level_browsing_context()
|
|
{
|
|
{
|