<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[281901] branches/safari-612-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/281901">281901</a></dd>
<dt>Author</dt> <dd>repstein@apple.com</dd>
<dt>Date</dt> <dd>2021-09-01 18:05:18 -0700 (Wed, 01 Sep 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/281860">r281860</a>. rdar://problem/82651913

    PerformanceNavigationTiming should be instantiated before scripts run then updated when response finishes
    https://bugs.webkit.org/show_bug.cgi?id=229751

    Patch by Alex Christensen <achristensen@webkit.org> on 2021-09-01
    Reviewed by Chris Dumez.

    LayoutTests/imported/w3c:

    * web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event-expected.txt: Added.
    * web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event.html: Added.
    * web-platform-tests/navigation-timing/resources/respond_slowly.py: Added.
    (main):

    Source/WebCore:

    Test: imported/w3c/web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event.html

    I noticed some server timing tests were calling performance.getEntriesByType('navigation')[0] before the document loaded, and in WebKit
    it would return undefined and in Chrome and Firefox it would return a PerformanceNavigationTiming object.  The solution is to make the object
    available earlier.  But what about responseEnd and duration before the main resource is finished responding?  It turns out in Chrome and now
    WebKit they are both 0 until they are filled in.  I added a WPT test to verify this behavior.

    * loader/DocumentLoader.cpp:
    (WebCore::DocumentLoader::notifyFinished):
    (WebCore::DocumentLoader::commitData):
    * loader/ResourceTiming.h:
    (WebCore::ResourceTiming::networkLoadMetrics):
    * page/Performance.cpp:
    (WebCore::Performance::addNavigationTiming):
    (WebCore::Performance::navigationFinished):
    * page/Performance.h:
    * page/PerformanceNavigationTiming.cpp:
    (WebCore::PerformanceNavigationTiming::navigationFinished):
    * page/PerformanceNavigationTiming.h:
    * page/PerformanceResourceTiming.cpp:
    (WebCore::PerformanceResourceTiming::responseEnd const):
    * page/PerformanceResourceTiming.h:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281860 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari612branchLayoutTestsimportedw3cChangeLog">branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#branchessafari612branchSourceWebCoreChangeLog">branches/safari-612-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari612branchSourceWebCoreloaderDocumentLoadercpp">branches/safari-612-branch/Source/WebCore/loader/DocumentLoader.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebCoreloaderResourceTimingh">branches/safari-612-branch/Source/WebCore/loader/ResourceTiming.h</a></li>
<li><a href="#branchessafari612branchSourceWebCorepagePerformancecpp">branches/safari-612-branch/Source/WebCore/page/Performance.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebCorepagePerformanceh">branches/safari-612-branch/Source/WebCore/page/Performance.h</a></li>
<li><a href="#branchessafari612branchSourceWebCorepagePerformanceNavigationTimingcpp">branches/safari-612-branch/Source/WebCore/page/PerformanceNavigationTiming.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebCorepagePerformanceNavigationTimingh">branches/safari-612-branch/Source/WebCore/page/PerformanceNavigationTiming.h</a></li>
<li><a href="#branchessafari612branchSourceWebCorepagePerformanceResourceTimingcpp">branches/safari-612-branch/Source/WebCore/page/PerformanceResourceTiming.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebCorepagePerformanceResourceTimingh">branches/safari-612-branch/Source/WebCore/page/PerformanceResourceTiming.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari612branchLayoutTestsimportedw3cwebplatformtestsnavigationtimingnav2_test_response_end_and_duration_before_during_and_after_load_eventexpectedtxt">branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event-expected.txt</a></li>
<li><a href="#branchessafari612branchLayoutTestsimportedw3cwebplatformtestsnavigationtimingnav2_test_response_end_and_duration_before_during_and_after_load_eventhtml">branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event.html</a></li>
<li><a href="#branchessafari612branchLayoutTestsimportedw3cwebplatformtestsnavigationtimingresourcesrespond_slowlypy">branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/resources/respond_slowly.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari612branchLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog (281900 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog    2021-09-02 01:05:13 UTC (rev 281900)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog       2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -1,5 +1,61 @@
</span><span class="cx"> 2021-09-01  Russell Epstein  <repstein@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r281860. rdar://problem/82651913
+
+    PerformanceNavigationTiming should be instantiated before scripts run then updated when response finishes
+    https://bugs.webkit.org/show_bug.cgi?id=229751
+    
+    Patch by Alex Christensen <achristensen@webkit.org> on 2021-09-01
+    Reviewed by Chris Dumez.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event-expected.txt: Added.
+    * web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event.html: Added.
+    * web-platform-tests/navigation-timing/resources/respond_slowly.py: Added.
+    (main):
+    
+    Source/WebCore:
+    
+    Test: imported/w3c/web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event.html
+    
+    I noticed some server timing tests were calling performance.getEntriesByType('navigation')[0] before the document loaded, and in WebKit
+    it would return undefined and in Chrome and Firefox it would return a PerformanceNavigationTiming object.  The solution is to make the object
+    available earlier.  But what about responseEnd and duration before the main resource is finished responding?  It turns out in Chrome and now
+    WebKit they are both 0 until they are filled in.  I added a WPT test to verify this behavior.
+    
+    * loader/DocumentLoader.cpp:
+    (WebCore::DocumentLoader::notifyFinished):
+    (WebCore::DocumentLoader::commitData):
+    * loader/ResourceTiming.h:
+    (WebCore::ResourceTiming::networkLoadMetrics):
+    * page/Performance.cpp:
+    (WebCore::Performance::addNavigationTiming):
+    (WebCore::Performance::navigationFinished):
+    * page/Performance.h:
+    * page/PerformanceNavigationTiming.cpp:
+    (WebCore::PerformanceNavigationTiming::navigationFinished):
+    * page/PerformanceNavigationTiming.h:
+    * page/PerformanceResourceTiming.cpp:
+    (WebCore::PerformanceResourceTiming::responseEnd const):
+    * page/PerformanceResourceTiming.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281860 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-01  Alex Christensen  <achristensen@webkit.org>
+
+            PerformanceNavigationTiming should be instantiated before scripts run then updated when response finishes
+            https://bugs.webkit.org/show_bug.cgi?id=229751
+
+            Reviewed by Chris Dumez.
+
+            * web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event-expected.txt: Added.
+            * web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event.html: Added.
+            * web-platform-tests/navigation-timing/resources/respond_slowly.py: Added.
+            (main):
+
+2021-09-01  Russell Epstein  <repstein@apple.com>
+
</ins><span class="cx">         Cherry-pick r281662. rdar://problem/82651998
</span><span class="cx"> 
</span><span class="cx">     REGRESSION(r275754): Using MarkOnlyThis to make the preferred width dirty introduces unexpected state
</span></span></pre></div>
<a id="branchessafari612branchLayoutTestsimportedw3cwebplatformtestsnavigationtimingnav2_test_response_end_and_duration_before_during_and_after_load_eventexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event-expected.txt (0 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event-expected.txt                             (rev 0)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event-expected.txt        2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+
+PASS Check that performance.getEntriesByType('navigation')[0].responseEnd has reasonable values before and after the load has finished
+
</ins></span></pre></div>
<a id="branchessafari612branchLayoutTestsimportedw3cwebplatformtestsnavigationtimingnav2_test_response_end_and_duration_before_during_and_after_load_eventhtml"></a>
<div class="addfile"><h4>Added: branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event.html (0 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event.html                             (rev 0)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event.html        2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+<!DOCTYPE HTML>
+<html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<iframe src="resources/respond_slowly.py"></iframe>
+<body>
+<script>
+async_test(function(t) {
+  window.addEventListener('message', t.step_func_done(function(event) {
+    let originalResponseEnd = event.data[0];
+    let originalDuration = event.data[1];
+    let responseEndDuringLoadEvent = event.data[2];
+    let durationDuringLoadEvent = event.data[3];
+    let responseEndAfterLoadEvent = event.data[4];
+    let durationAfterLoadEvent = event.data[5];
+    assert_equals(originalResponseEnd, 0, "PerformanceNavigationTiming.responseEnd == 0 before load event");
+    assert_equals(originalDuration, 0, "PerformanceNavigationTiming.duration is 0 before load event");
+    assert_greater_than(responseEndDuringLoadEvent, 500, "PerformanceNavigationTiming.responseEnd is reasonable during load event");
+    assert_equals(durationDuringLoadEvent, 0, "PerformanceNavigationTiming.duration is 0 during load event");
+    assert_greater_than(responseEndAfterLoadEvent, 500, "PerformanceNavigationTiming.responseEnd is reasonable after load event");
+    assert_greater_than(durationAfterLoadEvent, 500, "PerformanceNavigationTiming.duration is reasonable after load event");
+  }));
+}, "Check that performance.getEntriesByType('navigation')[0].responseEnd has reasonable values before and after the load has finished");
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari612branchLayoutTestsimportedw3cwebplatformtestsnavigationtimingresourcesrespond_slowlypy"></a>
<div class="addfile"><h4>Added: branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/resources/respond_slowly.py (0 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/resources/respond_slowly.py                             (rev 0)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/navigation-timing/resources/respond_slowly.py        2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+import time
+
+
+def main(request, response):
+    head = b"""<script>
+    let navBeforeLoadFinished = performance.getEntriesByType('navigation')[0];
+    let originalResponseEnd = navBeforeLoadFinished.responseEnd;
+    let originalDuration = navBeforeLoadFinished.duration;
+    function checkResponseEnd() {
+        let navDuringLoadEvent = performance.getEntriesByType('navigation')[0];
+        let responseEndDuringLoadEvent = navDuringLoadEvent.responseEnd;
+        let durationDuringLoadEvent = navDuringLoadEvent.duration;
+        setTimeout(function() {
+            let navAfterLoadEvent = performance.getEntriesByType('navigation')[0];
+            parent.postMessage([
+                originalResponseEnd,
+                originalDuration,
+                responseEndDuringLoadEvent,
+                durationDuringLoadEvent,
+                navAfterLoadEvent.responseEnd,
+                navAfterLoadEvent.duration], '*');
+        }, 0);
+    }
+    </script><body onload='checkResponseEnd()'>"""
+    response.headers.set(b"Content-Length", str(len(head) + 10000))
+    response.headers.set(b"Content-Type", b"text/html")
+    response.write_status_headers()
+    response.writer.write_content(head)
+    for i in range(1000):
+        response.writer.write_content(b"1234567890")
+        time.sleep(0.001)
</ins></span></pre></div>
<a id="branchessafari612branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (281900 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/ChangeLog      2021-09-02 01:05:13 UTC (rev 281900)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog 2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -1,5 +1,79 @@
</span><span class="cx"> 2021-09-01  Russell Epstein  <repstein@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r281860. rdar://problem/82651913
+
+    PerformanceNavigationTiming should be instantiated before scripts run then updated when response finishes
+    https://bugs.webkit.org/show_bug.cgi?id=229751
+    
+    Patch by Alex Christensen <achristensen@webkit.org> on 2021-09-01
+    Reviewed by Chris Dumez.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event-expected.txt: Added.
+    * web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event.html: Added.
+    * web-platform-tests/navigation-timing/resources/respond_slowly.py: Added.
+    (main):
+    
+    Source/WebCore:
+    
+    Test: imported/w3c/web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event.html
+    
+    I noticed some server timing tests were calling performance.getEntriesByType('navigation')[0] before the document loaded, and in WebKit
+    it would return undefined and in Chrome and Firefox it would return a PerformanceNavigationTiming object.  The solution is to make the object
+    available earlier.  But what about responseEnd and duration before the main resource is finished responding?  It turns out in Chrome and now
+    WebKit they are both 0 until they are filled in.  I added a WPT test to verify this behavior.
+    
+    * loader/DocumentLoader.cpp:
+    (WebCore::DocumentLoader::notifyFinished):
+    (WebCore::DocumentLoader::commitData):
+    * loader/ResourceTiming.h:
+    (WebCore::ResourceTiming::networkLoadMetrics):
+    * page/Performance.cpp:
+    (WebCore::Performance::addNavigationTiming):
+    (WebCore::Performance::navigationFinished):
+    * page/Performance.h:
+    * page/PerformanceNavigationTiming.cpp:
+    (WebCore::PerformanceNavigationTiming::navigationFinished):
+    * page/PerformanceNavigationTiming.h:
+    * page/PerformanceResourceTiming.cpp:
+    (WebCore::PerformanceResourceTiming::responseEnd const):
+    * page/PerformanceResourceTiming.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281860 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-01  Alex Christensen  <achristensen@webkit.org>
+
+            PerformanceNavigationTiming should be instantiated before scripts run then updated when response finishes
+            https://bugs.webkit.org/show_bug.cgi?id=229751
+
+            Reviewed by Chris Dumez.
+
+            Test: imported/w3c/web-platform-tests/navigation-timing/nav2_test_response_end_and_duration_before_during_and_after_load_event.html
+
+            I noticed some server timing tests were calling performance.getEntriesByType('navigation')[0] before the document loaded, and in WebKit
+            it would return undefined and in Chrome and Firefox it would return a PerformanceNavigationTiming object.  The solution is to make the object
+            available earlier.  But what about responseEnd and duration before the main resource is finished responding?  It turns out in Chrome and now
+            WebKit they are both 0 until they are filled in.  I added a WPT test to verify this behavior.
+
+            * loader/DocumentLoader.cpp:
+            (WebCore::DocumentLoader::notifyFinished):
+            (WebCore::DocumentLoader::commitData):
+            * loader/ResourceTiming.h:
+            (WebCore::ResourceTiming::networkLoadMetrics):
+            * page/Performance.cpp:
+            (WebCore::Performance::addNavigationTiming):
+            (WebCore::Performance::navigationFinished):
+            * page/Performance.h:
+            * page/PerformanceNavigationTiming.cpp:
+            (WebCore::PerformanceNavigationTiming::navigationFinished):
+            * page/PerformanceNavigationTiming.h:
+            * page/PerformanceResourceTiming.cpp:
+            (WebCore::PerformanceResourceTiming::responseEnd const):
+            * page/PerformanceResourceTiming.h:
+
+2021-09-01  Russell Epstein  <repstein@apple.com>
+
</ins><span class="cx">         Cherry-pick r281848. rdar://problem/82652449
</span><span class="cx"> 
</span><span class="cx">     Regression(r272607) Removal of alert()/confirm() in third-party iframes breaks Salesforce
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCoreloaderDocumentLoadercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/loader/DocumentLoader.cpp (281900 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/loader/DocumentLoader.cpp      2021-09-02 01:05:13 UTC (rev 281900)
+++ branches/safari-612-branch/Source/WebCore/loader/DocumentLoader.cpp 2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -424,7 +424,7 @@
</span><span class="cx">     if (auto document = makeRefPtr(this->document())) {
</span><span class="cx">         if (auto domWindow = makeRefPtr(document->domWindow())) {
</span><span class="cx">             if (document->settings().performanceNavigationTimingAPIEnabled())
</span><del>-                domWindow->performance().addNavigationTiming(*this, *document, resource, timing(), metrics);
</del><ins>+                domWindow->performance().navigationFinished(metrics);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1318,9 +1318,15 @@
</span><span class="cx">         if (!isLoading())
</span><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        if (auto* window = document.domWindow())
</del><ins>+        if (auto* window = document.domWindow()) {
</ins><span class="cx">             window->prewarmLocalStorageIfNecessary();
</span><span class="cx"> 
</span><ins>+            if (document.settings().performanceNavigationTimingAPIEnabled() && m_mainResource) {
+                auto* metrics = m_response.deprecatedNetworkLoadMetricsOrNull();
+                window->performance().addNavigationTiming(*this, document, *m_mainResource, timing(), metrics ? *metrics : NetworkLoadMetrics { });
+            }
+        }
+
</ins><span class="cx">         bool userChosen;
</span><span class="cx">         String encoding;
</span><span class="cx">         if (overrideEncoding().isNull()) {
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCoreloaderResourceTimingh"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/loader/ResourceTiming.h (281900 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/loader/ResourceTiming.h        2021-09-02 01:05:13 UTC (rev 281900)
+++ branches/safari-612-branch/Source/WebCore/loader/ResourceTiming.h   2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx">     const String& initiator() const { return m_initiator; }
</span><span class="cx">     const ResourceLoadTiming& resourceLoadTiming() const { return m_resourceLoadTiming; }
</span><span class="cx">     const NetworkLoadMetrics& networkLoadMetrics() const { return m_networkLoadMetrics; }
</span><ins>+    NetworkLoadMetrics& networkLoadMetrics() { return m_networkLoadMetrics; }
</ins><span class="cx">     Vector<Ref<PerformanceServerTiming>> populateServerTiming() const;
</span><span class="cx">     ResourceTiming isolatedCopy() const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorepagePerformancecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/page/Performance.cpp (281900 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/page/Performance.cpp   2021-09-02 01:05:13 UTC (rev 281900)
+++ branches/safari-612-branch/Source/WebCore/page/Performance.cpp      2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -241,6 +241,16 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(document.settings().performanceNavigationTimingAPIEnabled());
</span><span class="cx">     m_navigationTiming = PerformanceNavigationTiming::create(m_timeOrigin, resource, timing, metrics, document.eventTiming(), document.securityOrigin(), documentLoader.triggeringAction().type());
</span><ins>+}
+
+void Performance::navigationFinished(const NetworkLoadMetrics& metrics)
+{
+    if (!m_navigationTiming) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+    m_navigationTiming->navigationFinished(metrics);
+
</ins><span class="cx">     queueEntry(*m_navigationTiming);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorepagePerformanceh"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/page/Performance.h (281900 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/page/Performance.h     2021-09-02 01:05:13 UTC (rev 281900)
+++ branches/safari-612-branch/Source/WebCore/page/Performance.h        2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -97,6 +97,7 @@
</span><span class="cx">     void clearMeasures(const String& measureName);
</span><span class="cx"> 
</span><span class="cx">     void addNavigationTiming(DocumentLoader&, Document&, CachedResource&, const DocumentLoadTiming&, const NetworkLoadMetrics&);
</span><ins>+    void navigationFinished(const NetworkLoadMetrics&);
</ins><span class="cx">     void addResourceTiming(ResourceTiming&&);
</span><span class="cx"> 
</span><span class="cx">     void reportFirstContentfulPaint();
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorepagePerformanceNavigationTimingcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/page/PerformanceNavigationTiming.cpp (281900 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/page/PerformanceNavigationTiming.cpp   2021-09-02 01:05:13 UTC (rev 281900)
+++ branches/safari-612-branch/Source/WebCore/page/PerformanceNavigationTiming.cpp      2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -141,4 +141,12 @@
</span><span class="cx">     return loadEventEnd() - startTime();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PerformanceNavigationTiming::navigationFinished(const NetworkLoadMetrics& metrics)
+{
+    m_documentLoadTiming.markEndTime();
+
+    ASSERT(!m_resourceTiming.networkLoadMetrics().responseEnd);
+    m_resourceTiming.networkLoadMetrics() = metrics;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorepagePerformanceNavigationTimingh"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/page/PerformanceNavigationTiming.h (281900 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/page/PerformanceNavigationTiming.h     2021-09-02 01:05:13 UTC (rev 281900)
+++ branches/safari-612-branch/Source/WebCore/page/PerformanceNavigationTiming.h        2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -70,6 +70,7 @@
</span><span class="cx"> 
</span><span class="cx">     DocumentEventTiming& documentEventTiming() { return m_documentEventTiming; }
</span><span class="cx">     DocumentLoadTiming& documentLoadTiming() { return m_documentLoadTiming; }
</span><ins>+    void navigationFinished(const NetworkLoadMetrics&);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     PerformanceNavigationTiming(MonotonicTime timeOrigin, CachedResource&, const DocumentLoadTiming&, const NetworkLoadMetrics&, const DocumentEventTiming&, const SecurityOrigin&, WebCore::NavigationType);
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorepagePerformanceResourceTimingcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/page/PerformanceResourceTiming.cpp (281900 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/page/PerformanceResourceTiming.cpp     2021-09-02 01:05:13 UTC (rev 281900)
+++ branches/safari-612-branch/Source/WebCore/page/PerformanceResourceTiming.cpp        2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -221,8 +221,11 @@
</span><span class="cx"> 
</span><span class="cx"> double PerformanceResourceTiming::responseEnd() const
</span><span class="cx"> {
</span><del>-    // responseEnd is a required property.
-    ASSERT(m_resourceTiming.networkLoadMetrics().isComplete() || m_resourceTiming.resourceLoadTiming().endTime());
</del><ins>+    // responseEnd is a required property, but PerformanceNavigationTiming
+    // can be queried before the document load is complete
+    ASSERT(m_resourceTiming.networkLoadMetrics().isComplete()
+        || m_resourceTiming.resourceLoadTiming().endTime()
+        || performanceEntryType() == Type::Navigation);
</ins><span class="cx"> 
</span><span class="cx">     if (m_resourceTiming.networkLoadMetrics().isComplete()) {
</span><span class="cx">         if (m_resourceTiming.networkLoadMetrics().responseEnd)
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorepagePerformanceResourceTimingh"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/page/PerformanceResourceTiming.h (281900 => 281901)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/page/PerformanceResourceTiming.h       2021-09-02 01:05:13 UTC (rev 281900)
+++ branches/safari-612-branch/Source/WebCore/page/PerformanceResourceTiming.h  2021-09-02 01:05:18 UTC (rev 281901)
</span><span class="lines">@@ -75,7 +75,7 @@
</span><span class="cx">     ~PerformanceResourceTiming();
</span><span class="cx"> 
</span><span class="cx">     MonotonicTime m_timeOrigin;
</span><del>-    const ResourceTiming m_resourceTiming;
</del><ins>+    ResourceTiming m_resourceTiming;
</ins><span class="cx">     Vector<Ref<PerformanceServerTiming>> m_serverTiming;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>