summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibWeb/Bindings/LocationObject.cpp8
-rw-r--r--Libraries/LibWeb/DOM/Window.cpp14
-rw-r--r--Libraries/LibWeb/DOM/Window.h2
-rw-r--r--Libraries/LibWeb/Forward.h1
4 files changed, 23 insertions, 2 deletions
diff --git a/Libraries/LibWeb/Bindings/LocationObject.cpp b/Libraries/LibWeb/Bindings/LocationObject.cpp
index 302f64db40..f819903195 100644
--- a/Libraries/LibWeb/Bindings/LocationObject.cpp
+++ b/Libraries/LibWeb/Bindings/LocationObject.cpp
@@ -54,9 +54,13 @@ JS::Value LocationObject::href_getter(JS::Interpreter& interpreter)
return JS::js_string(interpreter, window.impl().document().url().to_string());
}
-void LocationObject::href_setter(JS::Interpreter&, JS::Value)
+void LocationObject::href_setter(JS::Interpreter& interpreter, JS::Value value)
{
- // FIXME: Navigate to a new URL
+ auto& window = static_cast<WindowObject&>(interpreter.global_object());
+ auto new_href = value.to_string(interpreter);
+ if (interpreter.exception())
+ return;
+ window.impl().did_set_location_href({}, new_href);
}
JS::Value LocationObject::pathname_getter(JS::Interpreter& interpreter)
diff --git a/Libraries/LibWeb/DOM/Window.cpp b/Libraries/LibWeb/DOM/Window.cpp
index adac5c5068..01bf4ca225 100644
--- a/Libraries/LibWeb/DOM/Window.cpp
+++ b/Libraries/LibWeb/DOM/Window.cpp
@@ -30,7 +30,10 @@
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/Function.h>
#include <LibJS/Runtime/MarkedValueList.h>
+#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Window.h>
+#include <LibWeb/Frame.h>
+#include <LibWeb/HtmlView.h>
namespace Web {
@@ -105,4 +108,15 @@ void Window::cancel_animation_frame(i32 id)
GUI::DisplayLink::unregister_callback(id);
}
+void Window::did_set_location_href(Badge<Bindings::LocationObject>, const String& new_href)
+{
+ auto* frame = document().frame();
+ if (!frame)
+ return;
+ auto* view = frame->html_view();
+ if (!view)
+ return;
+ view->load(new_href);
+}
+
}
diff --git a/Libraries/LibWeb/DOM/Window.h b/Libraries/LibWeb/DOM/Window.h
index 03d548b71a..77214a7de6 100644
--- a/Libraries/LibWeb/DOM/Window.h
+++ b/Libraries/LibWeb/DOM/Window.h
@@ -49,6 +49,8 @@ public:
void set_interval(JS::Function&, i32);
void set_timeout(JS::Function&, i32);
+ void did_set_location_href(Badge<Bindings::LocationObject>, const String& new_href);
+
private:
explicit Window(Document&);
diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h
index b54f45f958..f84af285ec 100644
--- a/Libraries/LibWeb/Forward.h
+++ b/Libraries/LibWeb/Forward.h
@@ -67,6 +67,7 @@ class EventTargetWrapper;
class HTMLCanvasElementWrapper;
class HTMLImageElementWrapper;
class ImageDataWrapper;
+class LocationObject;
class MouseEventWrapper;
class NodeWrapper;
class WindowObject;