mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 17:15:08 +00:00
LibWeb: Support relative URL's in XMLHttpRequest
In order to complete a relative URL, we need a Document. Fix this by giving XMLHttpRequest a pointer to its window object. Then we can go from the window to the document, and then we're home free. :^)
This commit is contained in:
parent
4ffac713b9
commit
4036f15728
3 changed files with 11 additions and 5 deletions
|
@ -28,14 +28,17 @@
|
|||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibWeb/Bindings/EventWrapper.h>
|
||||
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/DOM/EventListener.h>
|
||||
#include <LibWeb/DOM/Window.h>
|
||||
#include <LibWeb/DOM/XMLHttpRequest.h>
|
||||
#include <LibWeb/ResourceLoader.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
XMLHttpRequest::XMLHttpRequest()
|
||||
XMLHttpRequest::XMLHttpRequest(Window& window)
|
||||
: m_window(window)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -59,7 +62,7 @@ void XMLHttpRequest::open(const String& method, const String& url)
|
|||
void XMLHttpRequest::send()
|
||||
{
|
||||
ResourceLoader::the().load(
|
||||
URL(m_url),
|
||||
m_window->document().complete_url(m_url),
|
||||
[weak_this = make_weak_ptr()](auto& data) {
|
||||
if (!weak_this)
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue