summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-18 15:06:13 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-18 15:11:20 +0100
commit9e45594dc83d75e3bec90e5e519e8473f808ec85 (patch)
tree7ec18f6e3f4a514fcb54ef9213a758a5d359db3d /Userland/Libraries/LibWeb
parentc99e35485a84dd8ec46f144b1ae781aaed89cc84 (diff)
downloadserenity-9e45594dc83d75e3bec90e5e519e8473f808ec85.zip
LibWeb: Stub out the PerformanceTiming object from Navigation Timing
Just have all the timing functions return 0 for now. We can now run the Shynet JS on https://linus.dev/ although the XHR is rejected by our same-origin policy.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h3
-rw-r--r--Userland/Libraries/LibWeb/CMakeLists.txt2
-rw-r--r--Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp13
-rw-r--r--Userland/Libraries/LibWeb/Forward.h5
-rw-r--r--Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp1
-rw-r--r--Userland/Libraries/LibWeb/HighResolutionTime/Performance.h5
-rw-r--r--Userland/Libraries/LibWeb/HighResolutionTime/Performance.idl2
-rw-r--r--Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.cpp51
-rw-r--r--Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.h71
-rw-r--r--Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.idl25
10 files changed, 176 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h b/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h
index b37afe1894..94b115ef19 100644
--- a/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h
+++ b/Userland/Libraries/LibWeb/Bindings/WindowObjectHelper.h
@@ -198,6 +198,8 @@
#include <LibWeb/Bindings/NodePrototype.h>
#include <LibWeb/Bindings/PerformanceConstructor.h>
#include <LibWeb/Bindings/PerformancePrototype.h>
+#include <LibWeb/Bindings/PerformanceTimingConstructor.h>
+#include <LibWeb/Bindings/PerformanceTimingPrototype.h>
#include <LibWeb/Bindings/SVGElementConstructor.h>
#include <LibWeb/Bindings/SVGElementPrototype.h>
#include <LibWeb/Bindings/SVGGeometryElementConstructor.h>
@@ -308,6 +310,7 @@
ADD_WINDOW_OBJECT_INTERFACE(MouseEvent) \
ADD_WINDOW_OBJECT_INTERFACE(Node) \
ADD_WINDOW_OBJECT_INTERFACE(Performance) \
+ ADD_WINDOW_OBJECT_INTERFACE(PerformanceTiming) \
ADD_WINDOW_OBJECT_INTERFACE(ShadowRoot) \
ADD_WINDOW_OBJECT_INTERFACE(SubmitEvent) \
ADD_WINDOW_OBJECT_INTERFACE(SVGElement) \
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt
index 7e97391a76..eef44ab9a1 100644
--- a/Userland/Libraries/LibWeb/CMakeLists.txt
+++ b/Userland/Libraries/LibWeb/CMakeLists.txt
@@ -185,6 +185,7 @@ set(SOURCES
Loader/Resource.cpp
Loader/ResourceLoader.cpp
Namespace.cpp
+ NavigationTiming/PerformanceTiming.cpp
OutOfProcessWebView.cpp
Page/EventHandler.cpp
Page/EditEventHandler.cpp
@@ -365,6 +366,7 @@ libweb_js_wrapper(HTML/HTMLVideoElement)
libweb_js_wrapper(HTML/ImageData)
libweb_js_wrapper(HTML/SubmitEvent)
libweb_js_wrapper(HighResolutionTime/Performance)
+libweb_js_wrapper(NavigationTiming/PerformanceTiming)
libweb_js_wrapper(SVG/SVGElement)
libweb_js_wrapper(SVG/SVGGeometryElement)
libweb_js_wrapper(SVG/SVGGraphicsElement)
diff --git a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
index 7578776aec..d50186e88a 100644
--- a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
+++ b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
@@ -363,7 +363,7 @@ int main(int argc, char** argv)
return 1;
}
- if (namespace_.is_one_of("DOM", "HTML", "UIEvents", "HighResolutionTime", "SVG")) {
+ if (namespace_.is_one_of("DOM", "HTML", "UIEvents", "HighResolutionTime", "NavigationTiming", "SVG")) {
StringBuilder builder;
builder.append(namespace_);
builder.append("::");
@@ -474,6 +474,8 @@ static void generate_header(const IDL::Interface& interface)
# include <LibWeb/UIEvents/@name@.h>
#elif __has_include(<LibWeb/HighResolutionTime/@name@.h>)
# include <LibWeb/HighResolutionTime/@name@.h>
+#elif __has_include(<LibWeb/NavigationTiming/@name@.h>)
+# include <LibWeb/NavigationTiming/@name@.h>
#elif __has_include(<LibWeb/SVG/@name@.h>)
# include <LibWeb/SVG/@name@.h>
#endif
@@ -586,7 +588,7 @@ namespace Web::Bindings {
if (interface.wrapper_base_class == "Wrapper") {
generator.append(R"~~~(
@wrapper_class@::@wrapper_class@(JS::GlobalObject& global_object, @fully_qualified_name@& impl)
- : Wrapper(*global_object.object_prototype())
+ : Wrapper(static_cast<WindowObject&>(global_object).ensure_web_prototype<@prototype_class@>("@name@"))
, m_impl(impl)
{
}
@@ -692,6 +694,8 @@ void generate_constructor_implementation(const IDL::Interface& interface)
# include <LibWeb/UIEvents/@name@.h>
#elif __has_include(<LibWeb/HighResolutionTime/@name@.h>)
# include <LibWeb/HighResolutionTime/@name@.h>
+#elif __has_include(<LibWeb/NavigationTiming/@name@.h>)
+# include <LibWeb/NavigationTiming/@name@.h>
#elif __has_include(<LibWeb/SVG/@name@.h>)
# include <LibWeb/SVG/@name@.h>
#endif
@@ -836,12 +840,14 @@ void generate_prototype_implementation(const IDL::Interface& interface)
#include <LibWeb/Bindings/HTMLImageElementWrapper.h>
#include <LibWeb/Bindings/ImageDataWrapper.h>
#include <LibWeb/Bindings/NodeWrapperFactory.h>
+#include <LibWeb/Bindings/PerformanceTimingWrapper.h>
#include <LibWeb/Bindings/TextWrapper.h>
#include <LibWeb/Bindings/WindowObject.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/EventListener.h>
#include <LibWeb/DOM/Window.h>
#include <LibWeb/HTML/HTMLElement.h>
+#include <LibWeb/NavigationTiming/PerformanceTiming.h>
#include <LibWeb/Origin.h>
#if __has_include(<LibWeb/Bindings/@prototype_base_class@.h>)
@@ -855,6 +861,8 @@ void generate_prototype_implementation(const IDL::Interface& interface)
# include <LibWeb/UIEvents/@name@.h>
#elif __has_include(<LibWeb/HighResolutionTime/@name@.h>)
# include <LibWeb/HighResolutionTime/@name@.h>
+#elif __has_include(<LibWeb/NavigationTiming/@name@.h>)
+# include <LibWeb/NavigationTiming/@name@.h>
#elif __has_include(<LibWeb/SVG/@name@.h>)
# include <LibWeb/SVG/@name@.h>
#endif
@@ -862,6 +870,7 @@ void generate_prototype_implementation(const IDL::Interface& interface)
// FIXME: This is a total hack until we can figure out the namespace for a given type somehow.
using namespace Web::DOM;
using namespace Web::HTML;
+using namespace Web::NavigationTiming;
namespace Web::Bindings {
diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h
index 445b7222fa..7c50a1a759 100644
--- a/Userland/Libraries/LibWeb/Forward.h
+++ b/Userland/Libraries/LibWeb/Forward.h
@@ -142,6 +142,10 @@ namespace Web::HighResolutionTime {
class Performance;
}
+namespace Web::NavigationTiming {
+class PerformanceTiming;
+}
+
namespace Web::SVG {
class SVGElement;
class SVGGeometryElement;
@@ -274,6 +278,7 @@ class ImageDataWrapper;
class LocationObject;
class MouseEventWrapper;
class NodeWrapper;
+class PerformanceTimingWrapper;
class PerformanceWrapper;
class ScriptExecutionContext;
class SubmitEventWrapper;
diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp
index 1de64d81fb..ffafa8d2b1 100644
--- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp
+++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp
@@ -36,6 +36,7 @@ namespace Web::HighResolutionTime {
Performance::Performance(DOM::Window& window)
: DOM::EventTarget(static_cast<Bindings::ScriptExecutionContext&>(window.document()))
, m_window(window)
+ , m_timing(make<NavigationTiming::PerformanceTiming>(window))
{
m_timer.start();
}
diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h
index 7848beedcc..c51d4ad080 100644
--- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h
+++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h
@@ -30,6 +30,7 @@
#include <LibCore/ElapsedTimer.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/DOM/EventTarget.h>
+#include <LibWeb/NavigationTiming/PerformanceTiming.h>
namespace Web::HighResolutionTime {
@@ -46,6 +47,8 @@ public:
double now() const { return m_timer.elapsed(); }
double time_origin() const;
+ RefPtr<NavigationTiming::PerformanceTiming> timing() { return *m_timing; }
+
virtual void ref_event_target() override;
virtual void unref_event_target() override;
@@ -55,6 +58,8 @@ public:
private:
DOM::Window& m_window;
Core::ElapsedTimer m_timer;
+
+ OwnPtr<NavigationTiming::PerformanceTiming> m_timing;
};
}
diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.idl b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.idl
index 889760a08a..278bffde4b 100644
--- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.idl
+++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.idl
@@ -1,4 +1,6 @@
interface Performance : EventTarget {
double now();
readonly attribute double timeOrigin;
+
+ readonly attribute PerformanceTiming timing;
};
diff --git a/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.cpp b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.cpp
new file mode 100644
index 0000000000..b5b8efbf41
--- /dev/null
+++ b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <LibWeb/DOM/Window.h>
+#include <LibWeb/NavigationTiming/PerformanceTiming.h>
+
+namespace Web::NavigationTiming {
+
+PerformanceTiming::PerformanceTiming(DOM::Window& window)
+ : m_window(window)
+{
+}
+
+PerformanceTiming::~PerformanceTiming()
+{
+}
+
+void PerformanceTiming::ref()
+{
+ m_window.ref();
+}
+
+void PerformanceTiming::unref()
+{
+ m_window.unref();
+}
+
+}
diff --git a/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.h b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.h
new file mode 100644
index 0000000000..1460ccee50
--- /dev/null
+++ b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <AK/StdLibExtras.h>
+#include <LibWeb/Bindings/Wrappable.h>
+
+namespace Web::NavigationTiming {
+
+class PerformanceTiming final : public Bindings::Wrappable {
+public:
+ using WrapperType = Bindings::PerformanceTimingWrapper;
+ using AllowOwnPtr = AK::TrueType;
+
+ explicit PerformanceTiming(DOM::Window&);
+ ~PerformanceTiming();
+
+ void ref();
+ void unref();
+
+ u32 navigation_start() { return 0; }
+ u32 unload_event_start() { return 0; }
+ u32 unload_event_end() { return 0; }
+ u32 redirect_start() { return 0; }
+ u32 redirect_end() { return 0; }
+ u32 fetch_start() { return 0; }
+ u32 domain_lookup_start() { return 0; }
+ u32 domain_lookup_end() { return 0; }
+ u32 connect_start() { return 0; }
+ u32 connect_end() { return 0; }
+ u32 secure_connection_start() { return 0; }
+ u32 request_start() { return 0; }
+ u32 response_start() { return 0; }
+ u32 response_end() { return 0; }
+ u32 dom_loading() { return 0; }
+ u32 dom_interactive() { return 0; }
+ u32 dom_content_loaded_event_start() { return 0; }
+ u32 dom_content_loaded_event_end() { return 0; }
+ u32 dom_complete() { return 0; }
+ u32 load_event_start() { return 0; }
+ u32 load_event_end() { return 0; }
+
+private:
+ DOM::Window& m_window;
+};
+
+}
diff --git a/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.idl b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.idl
new file mode 100644
index 0000000000..87c87c64a3
--- /dev/null
+++ b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.idl
@@ -0,0 +1,25 @@
+interface PerformanceTiming {
+
+ readonly attribute unsigned long navigationStart;
+ readonly attribute unsigned long unloadEventStart;
+ readonly attribute unsigned long unloadEventEnd;
+ readonly attribute unsigned long redirectStart;
+ readonly attribute unsigned long redirectEnd;
+ readonly attribute unsigned long fetchStart;
+ readonly attribute unsigned long domainLookupStart;
+ readonly attribute unsigned long domainLookupEnd;
+ readonly attribute unsigned long connectStart;
+ readonly attribute unsigned long connectEnd;
+ readonly attribute unsigned long secureConnectionStart;
+ readonly attribute unsigned long requestStart;
+ readonly attribute unsigned long responseStart;
+ readonly attribute unsigned long responseEnd;
+ readonly attribute unsigned long domLoading;
+ readonly attribute unsigned long domInteractive;
+ readonly attribute unsigned long domContentLoadedEventStart;
+ readonly attribute unsigned long domContentLoadedEventEnd;
+ readonly attribute unsigned long domComplete;
+ readonly attribute unsigned long loadEventStart;
+ readonly attribute unsigned long loadEventEnd;
+
+};