mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibWeb: Implement XMLHttpRequest.responseURL
This was used on https://twinings.co.uk/ so let's support it :^)
This commit is contained in:
parent
34f2cbf202
commit
527ad9ac01
Notes:
sideshowbarker
2024-07-17 01:28:15 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/527ad9ac01 Pull-request: https://github.com/SerenityOS/serenity/pull/24177
@ -0,0 +1,2 @@
|
||||
responseURL before: ''
|
||||
responseURL after: 'data:text/html,hello'
|
15
Tests/LibWeb/Text/input/XHR/XMLHttpRequest-responseURL.html
Normal file
15
Tests/LibWeb/Text/input/XHR/XMLHttpRequest-responseURL.html
Normal file
@ -0,0 +1,15 @@
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
asyncTest((done) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "data:text/html,hello", true);
|
||||
println("responseURL before: '" + xhr.responseURL + "'");
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
println("responseURL after: '" + xhr.responseURL + "'");
|
||||
done();
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
});
|
||||
</script>
|
@ -1265,4 +1265,16 @@ JS::ThrowCompletionOr<void> XMLHttpRequest::request_error_steps(FlyString const&
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://xhr.spec.whatwg.org/#the-responseurl-attribute
|
||||
String XMLHttpRequest::response_url()
|
||||
{
|
||||
// The responseURL getter steps are to return the empty string if this’s response’s URL is null;
|
||||
// otherwise its serialization with the exclude fragment flag set.
|
||||
if (!m_response->url().has_value())
|
||||
return String {};
|
||||
|
||||
auto serialized = m_response->url().value().serialize(URL::ExcludeFragment::Yes);
|
||||
return String::from_utf8_without_validation(serialized.bytes());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
WebIDL::ExceptionOr<JS::GCPtr<DOM::Document>> response_xml();
|
||||
WebIDL::ExceptionOr<JS::Value> response();
|
||||
Bindings::XMLHttpRequestResponseType response_type() const { return m_response_type; }
|
||||
String response_url();
|
||||
|
||||
WebIDL::ExceptionOr<void> open(String const& method, String const& url);
|
||||
WebIDL::ExceptionOr<void> open(String const& method, String const& url, bool async, Optional<String> const& username = Optional<String> {}, Optional<String> const& password = Optional<String> {});
|
||||
|
@ -41,7 +41,7 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
||||
undefined abort();
|
||||
|
||||
// response
|
||||
// FIXME: readonly attribute USVString responseURL;
|
||||
readonly attribute USVString responseURL;
|
||||
readonly attribute unsigned short status;
|
||||
readonly attribute ByteString statusText;
|
||||
ByteString? getResponseHeader(ByteString name);
|
||||
|
Loading…
Reference in New Issue
Block a user