Title: [280971] branches/safari-612.1.27.0-branch
Revision
280971
Author
[email protected]
Date
2021-08-12 09:26:56 -0700 (Thu, 12 Aug 2021)

Log Message

Cherry-pick r280931. rdar://problem/81852494

    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.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280931 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-612.1.27.0-branch/LayoutTests/ChangeLog (280970 => 280971)


--- branches/safari-612.1.27.0-branch/LayoutTests/ChangeLog	2021-08-12 16:20:56 UTC (rev 280970)
+++ branches/safari-612.1.27.0-branch/LayoutTests/ChangeLog	2021-08-12 16:26:56 UTC (rev 280971)
@@ -1,3 +1,44 @@
+2021-08-12  Alan Coon  <[email protected]>
+
+        Cherry-pick r280931. rdar://problem/81852494
+
+    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.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280931 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-10  Russell Epstein  <[email protected]>
 
         Cherry-pick r280826. rdar://problem/81749833

Added: branches/safari-612.1.27.0-branch/LayoutTests/http/tests/performance/performance-measure-fetch-start-expected.txt (0 => 280971)


--- branches/safari-612.1.27.0-branch/LayoutTests/http/tests/performance/performance-measure-fetch-start-expected.txt	                        (rev 0)
+++ branches/safari-612.1.27.0-branch/LayoutTests/http/tests/performance/performance-measure-fetch-start-expected.txt	2021-08-12 16:26:56 UTC (rev 280971)
@@ -0,0 +1 @@
+PASS - performance.measure did not throw

Added: branches/safari-612.1.27.0-branch/LayoutTests/http/tests/performance/performance-measure-fetch-start.html (0 => 280971)


--- branches/safari-612.1.27.0-branch/LayoutTests/http/tests/performance/performance-measure-fetch-start.html	                        (rev 0)
+++ branches/safari-612.1.27.0-branch/LayoutTests/http/tests/performance/performance-measure-fetch-start.html	2021-08-12 16:26:56 UTC (rev 280971)
@@ -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: branches/safari-612.1.27.0-branch/Source/WebCore/ChangeLog (280970 => 280971)


--- branches/safari-612.1.27.0-branch/Source/WebCore/ChangeLog	2021-08-12 16:20:56 UTC (rev 280970)
+++ branches/safari-612.1.27.0-branch/Source/WebCore/ChangeLog	2021-08-12 16:26:56 UTC (rev 280971)
@@ -1,3 +1,51 @@
+2021-08-12  Alan Coon  <[email protected]>
+
+        Cherry-pick r280931. rdar://problem/81852494
+
+    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.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280931 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-10  Russell Epstein  <[email protected]>
 
         Cherry-pick r280826. rdar://problem/81749833

Modified: branches/safari-612.1.27.0-branch/Source/WebCore/page/PerformanceTiming.cpp (280970 => 280971)


--- branches/safari-612.1.27.0-branch/Source/WebCore/page/PerformanceTiming.cpp	2021-08-12 16:20:56 UTC (rev 280970)
+++ branches/safari-612.1.27.0-branch/Source/WebCore/page/PerformanceTiming.cpp	2021-08-12 16:26:56 UTC (rev 280971)
@@ -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