Skip to content

Truly independent web browser

LibWeb: Return the same detail object from user timing entries

Andreas Klinge67785fd4373
diff --git a/Libraries/LibWeb/UserTiming/PerformanceMark.cpp b/Libraries/LibWeb/UserTiming/PerformanceMark.cpp
index 4c91e85add5..b83276b707a 100644
--- a/Libraries/LibWeb/UserTiming/PerformanceMark.cpp
+++ b/Libraries/LibWeb/UserTiming/PerformanceMark.cpp
@@ -92,11 +92,11 @@ Utf16FlyString const& PerformanceMark::entry_type() const
return PerformanceTimeline::EntryTypes::mark;
}
-WebIDL::ExceptionOr<JS::Value> PerformanceMark::detail(JS::Object const& relevant_global_object) const
+// https://w3c.github.io/user-timing/#dom-performancemark-detail
+WebIDL::ExceptionOr<JS::Value> PerformanceMark::detail(JS::Object const&) const
{
- auto& relevant_realm = HTML::relevant_realm(relevant_global_object);
- auto serialized = TRY(HTML::structured_serialize(relevant_realm.vm(), m_detail));
- return HTML::structured_deserialize(relevant_realm.vm(), serialized, relevant_realm);
+ // NB: The detail was structured-cloned when this entry was created, so it is returned as is.
+ return m_detail;
}
void PerformanceMark::visit_edges(JS::Cell::Visitor& visitor)
diff --git a/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp b/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp
index b6daed3761d..29a4ebcc592 100644
--- a/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp
+++ b/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp
@@ -5,8 +5,6 @@
*/
#include <LibGC/Heap.h>
-#include <LibWeb/HTML/Scripting/Environments.h>
-#include <LibWeb/HTML/StructuredSerialize.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
#include <LibWeb/NavigationTiming/EntryNames.h>
@@ -36,11 +34,11 @@ Utf16FlyString const& PerformanceMeasure::entry_type() const
return PerformanceTimeline::EntryTypes::measure;
}
-WebIDL::ExceptionOr<JS::Value> PerformanceMeasure::detail(JS::Object const& relevant_global_object) const
+// https://w3c.github.io/user-timing/#dom-performancemeasure-detail
+WebIDL::ExceptionOr<JS::Value> PerformanceMeasure::detail(JS::Object const&) const
{
- auto& relevant_realm = HTML::relevant_realm(relevant_global_object);
- auto serialized = TRY(HTML::structured_serialize(relevant_realm.vm(), m_detail));
- return HTML::structured_deserialize(relevant_realm.vm(), serialized, relevant_realm);
+ // NB: The detail was structured-cloned when this entry was created, so it is returned as is.
+ return m_detail;
}
void PerformanceMeasure::visit_edges(JS::Cell::Visitor& visitor)
diff --git a/Tests/LibWeb/Text/expected/UserTiming/performance-entry-detail.txt b/Tests/LibWeb/Text/expected/UserTiming/performance-entry-detail.txt
index 763507f53cd..cb702a7f060 100644
--- a/Tests/LibWeb/Text/expected/UserTiming/performance-entry-detail.txt
+++ b/Tests/LibWeb/Text/expected/UserTiming/performance-entry-detail.txt
@@ -1,11 +1,11 @@
mark.detail.source: mark
mark.detail.values: 1,2,3
-mark.detail identity: false
+mark.detail identity: true
buffered mark detail source: mark
buffered mark detail values: 1,2,3
measure.detail.source: measure
measure.detail.nested.ok: true
-measure.detail identity: false
+measure.detail identity: true
buffered measure detail source: measure
buffered measure detail nested ok: true
no detail mark: null
diff --git a/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.txt b/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.txt
index a7b63d366b3..fc86e17242b 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.txt
@@ -2,14 +2,13 @@ Harness status: OK
Found 9 tests
-8 Pass
-1 Fail
+9 Pass
Pass The detail property in the mark constructor should be structured-clone.
Pass The detail property in the mark method should be structured-clone.
Pass When accessing detail from a mark entry and the detail is not provided, just return a null value.
Pass Mark: Throw an exception when the detail property cannot be structured-serialized.
Pass The detail property in the measure method should be structured-clone.
-Fail The detail property in the measure method should be the same reference.
+Pass The detail property in the measure method should be the same reference.
Pass When accessing detail from a measure entry and the detail is not provided, just return a null value.
Pass Measure: Throw an exception when the detail property cannot be structured-serialized.
Pass The detail object is cloned when passed to mark API.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.worker.txt
index a7b63d366b3..fc86e17242b 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/user-timing/structured-serialize-detail.any.worker.txt
@@ -2,14 +2,13 @@ Harness status: OK
Found 9 tests
-8 Pass
-1 Fail
+9 Pass
Pass The detail property in the mark constructor should be structured-clone.
Pass The detail property in the mark method should be structured-clone.
Pass When accessing detail from a mark entry and the detail is not provided, just return a null value.
Pass Mark: Throw an exception when the detail property cannot be structured-serialized.
Pass The detail property in the measure method should be structured-clone.
-Fail The detail property in the measure method should be the same reference.
+Pass The detail property in the measure method should be the same reference.
Pass When accessing detail from a measure entry and the detail is not provided, just return a null value.
Pass Measure: Throw an exception when the detail property cannot be structured-serialized.
Pass The detail object is cloned when passed to mark API.
\ No newline at end of file