Title: [280931] trunk
Revision
280931
Author
[email protected]
Date
2021-08-11 15:05:02 -0700 (Wed, 11 Aug 2021)

Log Message

REGRESSION (r278392) performance.measure should never throw an InvalidAccessError for fetchStart
https://bugs.webkit.org/show_bug.cgi?id=229008
<rdar://79960877>

Patch by Alex Christensen <[email protected]> on 2021-08-11
Reviewed by Chris Dumez.

Source/WebCore:

Test: http/tests/performance/performance-measure-fetch-start.html

PerformanceTiming::fetchStart is returning 0 when we get a main resource from the cache sometimes.
This is causing PerformanceUserTiming::convertMarkToTimestamp to throw an error, which it should.
Like PerformanceResourceTiming::fetchStart we need to fall back to ResourceLoadTiming::startTime
if the NetworkLoadMetrics doesn't have any useful data for us.

* page/PerformanceTiming.cpp:
(WebCore::PerformanceTiming::fetchStart const):

LayoutTests:

* http/tests/performance/performance-measure-fetch-start-expected.txt: Added.
* http/tests/performance/performance-measure-fetch-start.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (280930 => 280931)


--- trunk/LayoutTests/ChangeLog	2021-08-11 20:39:42 UTC (rev 280930)
+++ trunk/LayoutTests/ChangeLog	2021-08-11 22:05:02 UTC (rev 280931)
@@ -1,3 +1,14 @@
+2021-08-11  Alex Christensen  <[email protected]>
+
+        REGRESSION (r278392) performance.measure should never throw an InvalidAccessError for fetchStart
+        https://bugs.webkit.org/show_bug.cgi?id=229008
+        <rdar://79960877>
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/performance/performance-measure-fetch-start-expected.txt: Added.
+        * http/tests/performance/performance-measure-fetch-start.html: Added.
+
 2021-08-11  Dana Estra  <[email protected]>
 
         Start smooth keyboard scrolling animation when pageUp or pageDown key is pressed.

Added: trunk/LayoutTests/http/tests/performance/performance-measure-fetch-start-expected.txt (0 => 280931)


--- trunk/LayoutTests/http/tests/performance/performance-measure-fetch-start-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/performance/performance-measure-fetch-start-expected.txt	2021-08-11 22:05:02 UTC (rev 280931)
@@ -0,0 +1 @@
+PASS - performance.measure did not throw

Added: trunk/LayoutTests/http/tests/performance/performance-measure-fetch-start.html (0 => 280931)


--- trunk/LayoutTests/http/tests/performance/performance-measure-fetch-start.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/performance/performance-measure-fetch-start.html	2021-08-11 22:05:02 UTC (rev 280931)
@@ -0,0 +1,25 @@
+<script>
+    if (window.testRunner) {
+        testRunner.waitUntilDone();
+        testRunner.dumpAsText();
+    }
+    
+    window.addEventListener("message", (event) => {
+        document.write(event.data);
+        if (window.testRunner) { testRunner.notifyDone() }
+    }, false);
+    
+    function addIframe() {
+        var iframe = document.createElement('iframe');
+        const js = ''
+        + 'try{'
+        + '    performance.measure("fetchStart", "fetchStart", "fetchStart");'
+        + '    window.parent.postMessage("PASS - performance.measure did not throw", "*")'
+        + '} catch(e) {'
+        + '    window.parent.postMessage("FAIL - performance.measure did throw", "*")'
+        + '}';
+        iframe.src = '' + encodeURI('<script>' + js + '</scri' + 'pt>');
+        document.body.appendChild(iframe);
+    }
+</script>
+<body _onload_='addIframe()'/>

Modified: trunk/Source/WebCore/ChangeLog (280930 => 280931)


--- trunk/Source/WebCore/ChangeLog	2021-08-11 20:39:42 UTC (rev 280930)
+++ trunk/Source/WebCore/ChangeLog	2021-08-11 22:05:02 UTC (rev 280931)
@@ -1,3 +1,21 @@
+2021-08-11  Alex Christensen  <[email protected]>
+
+        REGRESSION (r278392) performance.measure should never throw an InvalidAccessError for fetchStart
+        https://bugs.webkit.org/show_bug.cgi?id=229008
+        <rdar://79960877>
+
+        Reviewed by Chris Dumez.
+
+        Test: http/tests/performance/performance-measure-fetch-start.html
+
+        PerformanceTiming::fetchStart is returning 0 when we get a main resource from the cache sometimes.
+        This is causing PerformanceUserTiming::convertMarkToTimestamp to throw an error, which it should.
+        Like PerformanceResourceTiming::fetchStart we need to fall back to ResourceLoadTiming::startTime
+        if the NetworkLoadMetrics doesn't have any useful data for us.
+
+        * page/PerformanceTiming.cpp:
+        (WebCore::PerformanceTiming::fetchStart const):
+
 2021-08-11  John Wilander  <[email protected]>
 
         PCM: Flip WebCore's FraudPreventionEnabled to true if HAVE(RSA_BSSA) to match the experimental setting

Modified: trunk/Source/WebCore/page/PerformanceTiming.cpp (280930 => 280931)


--- trunk/Source/WebCore/page/PerformanceTiming.cpp	2021-08-11 20:39:42 UTC (rev 280930)
+++ trunk/Source/WebCore/page/PerformanceTiming.cpp	2021-08-11 22:05:02 UTC (rev 280931)
@@ -137,10 +137,16 @@
         return m_fetchStart;
 
     auto* metrics = networkLoadMetrics();
-    if (!metrics)
-        return 0;
+    if (metrics)
+        m_fetchStart = monotonicTimeToIntegerMilliseconds(metrics->fetchStart);
 
-    m_fetchStart = monotonicTimeToIntegerMilliseconds(metrics->fetchStart);
+    if (!m_fetchStart) {
+        if (auto* timing = documentLoadTiming())
+            m_fetchStart = monotonicTimeToIntegerMilliseconds(timing->startTime());
+    }
+
+    // Like PerformanceResourceTiming::fetchStart, fetchStart is a required property
+    ASSERT(m_fetchStart);
     return m_fetchStart;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to