haikuwebkit/Source/WebCore/page/PerformanceNavigationTiming...

145 lines
5.3 KiB
C++
Raw Permalink Normal View History

Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
/*
* Copyright (C) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "config.h"
#include "PerformanceNavigationTiming.h"
#include "CachedResource.h"
#include "ResourceTiming.h"
namespace WebCore {
static PerformanceNavigationTiming::NavigationType toPerformanceNavigationTimingNavigationType(NavigationType navigationType)
{
switch (navigationType) {
case NavigationType::BackForward:
return PerformanceNavigationTiming::NavigationType::Back_forward;
case NavigationType::Reload:
return PerformanceNavigationTiming::NavigationType::Reload;
case NavigationType::LinkClicked:
case NavigationType::FormSubmitted:
case NavigationType::FormResubmitted:
case NavigationType::Other:
return PerformanceNavigationTiming::NavigationType::Navigate;
}
ASSERT_NOT_REACHED();
return PerformanceNavigationTiming::NavigationType::Navigate;
}
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
PerformanceNavigationTiming::PerformanceNavigationTiming(MonotonicTime timeOrigin, CachedResource& resource, const DocumentLoadTiming& documentLoadTiming, const NetworkLoadMetrics& metrics, const DocumentEventTiming& documentEventTiming, const SecurityOrigin& origin, WebCore::NavigationType navigationType)
: PerformanceResourceTiming(timeOrigin, ResourceTiming::fromLoad(resource, resource.response().url(), "navigation"_s, documentLoadTiming, metrics, origin))
, m_documentEventTiming(documentEventTiming)
, m_documentLoadTiming(documentLoadTiming)
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
, m_navigationType(toPerformanceNavigationTimingNavigationType(navigationType)) { }
PerformanceNavigationTiming::~PerformanceNavigationTiming() = default;
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
double PerformanceNavigationTiming::millisecondsSinceOrigin(MonotonicTime time) const
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
{
if (!time)
return 0;
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
return Performance::reduceTimeResolution(time - m_timeOrigin).milliseconds();
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
}
bool PerformanceNavigationTiming::sameOriginCheckFails() const
{
// https://www.w3.org/TR/navigation-timing-2/#dfn-same-origin-check
Move Timing-Allow-Origin checks to the network process https://bugs.webkit.org/show_bug.cgi?id=226678 <rdar://problem/45227788> Reviewed by Chris Dumez. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/CodingConventions.md: Added. * web-platform-tests/resource-timing/SO-XO-SO-redirect-chain-tao.https-expected.txt: Added. * web-platform-tests/resource-timing/SO-XO-SO-redirect-chain-tao.https.html: Added. * web-platform-tests/resource-timing/SyntheticResponse.py: (main): * web-platform-tests/resource-timing/TAO-match-expected.txt: Added. * web-platform-tests/resource-timing/TAO-match.html: Added. * web-platform-tests/resource-timing/TAO-null-opaque-origin-expected.txt: Added. * web-platform-tests/resource-timing/TAO-null-opaque-origin.html: Added. * web-platform-tests/resource-timing/TAO-port-mismatch-means-crossorigin-expected.txt: Added. * web-platform-tests/resource-timing/TAO-port-mismatch-means-crossorigin.html: Added. * web-platform-tests/resource-timing/__init__.py: Added. * web-platform-tests/resource-timing/buffer-full-add-after-full-event-expected.txt: * web-platform-tests/resource-timing/buffer-full-add-after-full-event.html: * web-platform-tests/resource-timing/buffer-full-add-entries-during-callback-expected.txt: * web-platform-tests/resource-timing/buffer-full-add-entries-during-callback-that-drop.html: * web-platform-tests/resource-timing/buffer-full-add-entries-during-callback.html: * web-platform-tests/resource-timing/buffer-full-add-then-clear-expected.txt: * web-platform-tests/resource-timing/buffer-full-add-then-clear.html: * web-platform-tests/resource-timing/buffer-full-decrease-buffer-during-callback.html: * web-platform-tests/resource-timing/buffer-full-increase-buffer-during-callback-expected.txt: * web-platform-tests/resource-timing/buffer-full-increase-buffer-during-callback.html: * web-platform-tests/resource-timing/buffer-full-inspect-buffer-during-callback-expected.txt: * web-platform-tests/resource-timing/buffer-full-inspect-buffer-during-callback.html: * web-platform-tests/resource-timing/buffer-full-set-to-current-buffer-expected.txt: * web-platform-tests/resource-timing/buffer-full-set-to-current-buffer.html: * web-platform-tests/resource-timing/buffer-full-store-and-clear-during-callback-expected.txt: * web-platform-tests/resource-timing/buffer-full-store-and-clear-during-callback.html: * web-platform-tests/resource-timing/buffer-full-then-increased-expected.txt: * web-platform-tests/resource-timing/buffer-full-then-increased.html: * web-platform-tests/resource-timing/buffer-full-when-populate-entries-expected.txt: * web-platform-tests/resource-timing/buffer-full-when-populate-entries.html: All these buffer-full tests start failing when I update them. That is an unrelated bug. Firefox has the same bug, and we had the same bug before and after this change. * web-platform-tests/resource-timing/connection-reuse-expected.txt: Added. * web-platform-tests/resource-timing/connection-reuse.html: Added. * web-platform-tests/resource-timing/connection-reuse.https-expected.txt: Added. * web-platform-tests/resource-timing/connection-reuse.https.html: Added. * web-platform-tests/resource-timing/cross-origin-start-end-time-with-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-start-end-time-with-redirects.html: Added. * web-platform-tests/resource-timing/cross-origin-status-codes.html: * web-platform-tests/resource-timing/document-domain-no-impact-opener-expected.txt: Added. * web-platform-tests/resource-timing/document-domain-no-impact-opener.html: Added. * web-platform-tests/resource-timing/entry-attributes-expected.txt: Added. * web-platform-tests/resource-timing/entry-attributes.html: Added. * web-platform-tests/resource-timing/fetch-cross-origin-redirect.https-expected.txt: Added. * web-platform-tests/resource-timing/fetch-cross-origin-redirect.https.html: Added. * web-platform-tests/resource-timing/font-timestamps-expected.txt: Added. * web-platform-tests/resource-timing/font-timestamps.html: Added. * web-platform-tests/resource-timing/iframe-failed-commit-expected.txt: Added. * web-platform-tests/resource-timing/iframe-failed-commit.html: Added. * web-platform-tests/resource-timing/initiator-type-for-script-expected.txt: Added. * web-platform-tests/resource-timing/initiator-type-for-script.html: Added. * web-platform-tests/resource-timing/nextHopProtocol-is-tao-protected.https-expected.txt: Added. * web-platform-tests/resource-timing/nextHopProtocol-is-tao-protected.https.html: Added. * web-platform-tests/resource-timing/object-not-found-after-TAO-cross-origin-redirect-expected.txt: Added. * web-platform-tests/resource-timing/object-not-found-after-TAO-cross-origin-redirect.html: Added. * web-platform-tests/resource-timing/object-not-found-after-cross-origin-redirect-expected.txt: Added. * web-platform-tests/resource-timing/object-not-found-after-cross-origin-redirect.html: Added. * web-platform-tests/resource-timing/redirects-expected.txt: Added. * web-platform-tests/resource-timing/redirects.html: Added. * web-platform-tests/resource-timing/resource-ignore-data-url-expected.txt: Added. * web-platform-tests/resource-timing/resource-ignore-data-url.html: Added. * web-platform-tests/resource-timing/resource_TAO_cross_origin_redirect_chain-expected.txt: This apparent regression is actually a progression. When this test is run from our test infrastructure, Chrome and Firefox fail the same tests that you see now failing here, indicating that something is wrong with our test infrastructure. When run on wpt.live, all browsers pass this test after this change. * web-platform-tests/resource-timing/resource_cached.html: Added. * web-platform-tests/resource-timing/resource_initiator_types.html: * web-platform-tests/resource-timing/resource_nested_dedicated_worker.worker.js: (async_test): (async_test.async const): Deleted. * web-platform-tests/resource-timing/resource_timing_content_length-expected.txt: Added. * web-platform-tests/resource-timing/resource_timing_content_length.html: Added. * web-platform-tests/resource-timing/resources/200_empty.asis: Added. * web-platform-tests/resource-timing/resources/TAOResponse.py: (main): * web-platform-tests/resource-timing/resources/all_resource_types.html: Added. * web-platform-tests/resource-timing/resources/buffer-full-utilities.js: (const.waitForNextTask): (const.forceBufferFullEvent.async clearBufferAndSetSize): (const.forceBufferFullEvent): (const.fillUpTheBufferWithTwoResources.async clearBufferAndSetSize): (async const.fillUpTheBufferWithSingleResource.async clearBufferAndSetSize): (async const): (let.appendScript): Deleted. (let.waitForNextTask): Deleted. (let.waitUntilConditionIsMet.cond.return.new.Promise.resolve.let.checkCondition): Deleted. (let.waitForEventToFire.return.new.Promise): Deleted. (let.waitForEventToFire): Deleted. (let.fillUpTheBufferWithTwoResources.async src): Deleted. * web-platform-tests/resource-timing/resources/cacheable-and-validated.py: Added. (main): * web-platform-tests/resource-timing/resources/connection-reuse-test.js: Added. (attribute_test.async client): (attribute_test): * web-platform-tests/resource-timing/resources/csp-default-none.html: Added. * web-platform-tests/resource-timing/resources/csp-default-none.html.headers: Added. * web-platform-tests/resource-timing/resources/document-domain-no-impact.html: Added. * web-platform-tests/resource-timing/resources/document-refreshed.html: Added. * web-platform-tests/resource-timing/resources/document-that-refreshes.html: Added. * web-platform-tests/resource-timing/resources/embed-refresh.html: Added. * web-platform-tests/resource-timing/resources/green-frame.html: Added. * web-platform-tests/resource-timing/resources/green.html: Added. * web-platform-tests/resource-timing/resources/green.html.headers: Added. * web-platform-tests/resource-timing/resources/gzip_xml.py: * web-platform-tests/resource-timing/resources/iframe-refresh.html: Added. * web-platform-tests/resource-timing/resources/iframe-reload-TAO.sub.html: * web-platform-tests/resource-timing/resources/multi_redirect.py: (main): * web-platform-tests/resource-timing/resources/object-refresh.html: Added. * web-platform-tests/resource-timing/resources/redirect-cors.py: Added. (main): * web-platform-tests/resource-timing/resources/resource-timing-content-length.py: Added. (main): * web-platform-tests/resource-timing/resources/resource_timing_test0.xml: * web-platform-tests/resource-timing/resources/sizes-helper.js: Added. (const.checkSizeFields): * web-platform-tests/resource-timing/resources/status-code.py: (main): * web-platform-tests/resource-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/resource-timing/resources/webperftestharnessextension.js: (test_method_exists): * web-platform-tests/resource-timing/same-origin-from-cross-origin-redirect-expected.txt: Added. * web-platform-tests/resource-timing/same-origin-from-cross-origin-redirect.html: Added. * web-platform-tests/resource-timing/sizes-cache.any.js: Added. (const.accumulateEntries): (const.checkResourceSizes.list.let.entry.of.entries.else): (promise_test): * web-platform-tests/resource-timing/sizes-redirect-img-expected.txt: Added. * web-platform-tests/resource-timing/sizes-redirect-img.html: Added. * web-platform-tests/resource-timing/sizes-redirect.any.js: Added. (const.accumulateEntry): (const.checkResourceSizes): (const.redirectUrl): (promise_test): * web-platform-tests/resource-timing/status-codes-create-entry.html: * web-platform-tests/resource-timing/test_resource_timing-expected.txt: * web-platform-tests/resource-timing/test_resource_timing.https-expected.txt: * web-platform-tests/resource-timing/workerStart-tao-protected.https.html: Source/WebCore: We tried hard to do it in the web process by keeping track of whether the last redirect was cross-origin and checking the final response and original security origin. We got many tests to pass, but to get the rest and be correct, we need to check the Timing-Allow-Origin header field of each redirect against the original security origin. Tests: imported/w3c/web-platform-tests/resource-timing/SO-XO-SO-redirect-chain-tao.https.html imported/w3c/web-platform-tests/resource-timing/TAO-match.html imported/w3c/web-platform-tests/resource-timing/TAO-null-opaque-origin.html imported/w3c/web-platform-tests/resource-timing/TAO-port-mismatch-means-crossorigin.html imported/w3c/web-platform-tests/resource-timing/connection-reuse.html imported/w3c/web-platform-tests/resource-timing/connection-reuse.https.html imported/w3c/web-platform-tests/resource-timing/cross-origin-start-end-time-with-redirects.html imported/w3c/web-platform-tests/resource-timing/document-domain-no-impact-opener.html imported/w3c/web-platform-tests/resource-timing/entry-attributes.html imported/w3c/web-platform-tests/resource-timing/fetch-cross-origin-redirect.https.html imported/w3c/web-platform-tests/resource-timing/font-timestamps.html imported/w3c/web-platform-tests/resource-timing/iframe-failed-commit.html imported/w3c/web-platform-tests/resource-timing/initiator-type-for-script.html imported/w3c/web-platform-tests/resource-timing/nextHopProtocol-is-tao-protected.https.html imported/w3c/web-platform-tests/resource-timing/object-not-found-after-TAO-cross-origin-redirect.html imported/w3c/web-platform-tests/resource-timing/object-not-found-after-cross-origin-redirect.html imported/w3c/web-platform-tests/resource-timing/redirects.html imported/w3c/web-platform-tests/resource-timing/resource-ignore-data-url.html imported/w3c/web-platform-tests/resource-timing/resource_cached.html imported/w3c/web-platform-tests/resource-timing/resource_timing_content_length.html imported/w3c/web-platform-tests/resource-timing/same-origin-from-cross-origin-redirect.html imported/w3c/web-platform-tests/resource-timing/sizes-redirect-img.html * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::start): Get a SecurityOrigin for our WebKitLegacy ResourceHandle use like we do in WebLoaderStrategy::scheduleLoadFromNetworkProcess * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::initServerTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::passesTimingAllowCheck): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::networkLoadMetrics const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::allowTimingDetails const): Deleted. (): Deleted. * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceResourceTiming.cpp: (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::transferSize const): (WebCore::PerformanceResourceTiming::encodedBodySize const): (WebCore::PerformanceResourceTiming::decodedBodySize const): * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::BlobResourceHandle): * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::ResourceHandle): (WebCore::ResourceHandle::create): (WebCore::ResourceHandle::loadResourceSynchronously): (WebCore::ResourceHandle::isCrossOriginWithoutTAO const): (WebCore::ResourceHandle::markAsCrossOriginWithoutTAO): (WebCore::ResourceHandle::sourceOrigin const): (WebCore::ResourceHandle::hasCrossOriginRedirect const): Deleted. (WebCore::ResourceHandle::setHasCrossOriginRedirect): Deleted. * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: (WebCore::ResourceHandleInternal::ResourceHandleInternal): * platform/network/TimingAllowOrigin.cpp: Added. (WebCore::passesTimingAllowOriginCheck): * platform/network/TimingAllowOrigin.h: Added. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::platformLoadResourceSynchronously): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): Source/WebKit: * NetworkProcess/NetworkLoadParameters.h: * NetworkProcess/NetworkResourceLoadParameters.h: * NetworkProcess/NetworkResourceLoader.cpp: (WebKit::sendReplyToSynchronousRequest): Pass complete metrics with sync xhr responses. Many of the tests use sync xhr. (WebKit::NetworkResourceLoader::didFinishLoading): (WebKit::NetworkResourceLoader::didFailLoading): (WebKit::NetworkResourceLoader::didRetrieveCacheEntry): * NetworkProcess/cocoa/NetworkDataTaskCocoa.h: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa): (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: * WebCoreSupport/WebResourceLoadScheduler.cpp: (WebResourceLoadScheduler::loadResourceSynchronously): LayoutTests: * TestExpectations: Canonical link: https://commits.webkit.org/238700@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278738 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-10 23:29:57 +00:00
return m_resourceTiming.networkLoadMetrics().hasCrossOriginRedirect
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
|| !m_documentLoadTiming.hasSameOriginAsPreviousDocument();
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
}
double PerformanceNavigationTiming::unloadEventStart() const
{
if (sameOriginCheckFails())
return 0.0;
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
return millisecondsSinceOrigin(m_documentLoadTiming.unloadEventStart());
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
}
double PerformanceNavigationTiming::unloadEventEnd() const
{
if (sameOriginCheckFails())
return 0.0;
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
return millisecondsSinceOrigin(m_documentLoadTiming.unloadEventEnd());
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
}
double PerformanceNavigationTiming::domInteractive() const
{
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
return millisecondsSinceOrigin(m_documentEventTiming.domInteractive);
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
}
double PerformanceNavigationTiming::domContentLoadedEventStart() const
{
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
return millisecondsSinceOrigin(m_documentEventTiming.domContentLoadedEventStart);
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
}
double PerformanceNavigationTiming::domContentLoadedEventEnd() const
{
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
return millisecondsSinceOrigin(m_documentEventTiming.domContentLoadedEventEnd);
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
}
double PerformanceNavigationTiming::domComplete() const
{
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
return millisecondsSinceOrigin(m_documentEventTiming.domComplete);
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
}
double PerformanceNavigationTiming::loadEventStart() const
{
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
return millisecondsSinceOrigin(m_documentLoadTiming.loadEventStart());
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
}
double PerformanceNavigationTiming::loadEventEnd() const
{
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
return millisecondsSinceOrigin(m_documentLoadTiming.loadEventEnd());
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
}
PerformanceNavigationTiming::NavigationType PerformanceNavigationTiming::type() const
{
return m_navigationType;
}
unsigned short PerformanceNavigationTiming::redirectCount() const
{
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
if (m_resourceTiming.networkLoadMetrics().hasCrossOriginRedirect)
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
return 0;
Fix WPT test resource-timing/cross-origin-redirects.html https://bugs.webkit.org/show_bug.cgi?id=190523 <rdar://45227788> Reviewed by Brady Eidson. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: Sometimes, with our use of Performance::reduceTimeResolution, the event times are equal to each other. Allow this. * web-platform-tests/resource-timing/cross-origin-redirects-expected.txt: Added. * web-platform-tests/resource-timing/cross-origin-redirects.html: Added. * web-platform-tests/resource-timing/resources/entry-invariants.js: Added. (const.assert_all_equal_): (const.assert_ordered_): (const.assert_zeroed_): (const.assert_not_negative_): (const.assert_positive_): (const.attribute_test_internal): (async const): (const.attribute_test_with_validator): * web-platform-tests/resource-timing/resources/resource-loaders.js: Added. (const.load.font.path.return.document.fonts.ready.then): (const.load.stylesheet.async path): (const.load.iframe.async path): (const.load.script.async path): (const.load.xhr_sync.async path): Source/WebCore: Test: imported/w3c/web-platform-tests/resource-timing/cross-origin-redirects.html This test took more to fix than I thought it would. We used to collect our timing data from various sources into various structures, mostly based on Google's work from 2010 with a few things tacked on to it. The timing specifications have changed considerably in the last 11 years, and so should the shape of the structures we put the data into. We used to have a LoadTiming structure in various places that claimed to contain the redirect times, but markRedirectStart and markRedirectEnd were never called. Instead we tried to collect this data from the SubResourceLoader and DocumentLoader reporting redirects in the web process. This wasn't great. Redirect timing is best collected in the network process by the framework doing the redirecting, and now we have the NSURLSessionTaskMetrics API to get the data we need. I've made NetworkLoadMetrics the structure that contains all the network load metrics from the network process. DocumentEventTiming is owned in the web process by the Document, and it contains the load event timing data. ResourceLoadTiming is owned by the ResourceLoader, and it contains the fetch start and end times including the parts of the fetch algorithm that happen in the web process. DocumentLoadTiming inherits from it and is owned by the DocumentLoader, which reflects the fact that PerformanceNavigationTiming inherits from PerformanceResourceTiming in the specs. With these structures in place, we now have the infrastructure to collect timing data and expose it correctly. Another thing that has changed is that these structures consistently store the timing data in the MonotonicTime type, which is the number of seconds since the machine restarted. NetworkLoadMetrics used to confusingly store fetch start time and then other network times as deltas from it, and we would pretend that fetch start time was the same as the fetch start time in the web process and calculate everything from the deltas. This is an unfortunate consequence of my younger self not realizing that the double values from NSURLConnection._timingData are values to be put into [NSDate initWithTimeIntervalSinceReferenceDate] then pulled out with timeIntervalSince1970 to get WallTime. I was confused because they weren't WallTime or MonotonicTime, so I only dealt with them as deltas from each other. Consistently using MonotonicTime makes all this code much more straightforward. I also use std::numeric_limits<uint64_t>::max() instead of std::numeric_limits<uint32_t>::max() as a sentinel value for requestHeaderBytesSent and responseHeaderBytesReceived to make everything more sane. I'm not too worried about the metrics of downloads of exactly 4GB, but they should also be fixed. A consequence of collecting the redirect times in the network process is that we have to move the SecurityOrigin::canRequest checks to see if the redirects are same-origin to ResourceHandle and NetworkDataTask. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::setReadyState): (WebCore::Document::finishedParsing): (WebCore::Document::monotonicTimestamp const): * dom/Document.h: (WebCore::Document::eventTiming const): (WebCore::Document::timing const): Deleted. * dom/DocumentEventTiming.h: Copied from Source/WebCore/dom/DocumentTiming.h. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForMetrics): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentLoadTiming.h: Renamed from Source/WebCore/loader/LoadTiming.h. (WebCore::DocumentLoadTiming::timeOrigin const): (WebCore::DocumentLoadTiming::markUnloadEventStart): (WebCore::DocumentLoadTiming::markUnloadEventEnd): (WebCore::DocumentLoadTiming::markLoadEventStart): (WebCore::DocumentLoadTiming::markLoadEventEnd): (WebCore::DocumentLoadTiming::setHasSameOriginAsPreviousDocument): (WebCore::DocumentLoadTiming::unloadEventStart const): (WebCore::DocumentLoadTiming::unloadEventEnd const): (WebCore::DocumentLoadTiming::loadEventStart const): (WebCore::DocumentLoadTiming::loadEventEnd const): (WebCore::DocumentLoadTiming::hasSameOriginAsPreviousDocument const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::willSendRequest): (WebCore::DocumentLoader::dataReceived): (WebCore::DocumentLoader::startLoadingMainResource): * loader/DocumentLoader.h: (WebCore::DocumentLoader::timing const): (WebCore::DocumentLoader::timing): (WebCore::DocumentLoader::resetTiming): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::dispatchUnloadEvents): * loader/LoadTiming.cpp: Removed. * loader/ResourceLoadTiming.h: Renamed from Source/WebCore/dom/DocumentTiming.h. (WebCore::ResourceLoadTiming::markStartTime): (WebCore::ResourceLoadTiming::markEndTime): (WebCore::ResourceLoadTiming::startTime const): (WebCore::ResourceLoadTiming::endTime const): (WebCore::ResourceLoadTiming::isolatedCopy const): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * loader/ResourceLoader.h: (WebCore::ResourceLoader::loadTiming): * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy const): (WebCore::ResourceTiming::fromCache): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::resourceLoadTiming const): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::loadTiming const): Deleted. * loader/ResourceTimingInformation.cpp: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didFinishLoading): * loader/cache/CachedResource.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::performance const): * page/Performance.cpp: (WebCore::Performance::addNavigationTiming): * page/Performance.h: * page/PerformanceNavigation.cpp: (WebCore::PerformanceNavigation::redirectCount const): * page/PerformanceNavigationTiming.cpp: (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::redirectCount const): * page/PerformanceNavigationTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::networkLoadTimeToDOMHighResTimeStamp): (WebCore::fetchStart): (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::monotonicTimeToDOMHighResTimeStamp): Deleted. (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): Deleted. * page/PerformanceResourceTiming.h: * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::navigationStart const): (WebCore::PerformanceTiming::unloadEventStart const): (WebCore::PerformanceTiming::unloadEventEnd const): (WebCore::PerformanceTiming::redirectStart const): (WebCore::PerformanceTiming::redirectEnd const): (WebCore::PerformanceTiming::fetchStart const): (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): (WebCore::PerformanceTiming::responseEnd const): (WebCore::PerformanceTiming::domLoading const): (WebCore::PerformanceTiming::domInteractive const): (WebCore::PerformanceTiming::domContentLoadedEventStart const): (WebCore::PerformanceTiming::domContentLoadedEventEnd const): (WebCore::PerformanceTiming::domComplete const): (WebCore::PerformanceTiming::loadEventStart const): (WebCore::PerformanceTiming::loadEventEnd const): (WebCore::PerformanceTiming::documentLoader const): (WebCore::PerformanceTiming::documentEventTiming const): (WebCore::PerformanceTiming::documentLoadTiming const): (WebCore::PerformanceTiming::networkLoadMetrics const): (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds const): (WebCore::PerformanceTiming::documentTiming const): Deleted. (WebCore::PerformanceTiming::loadTiming const): Deleted. (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart const): Deleted. * page/PerformanceTiming.h: * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::hasCrossOriginRedirect const): (WebCore::ResourceHandle::setHasCrossOriginRedirect): (WebCore::ResourceHandle::incrementRedirectCount): (WebCore::ResourceHandle::redirectCount const): (WebCore::ResourceHandle::startTimeBeforeRedirects const): (WebCore::ResourceHandle::networkLoadMetrics): (WebCore::ResourceHandle::setNetworkLoadMetrics): * platform/network/ResourceHandle.h: * platform/network/ResourceHandleInternal.h: * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::dateToMonotonicTime): (WebCore::packageTimingData): (WebCore::copyTimingData): * platform/network/cocoa/WebCoreNSURLSession.mm: (networkLoadMetricsDate): (-[WebCoreNSURLSessionTaskTransactionMetrics fetchStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics domainLookupEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics secureConnectionStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics connectEndDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics requestStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseStartDate]): (-[WebCoreNSURLSessionTaskTransactionMetrics responseEndDate]): * platform/network/curl/CurlContext.cpp: (WebCore::CurlHandle::getNetworkLoadMetrics): * platform/network/curl/CurlContext.h: * platform/network/curl/CurlRequest.cpp: (WebCore::CurlRequest::didCompleteTransfer): (WebCore::CurlRequest::networkLoadMetrics): * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::start): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::clearRequest): (WebKit::NetworkDataTaskSoup::resume): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): LayoutTests: * http/tests/misc/webtiming-slow-load-expected.txt: * http/tests/misc/webtiming-slow-load.py: Our new metrics gathering now matches Firefox instead of Chrome in PerformanceResourceTiming::responseEnd in this edge case of a deprecated API. Update expectations accordingly. * platform/mac-wk1/TestExpectations: Bringing this test to passing in WK2 makes it flaky in WK1 because we don't get good redirect timing data from CFNetwork through NSURLConnection. * platform/win/http/tests/misc/webtiming-one-redirect-expected.txt: Added. * platform/win/http/tests/misc/webtiming-slow-load-expected.txt: Copied from LayoutTests/http/tests/misc/webtiming-slow-load-expected.txt. * platform/win/http/tests/misc/webtiming-two-redirects-expected.txt: Added. The network layer is now responsible for counting redirects and providing redirect timings. Our friend CFURLConnection doesn't have that ability, so it doesn't pass these tests any more. It never supported any timing APIs and other tests are skipped. Canonical link: https://commits.webkit.org/238416@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 01:25:53 +00:00
return m_resourceTiming.networkLoadMetrics().redirectCount;
Add support for Navigation Timing Level 2 https://bugs.webkit.org/show_bug.cgi?id=184363 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/navigation-timing/META.yml: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_image_document.html: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document-expected.txt: Added. * web-platform-tests/navigation-timing/dom_interactive_media_document.html: Added. * web-platform-tests/navigation-timing/idlharness.window.js: * web-platform-tests/navigation-timing/nav2_test_attributes_exist-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_exist.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_attributes_values.html: Added. This test fails because we have not implemented transferSize, encodedBodySize, and decodedBodySize as noted in PerformanceResourceTiming.idl * web-platform-tests/navigation-timing/nav2_test_document_open-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_open.html: * web-platform-tests/navigation-timing/nav2_test_document_replaced-expected.txt: * web-platform-tests/navigation-timing/nav2_test_document_replaced.html: * web-platform-tests/navigation-timing/nav2_test_frame_removed-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start-expected.txt: * web-platform-tests/navigation-timing/nav2_test_instance_accessible_from_the_start.html: * web-platform-tests/navigation-timing/nav2_test_instance_accessors-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_instance_accessors.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigate_within_document-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigate_within_document.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_backforward.html: * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html: Added. * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload-expected.txt: * web-platform-tests/navigation-timing/nav2_test_navigation_type_reload.html: * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin-expected.txt: Added. This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html: Copied from LayoutTests/imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_partial_opt_in.html: * web-platform-tests/navigation-timing/nav2_test_redirect_none-expected.txt: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_none.html: Added. * web-platform-tests/navigation-timing/nav2_test_redirect_server-expected.txt: This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_redirect_server.html: * web-platform-tests/navigation-timing/nav2_test_redirect_xserver-expected.txt: This test fails because our test infrastructure doesn't support loading from www.localhost. * web-platform-tests/navigation-timing/nav2_test_redirect_xserver.html: * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances-expected.txt: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html: Added. * web-platform-tests/navigation-timing/po-navigation-expected.txt: Added. * web-platform-tests/navigation-timing/po-navigation.html: Added. * web-platform-tests/navigation-timing/resources/webperftestharness.js: (test_namespace): (test_attribute_exists): (test_enum): * web-platform-tests/navigation-timing/secure-connection-start-reuse.https-expected.txt: Added. * web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html: Added. * web-platform-tests/navigation-timing/secure_connection_start_non_zero.https-expected.txt: This test has been marked as flaky. It needs to be fixed to not rely on no initial connection reuse. * web-platform-tests/navigation-timing/supported_navigation_type.any-expected.txt: * web-platform-tests/navigation-timing/supported_navigation_type.any.worker-expected.txt: * web-platform-tests/navigation-timing/test_document_onload-expected.txt: Added. * web-platform-tests/navigation-timing/test_document_onload.html: Added. This test failure needs further investigation. * web-platform-tests/navigation-timing/unload-event-same-origin-check-expected.txt: * web-platform-tests/navigation-timing/unload-event-same-origin-check.html: * web-platform-tests/performance-timeline/META.yml: Added. * web-platform-tests/performance-timeline/buffered-flag-after-timeout.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/buffered-flag-observer.any.js: Added. * web-platform-tests/performance-timeline/get-invalid-entries-expected.txt: Added. * web-platform-tests/performance-timeline/get-invalid-entries.html: Added. * web-platform-tests/performance-timeline/idlharness.any.js: Added. (async idl_array): * web-platform-tests/performance-timeline/multiple-buffered-flag-observers.any.js: Added. (promise_test): * web-platform-tests/performance-timeline/not-clonable-expected.txt: Added. * web-platform-tests/performance-timeline/not-clonable.html: Added. * web-platform-tests/performance-timeline/observer-buffered-false.any.js: Added. (async_test.t.t.step_timeout): * web-platform-tests/performance-timeline/performanceentry-tojson.any.js: Added. (test): * web-platform-tests/performance-timeline/po-callback-mutate.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect-removes-observed-types.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-disconnect.any.js: Added. (async_test): (test): * web-platform-tests/performance-timeline/po-entries-sort.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-getentries.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-mark-measure.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe-expected.txt: Added. * web-platform-tests/performance-timeline/po-observe-repeated-type.any.js: Added. (async_test): * web-platform-tests/performance-timeline/po-observe.html: Added. * web-platform-tests/performance-timeline/po-resource-expected.txt: Added. * web-platform-tests/performance-timeline/po-resource.html: Added. * web-platform-tests/performance-timeline/po-takeRecords.any.js: Added. (async_test): * web-platform-tests/performance-timeline/resources/postmessage-entry.html: Added. * web-platform-tests/performance-timeline/resources/worker-invalid-entries.js: Added. * web-platform-tests/performance-timeline/resources/worker-with-performance-observer.js: Added. (catch): * web-platform-tests/performance-timeline/supportedEntryTypes.any-expected.txt: This test failure needs further investigation. It's a bindings generation problem I've unsuccessfully looked into before. * web-platform-tests/performance-timeline/supportedEntryTypes.any.js: (test): * web-platform-tests/performance-timeline/supportedEntryTypes.any.worker-expected.txt: * web-platform-tests/performance-timeline/webtiming-resolution.any.js: Added. (testTimeResolution): (timeByUserTiming): * web-platform-tests/performance-timeline/worker-with-performance-observer-expected.txt: Added. * web-platform-tests/performance-timeline/worker-with-performance-observer.html: Added. * web-platform-tests/service-workers/service-worker/navigation-timing.https-expected.txt: This existing test failure needs more investigation. We are probably close to a fix after this patch. Source/WebCore: This is basically just a new shape for exposing the same data as window.performance.navigation, but with a shape that fits better into the rest of the performance timeline measurements that have been added to the web platform since performance.navigation. I noted that exposing transfer size is problematic, and some of the tests for reading transfer size still fail. There are still a few relatively minor test failures to fix in future patches. Each one is annotated in the LayoutTests ChangeLogs. Tests: imported/w3c/web-platform-tests/navigation-timing/dom_interactive_image_document.html imported/w3c/web-platform-tests/navigation-timing/dom_interactive_media_document.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_exist.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_instance_accessors.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigate_iframe.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_navigation_type_navigate.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_chain_xserver_final_original_origin.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_redirect_none.html imported/w3c/web-platform-tests/navigation-timing/nav2_test_unique_nav_instances.html imported/w3c/web-platform-tests/navigation-timing/po-navigation.html imported/w3c/web-platform-tests/navigation-timing/secure-connection-start-reuse.https.html imported/w3c/web-platform-tests/navigation-timing/test_document_onload.html imported/w3c/web-platform-tests/performance-timeline/get-invalid-entries.html imported/w3c/web-platform-tests/performance-timeline/not-clonable.html imported/w3c/web-platform-tests/performance-timeline/po-observe.html imported/w3c/web-platform-tests/performance-timeline/po-resource.html imported/w3c/web-platform-tests/performance-timeline/worker-with-performance-observer.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSPerformanceEntryCustom.cpp: (WebCore::toJSNewlyCreated): * dom/Document.cpp: (WebCore::Document::setReadyState): Sometimes the ready state jumps right to Complete without hitting Interactive along the way. When this happens, we want to mark both m_documentTiming.domComplete and m_documentTiming.domInteractive. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): Call addNavigationTiming in notifyFinished to create the navigation timing object when we are done navigating * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didFinishLoading): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): Add a URL parameter. Sometimes we need to use the request's URL and sometimes the response's. Different specs written at different times. (WebCore::ResourceTiming::populateServerTiming const): (WebCore::ResourceTiming::populateServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::url const): (WebCore::ResourceTiming::initiator const): (WebCore::ResourceTiming::loadTiming const): (WebCore::ResourceTiming::networkLoadMetrics const): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::reportResourceTiming): * page/Performance.cpp: (WebCore::Performance::getEntries const): (WebCore::Performance::getEntriesByType const): (WebCore::Performance::getEntriesByName const): (WebCore::Performance::appendBufferedEntriesByType const): (WebCore::Performance::addNavigationTiming): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::queueEntry): (WebCore::Performance::scheduleTaskIfNeeded): * page/Performance.h: * page/PerformanceEntry.h: (WebCore::PerformanceEntry::startTime const): (WebCore::PerformanceEntry::duration const): (WebCore::PerformanceEntry::isResource const): Deleted. (WebCore::PerformanceEntry::isMark const): Deleted. (WebCore::PerformanceEntry::isMeasure const): Deleted. (WebCore::PerformanceEntry::isPaint const): Deleted. * page/PerformanceMark.h: (isType): Deleted. SPECIALIZE_TYPE_TRAITS_BEGIN/END doesn't work well with PerformanceNavigationTiming which inherits from PerformanceResourceTiming which both have distinct types. is<PerformanceResourceTiming> doesn't give us the info we need. I replaced that with "switch (entry->performanceEntryType())" in the one place it's used, and it works like a charm. Also renamed type to performanceEntryType so it doesn't conflict with PerformanceNavigationTiming::type, which is specified in the idl. * page/PerformanceMeasure.h: (isType): Deleted. * page/PerformanceNavigationTiming.cpp: Added. (WebCore::toPerformanceNavigationTimingNavigationType): (WebCore::PerformanceNavigationTiming::PerformanceNavigationTiming): (WebCore::PerformanceNavigationTiming::millisecondsSinceOrigin const): (WebCore::PerformanceNavigationTiming::sameOriginCheckFails const): (WebCore::PerformanceNavigationTiming::unloadEventStart const): (WebCore::PerformanceNavigationTiming::unloadEventEnd const): (WebCore::PerformanceNavigationTiming::domInteractive const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventStart const): (WebCore::PerformanceNavigationTiming::domContentLoadedEventEnd const): (WebCore::PerformanceNavigationTiming::domComplete const): (WebCore::PerformanceNavigationTiming::loadEventStart const): (WebCore::PerformanceNavigationTiming::loadEventEnd const): (WebCore::PerformanceNavigationTiming::type const): (WebCore::PerformanceNavigationTiming::redirectCount const): (WebCore::PerformanceNavigationTiming::startTime const): (WebCore::PerformanceNavigationTiming::duration const): * page/PerformanceNavigationTiming.h: Added. * page/PerformanceNavigationTiming.idl: Copied from Source/WebCore/page/PerformanceObserver.idl. * page/PerformanceObserver.cpp: (WebCore::PerformanceObserver::takeRecords): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::deliver): (WebCore::PerformanceObserver::supportedEntryTypes): * page/PerformanceObserver.h: * page/PerformanceObserver.idl: * page/PerformanceObserverEntryList.cpp: (WebCore::PerformanceObserverEntryList::getEntriesByName const): * page/PerformancePaintTiming.h: (isType): Deleted. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol const): (WebCore::PerformanceResourceTiming::redirectStart const): (WebCore::PerformanceResourceTiming::redirectEnd const): (WebCore::PerformanceResourceTiming::fetchStart const): (WebCore::PerformanceResourceTiming::domainLookupStart const): (WebCore::PerformanceResourceTiming::domainLookupEnd const): (WebCore::PerformanceResourceTiming::connectStart const): (WebCore::PerformanceResourceTiming::connectEnd const): (WebCore::PerformanceResourceTiming::secureConnectionStart const): (WebCore::PerformanceResourceTiming::requestStart const): (WebCore::PerformanceResourceTiming::responseStart const): (WebCore::PerformanceResourceTiming::responseEnd const): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp const): * page/PerformanceResourceTiming.h: (WebCore::PerformanceResourceTiming::initiatorType const): (isType): Deleted. * page/PerformanceResourceTiming.idl: * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/NetworkLoadMetrics.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): Pass metrics including the response end time from NSURLConnection so we don't assert in WebKitLegacy. * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): Use currentRequest instead of passing in the response so we can call it from didFinishLoading, where we don't have a response stored anywhere. We're just looking for whether it's http or https, so the currentRequest (which is the request after all the redirects) fits our purpose. * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::handleDataURL): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): Source/WebKit: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): Mark reused TLS connections in complete metrics like I did in incomplete metrics in r277493. Source/WebKitLegacy: * WebCoreSupport/PingHandle.h: Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * TestExpectations: Annoyingly secure_connection_start_non_zero.https.html becomes flaky with a correct implementation because it assumes that no connection is reused. However, when running this test after other tests, another connection is often reused. * performance-api/paint-timing/performance-observer-first-contentful-paint-expected.txt: * performance-api/paint-timing/performance-observer-first-contentful-paint.html: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resources/timeline-api.js: * platform/mac-wk1/imported/w3c/web-platform-tests/navigation-timing/nav2_test_attributes_values-expected.txt: Next hop protocol isn't implemented in ResourceHandle. That's probably no big deal because WebKitLegacy is deprecated and not used by Safari. Canonical link: https://commits.webkit.org/237930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-20 00:33:02 +00:00
}
double PerformanceNavigationTiming::startTime() const
{
// https://www.w3.org/TR/navigation-timing-2/#dom-PerformanceNavigationTiming-startTime
return 0.0;
}
double PerformanceNavigationTiming::duration() const
{
// https://www.w3.org/TR/navigation-timing-2/#dom-PerformanceNavigationTiming-duration
return loadEventEnd() - startTime();
}
} // namespace WebCore