- Revision
- 279203
- Author
- [email protected]
- Date
- 2021-06-23 19:06:53 -0700 (Wed, 23 Jun 2021)
Log Message
Fix some PerformanceNavigationTiming bugs
https://bugs.webkit.org/show_bug.cgi?id=227329
Patch by Alex Christensen <[email protected]> on 2021-06-23
Reviewed by Chris Dumez.
LayoutTests/imported/w3c:
* web-platform-tests/navigation-timing/buffered-flag.window-expected.txt: Added.
* web-platform-tests/navigation-timing/buffered-flag.window.html: Added.
* web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt:
Source/WebCore:
Test: imported/w3c/web-platform-tests/navigation-timing/buffered-flag.window.html
This fixes two bugs:
1. We need to delay the PerformanceObserver event until didFinishNavigation time, which is after iframes have also finished loading.
2. We need to remember whether we've added the PerformanceNavigationTiming to a PerformanceObserver's list to avoid duplicate entries.
This fixes two WPT tests that were passed by Chrome and Firefox.
PerformanceNavigationTiming is still an off-by-default experimental feature, so this won't affect anything yet.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::checkLoadCompleteForThisFrame):
* page/Performance.cpp:
(WebCore::Performance::appendBufferedEntriesByType const):
(WebCore::Performance::registerPerformanceObserver):
(WebCore::Performance::scheduleNavigationObservationTaskIfNeeded):
* page/Performance.h:
* page/PerformanceObserver.cpp:
(WebCore::PerformanceObserver::observe):
* page/PerformanceObserver.h:
(WebCore::PerformanceObserver::hasNavigationTiming const):
(WebCore::PerformanceObserver::addedNavigationTiming):
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279202 => 279203)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-06-24 01:58:27 UTC (rev 279202)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-06-24 02:06:53 UTC (rev 279203)
@@ -1,3 +1,14 @@
+2021-06-23 Alex Christensen <[email protected]>
+
+ Fix some PerformanceNavigationTiming bugs
+ https://bugs.webkit.org/show_bug.cgi?id=227329
+
+ Reviewed by Chris Dumez.
+
+ * web-platform-tests/navigation-timing/buffered-flag.window-expected.txt: Added.
+ * web-platform-tests/navigation-timing/buffered-flag.window.html: Added.
+ * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt:
+
2021-06-23 Chris Dumez <[email protected]>
Update WPT resources from upstream
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/buffered-flag.window-expected.txt (0 => 279203)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/buffered-flag.window-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/buffered-flag.window-expected.txt 2021-06-24 02:06:53 UTC (rev 279203)
@@ -0,0 +1,3 @@
+
+PASS PerformanceObserver with buffered flag sees previous navigation entry.
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/buffered-flag.window.html (0 => 279203)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/buffered-flag.window.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/buffered-flag.window.html 2021-06-24 02:06:53 UTC (rev 279203)
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt (279202 => 279203)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt 2021-06-24 01:58:27 UTC (rev 279202)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt 2021-06-24 02:06:53 UTC (rev 279203)
@@ -3,5 +3,5 @@
This test validates that each window has a unique nav timing 2 instance.
-FAIL Each window has a unique nav timing 2 instance. assert_equals: Only one nav timing instance exists. expected 1 but got 0
+PASS Each window has a unique nav timing 2 instance.
Modified: trunk/Source/WebCore/ChangeLog (279202 => 279203)
--- trunk/Source/WebCore/ChangeLog 2021-06-24 01:58:27 UTC (rev 279202)
+++ trunk/Source/WebCore/ChangeLog 2021-06-24 02:06:53 UTC (rev 279203)
@@ -1,3 +1,32 @@
+2021-06-23 Alex Christensen <[email protected]>
+
+ Fix some PerformanceNavigationTiming bugs
+ https://bugs.webkit.org/show_bug.cgi?id=227329
+
+ Reviewed by Chris Dumez.
+
+ Test: imported/w3c/web-platform-tests/navigation-timing/buffered-flag.window.html
+
+ This fixes two bugs:
+ 1. We need to delay the PerformanceObserver event until didFinishNavigation time, which is after iframes have also finished loading.
+ 2. We need to remember whether we've added the PerformanceNavigationTiming to a PerformanceObserver's list to avoid duplicate entries.
+
+ This fixes two WPT tests that were passed by Chrome and Firefox.
+ PerformanceNavigationTiming is still an off-by-default experimental feature, so this won't affect anything yet.
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
+ * page/Performance.cpp:
+ (WebCore::Performance::appendBufferedEntriesByType const):
+ (WebCore::Performance::registerPerformanceObserver):
+ (WebCore::Performance::scheduleNavigationObservationTaskIfNeeded):
+ * page/Performance.h:
+ * page/PerformanceObserver.cpp:
+ (WebCore::PerformanceObserver::observe):
+ * page/PerformanceObserver.h:
+ (WebCore::PerformanceObserver::hasNavigationTiming const):
+ (WebCore::PerformanceObserver::addedNavigationTiming):
+
2021-06-23 Truitt Savell <[email protected]>
Fix iOS Debug testing be removing the assert added in r279119
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (279202 => 279203)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2021-06-24 01:58:27 UTC (rev 279202)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2021-06-24 02:06:53 UTC (rev 279203)
@@ -94,6 +94,7 @@
#include "Node.h"
#include "Page.h"
#include "PageTransitionEvent.h"
+#include "Performance.h"
#include "PerformanceLogging.h"
#include "PlatformStrategies.h"
#include "PluginData.h"
@@ -2562,6 +2563,9 @@
}
}
+ if (auto domWindow = makeRefPtr(m_frame.document() ? m_frame.document()->domWindow() : nullptr))
+ domWindow->performance().scheduleNavigationObservationTaskIfNeeded();
+
const ResourceError& error = m_documentLoader->mainDocumentError();
AXObjectCache::AXLoadingEvent loadingEvent;
Modified: trunk/Source/WebCore/page/Performance.cpp (279202 => 279203)
--- trunk/Source/WebCore/page/Performance.cpp 2021-06-24 01:58:27 UTC (rev 279202)
+++ trunk/Source/WebCore/page/Performance.cpp 2021-06-24 02:06:53 UTC (rev 279203)
@@ -198,10 +198,14 @@
return entries;
}
-void Performance::appendBufferedEntriesByType(const String& entryType, Vector<RefPtr<PerformanceEntry>>& entries) const
+void Performance::appendBufferedEntriesByType(const String& entryType, Vector<RefPtr<PerformanceEntry>>& entries, PerformanceObserver& observer) const
{
- if (m_navigationTiming && entryType == "navigation")
+ if (m_navigationTiming
+ && entryType == "navigation"
+ && !observer.hasNavigationTiming()) {
entries.append(m_navigationTiming);
+ observer.addedNavigationTiming();
+ }
if (entryType == "resource")
entries.appendVector(m_resourceTimingBuffer);
@@ -373,9 +377,11 @@
{
m_observers.add(&observer);
- if (m_navigationTiming && observer.typeFilter().contains(PerformanceEntry::Type::Navigation)) {
+ if (m_navigationTiming
+ && observer.typeFilter().contains(PerformanceEntry::Type::Navigation)
+ && !observer.hasNavigationTiming()) {
observer.queueEntry(*m_navigationTiming);
- scheduleTaskIfNeeded();
+ observer.addedNavigationTiming();
}
}
@@ -384,6 +390,12 @@
m_observers.remove(&observer);
}
+void Performance::scheduleNavigationObservationTaskIfNeeded()
+{
+ if (m_navigationTiming)
+ scheduleTaskIfNeeded();
+}
+
void Performance::queueEntry(PerformanceEntry& entry)
{
bool shouldScheduleTask = false;
Modified: trunk/Source/WebCore/page/Performance.h (279202 => 279203)
--- trunk/Source/WebCore/page/Performance.h 2021-06-24 01:58:27 UTC (rev 279202)
+++ trunk/Source/WebCore/page/Performance.h 2021-06-24 02:06:53 UTC (rev 279203)
@@ -84,7 +84,7 @@
Vector<RefPtr<PerformanceEntry>> getEntries() const;
Vector<RefPtr<PerformanceEntry>> getEntriesByType(const String& entryType) const;
Vector<RefPtr<PerformanceEntry>> getEntriesByName(const String& name, const String& entryType) const;
- void appendBufferedEntriesByType(const String& entryType, Vector<RefPtr<PerformanceEntry>>&) const;
+ void appendBufferedEntriesByType(const String& entryType, Vector<RefPtr<PerformanceEntry>>&, PerformanceObserver&) const;
void clearResourceTimings();
void setResourceTimingBufferSize(unsigned);
@@ -114,6 +114,8 @@
using RefCounted::ref;
using RefCounted::deref;
+ void scheduleNavigationObservationTaskIfNeeded();
+
private:
Performance(ScriptExecutionContext*, MonotonicTime timeOrigin);
Modified: trunk/Source/WebCore/page/PerformanceObserver.cpp (279202 => 279203)
--- trunk/Source/WebCore/page/PerformanceObserver.cpp 2021-06-24 01:58:27 UTC (rev 279202)
+++ trunk/Source/WebCore/page/PerformanceObserver.cpp 2021-06-24 02:06:53 UTC (rev 279203)
@@ -88,7 +88,7 @@
if (init.buffered) {
isBuffered = true;
auto oldSize = m_entriesToDeliver.size();
- m_performance->appendBufferedEntriesByType(*init.type, m_entriesToDeliver);
+ m_performance->appendBufferedEntriesByType(*init.type, m_entriesToDeliver, *this);
auto begin = m_entriesToDeliver.begin();
auto oldEnd = begin + oldSize;
auto end = m_entriesToDeliver.end();
Modified: trunk/Source/WebCore/page/PerformanceObserver.h (279202 => 279203)
--- trunk/Source/WebCore/page/PerformanceObserver.h 2021-06-24 01:58:27 UTC (rev 279202)
+++ trunk/Source/WebCore/page/PerformanceObserver.h 2021-06-24 02:06:53 UTC (rev 279203)
@@ -61,6 +61,9 @@
OptionSet<PerformanceEntry::Type> typeFilter() const { return m_typeFilter; }
+ bool hasNavigationTiming() const { return m_hasNavigationTiming; }
+ void addedNavigationTiming() { m_hasNavigationTiming = true; }
+
void queueEntry(PerformanceEntry&);
void deliver();
@@ -76,6 +79,7 @@
OptionSet<PerformanceEntry::Type> m_typeFilter;
bool m_registered { false };
bool m_isTypeObserver { false };
+ bool m_hasNavigationTiming { false };
};
} // namespace WebCore