haikuwebkit/Source/WebCore/loader/ResourceTiming.cpp

83 lines
3.8 KiB
C++
Raw Permalink Normal View History

[Resource Timing] Support Resource Timing in Workers https://bugs.webkit.org/show_bug.cgi?id=168086 <rdar://problem/30430117> Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/idlharness-expected.txt: * web-platform-tests/resource-timing/resource-timing-expected.txt: * web-platform-tests/resource-timing/resource_cached-expected.txt: * web-platform-tests/resource-timing/resource_connection_reuse-expected.txt: Progressions. * web-platform-tests/resource-timing/resources/data.json: Added. * web-platform-tests/resource-timing/resources/rt-iframe-1.html: Added. * web-platform-tests/resource-timing/resources/rt-iframe-2.html: Added. * web-platform-tests/resource-timing/resources/rt-module.js: Added. * web-platform-tests/resource-timing/resources/rt-sub-module.js: Added. * web-platform-tests/resource-timing/resources/rt-utilities.js: Added. * web-platform-tests/resource-timing/resources/rt-worker-resources.js: Added. New Resources. * web-platform-tests/resource-timing/rt-cors-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.html: Added. * web-platform-tests/resource-timing/rt-cors.js: Added. * web-platform-tests/resource-timing/rt-cors.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.worker.html: Added. * web-platform-tests/resource-timing/rt-cors.worker.js: Added. Tests for redirects and cross origin data hiding. * web-platform-tests/resource-timing/rt-initiatorType-css-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-css.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-element-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-element.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.js: Added. * web-platform-tests/resource-timing/rt-initiatorType-other-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-other.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.js: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.html: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.js: Added. Tests for producing different initiator types. * web-platform-tests/resource-timing/rt-initiatorType-media-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-media.html: Added. We currently fail these tests, so they are marked as fail. * web-platform-tests/resource-timing/rt-performance-extensions-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.js: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.js: Added. Tests for the new Performance APIs. * web-platform-tests/resource-timing/rt-serialization-expected.txt: Added. * web-platform-tests/resource-timing/rt-serialization.html: Added. Tests for JSON serialization. * web-platform-tests/resource-timing/rt-resource-errors-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-errors.html: Added. * web-platform-tests/resource-timing/rt-resource-ignored-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-ignored.html: Added. Tests for when PerformanceResourceTiming entries should not be included. * web-platform-tests/resource-timing/rt-resources-per-frame-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-frame.html: Added. * web-platform-tests/resource-timing/rt-resources-per-worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-worker.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers.html: Added. Tests for different entries in different contexts. * web-platform-tests/serve: Make executable. Source/WebCore: Worker's load resources through the Document that loaded them. However, their PerformanceResourceTiming entries should be added to the Performance object inside the Worker context, not the Document's context. This change adds an InitiatorContext to ResourceLoadOptions so that loaders can determine if the load was initiated by the Document or a Worker. This allows loaders to then know if the ResourceTiming data they collect should be added to the Document's Performance object or forwarded on to the Worker's. This adds a new ThreadableLoaderClient method intended only for the purpose of adding the ResourceTiming information to the Worker's Performance object. Unlike other ThreadableLoaderClient methods that are bridged and forwarded on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this method never needs to be handled by clients and can be uniformly handled by the WorkerThreadableLoader itself. We also add a new ResourceTiming object that encapsulates all of the data ultimately needed for a PerformanceResourceTimingEntry object. This allows for all of the information to be gathered while loading on the Document before serializing across to the Worker. That includes the Timing-Allow-Origin check which uses the SecurityOrigin of the Worker. This also modernizes and addresses issues in the Resource Timing implementation. Better handling cases like loading from the Cache, Synchronous Loads, and improving initiatorType information. Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html imported/w3c/web-platform-tests/resource-timing/rt-serialization.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html performance-api/resource-timing-apis.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: New files. * platform/network/NetworkLoadTiming.h: (WebCore::NetworkLoadTiming::reset): Deleted. We no longer need to reset. * loader/ResourceTiming.cpp: Added. (WebCore::passesTimingAllowCheck): (WebCore::ResourceTiming::fromCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: Added. (WebCore::ResourceTiming::url): (WebCore::ResourceTiming::initiator): (WebCore::ResourceTiming::loadTiming): (WebCore::ResourceTiming::networkLoadTiming): (WebCore::ResourceTiming::allowTimingDetails): (WebCore::ResourceTiming::overrideInitiatorName): (WebCore::ResourceTiming::ResourceTiming): Class that encapsulates all of the data needed for a PerformanceResourceTiming entry. There are three static constructors indicating the different ways this object can be constructed and the different data available at the time of construction. * loader/ResourceLoaderOptions.h: Add the new InitiatorContext, default to Document. * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishTiming): New client method only used by WorkerThreadableLoader. * loader/WorkerThreadableLoader.h: * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming): All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker. Add timing information to the Performance object when received. No need to inform clients. * loader/DocumentThreadableLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad): (WebCore::DocumentThreadableLoader::loadRequest): Provide APIs to pass timing data on to a WorkerThreadableLoader. Create ResourceTiming data for synchronous loads. * loader/LoadTiming.h: * loader/LoadTiming.cpp: (WebCore::LoadTiming::isolatedCopy): Add isolatedCopy to allow this data to be passed across to a Worker. * loader/ResourceTimingInformation.h: * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): (WebCore::ResourceTimingInformation::addResourceTiming): (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Refactor to remove unused / unnecessary bits. Extract out some helpful code. Changed this to match when Blink decides when to add or ignore entries, however this may change over time. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::notifyDone): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::finishedTimingForWorkerLoad): * loader/cache/CachedRawResource.h: * loader/cache/CachedRawResourceClient.h: (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad): Plumbing to report timing information to Worker if this resource was loaded for a Worker. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): * loader/cache/CachedResource.h: (WebCore::CachedResource::initiatorName): Store the initiator name on the CachedResource like other data added to the original CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and cleans up other hacks that worked around this later on. * loader/cache/CachedResourceLoader.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::revalidateResource): (WebCore::CachedResourceLoader::loadResource): Simply the creation of a ResourceTiming object for cache hits. Report timing information to Worker if this resource was loaded for a Worker. (WebCore::CachedResourceLoader::loadDone): Eliminate this redundant point attempting to add a ResourceTiming entry. * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName): Update to match the spec. The fallback is "other". * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::setResourceTimingBufferSize): (WebCore::Performance::addResourceTiming): Update to support PerformanceObservers. Update to match spec (event should bubble). * page/PerformanceResourceTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::create): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::fetchStart): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): Construct with a ResourceTiming object containing all the data we need for the entry. Update to match spec for what is required, should fallback, should be zero, etc. (WebCore::passesTimingAllowCheck): Deleted. Extracted this to ResourceTiming creation time in the loading context, since this can't be determined on the Worker context without also having all of the header information from each resource response. * page/PerformanceResourceTiming.idl: Expose to Workers! LayoutTests: * TestExpectations: Pre-emptively mark some tests as flakey that have seen flakiness. * platform/mac/TestExpectations: Skip some tests on ElCapitan because the network timing numbers appear incorrect. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: PerformanceResourceTiming is now available in Workers. * performance-api/resource-timing-apis-expected.txt: Added. * performance-api/resource-timing-apis.html: Added. * performance-api/resources/resource-timing-api.js: Added. Basic API test. We expect to fail nextHopProtocol and size properties right now. Canonical link: https://commits.webkit.org/185464@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-16 19:18:32 +00:00
/*
* Copyright (C) 2017 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
*/
#include "config.h"
#include "ResourceTiming.h"
#include "CachedResource.h"
Resource Timing: Duration is 0 in many cases https://bugs.webkit.org/show_bug.cgi?id=225737 Reviewed by Chris Dumez. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/cors-preflight.any-expected.txt: * web-platform-tests/resource-timing/crossorigin-sandwich-no-TAO.sub-expected.txt: * web-platform-tests/resource-timing/crossorigin-sandwich-partial-TAO.sub-expected.txt: * web-platform-tests/resource-timing/resource_timing_cross_origin_redirect_chain-expected.txt: * web-platform-tests/resource-timing/status-codes-create-entry-expected.txt: Source/WebCore: This fixes two problems with our PerformanceResourceTiming implementation: 1. ResourceTimingInformation::shouldAddResourceTiming wasn't adding timing data if CachedResource::errorOccurred returned true, which includes when the server responds with an HTTP 404. We want loadFailedOrCanceled instead, which only returns true if there's a network error or if the load is cancelled. This matches the behavior of other browsers. 2. ResourceTiming::fromMemoryCache was assuming that it never had network information to report because we pulled from the cache, not the network. However, a common case is that HTMLPreloadScanner::scan calls HTMLResourcePreloader::preload which loads the resource while the HTML parser is blocked on loading scripts or other things, then CachedResourceLoader::requestResource pulls it out of the memory cache. In this case, use the network metrics that we are already storing if it's the first time we are pulling this resource out of the memory cache. After that, 0 load time is quite accurate. Covered by newly passing Web Platform Tests, which Chrome and Firefox already passed. * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::initServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::ResourceTiming): * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): * loader/cache/CachedResource.h: (WebCore::CachedResource::takeNetworkLoadMetrics): * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * platform/network/ResourceResponseBase.h: (WebCore::ResourceResponseBase::deprecatedNetworkLoadMetricsOrNull const): (WebCore::ResourceResponseBase::takeNetworkLoadMetrics): Canonical link: https://commits.webkit.org/240569@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281110 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-16 21:43:02 +00:00
#include "DocumentLoadTiming.h"
Add the PerformanceServerTiming Interface which makes Server-Timing header timing values available to JavaScript running in the browser. https://bugs.webkit.org/show_bug.cgi?id=175569 Patch by Charles Vazac <cvazac@gmail.com> on 2018-05-15 Reviewed by Youenn Fablet. Tests were imported from web-platform-tests: WebKit/LayoutTests/imported/w3c/web-platform-tests/server-timing/* LayoutTests/imported/w3c: * web-platform-tests/server-timing/cross_origin.html: Added. * web-platform-tests/server-timing/navigation_timing_idl.html: Added. * web-platform-tests/server-timing/navigation_timing_idl.https.html: Added. * web-platform-tests/server-timing/resources/blue.png: Added. * web-platform-tests/server-timing/resources/blue.png.sub.headers: Added. * web-platform-tests/server-timing/resources/blue_tao.png: Added. * web-platform-tests/server-timing/resources/blue_tao.png.sub.headers: Added. * web-platform-tests/server-timing/resources/green.png: Added. * web-platform-tests/server-timing/resources/green.png.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/0.js: Added. * web-platform-tests/server-timing/resources/parsing/0.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/1.js: Added. * web-platform-tests/server-timing/resources/parsing/1.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/10.js: Added. * web-platform-tests/server-timing/resources/parsing/10.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/11.js: Added. * web-platform-tests/server-timing/resources/parsing/11.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/12.js: Added. * web-platform-tests/server-timing/resources/parsing/12.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/13.js: Added. * web-platform-tests/server-timing/resources/parsing/13.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/14.js: Added. * web-platform-tests/server-timing/resources/parsing/14.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/15.js: Added. * web-platform-tests/server-timing/resources/parsing/15.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/16.js: Added. * web-platform-tests/server-timing/resources/parsing/16.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/17.js: Added. * web-platform-tests/server-timing/resources/parsing/17.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/18.js: Added. * web-platform-tests/server-timing/resources/parsing/18.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/19.js: Added. * web-platform-tests/server-timing/resources/parsing/19.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/2.js: Added. * web-platform-tests/server-timing/resources/parsing/2.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/20.js: Added. * web-platform-tests/server-timing/resources/parsing/20.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/21.js: Added. * web-platform-tests/server-timing/resources/parsing/21.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/22.js: Added. * web-platform-tests/server-timing/resources/parsing/22.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/23.js: Added. * web-platform-tests/server-timing/resources/parsing/23.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/24.js: Added. * web-platform-tests/server-timing/resources/parsing/24.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/25.js: Added. * web-platform-tests/server-timing/resources/parsing/25.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/26.js: Added. * web-platform-tests/server-timing/resources/parsing/26.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/27.js: Added. * web-platform-tests/server-timing/resources/parsing/27.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/28.js: Added. * web-platform-tests/server-timing/resources/parsing/28.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/29.js: Added. * web-platform-tests/server-timing/resources/parsing/29.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/3.js: Added. * web-platform-tests/server-timing/resources/parsing/3.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/30.js: Added. * web-platform-tests/server-timing/resources/parsing/30.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/31.js: Added. * web-platform-tests/server-timing/resources/parsing/31.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/32.js: Added. * web-platform-tests/server-timing/resources/parsing/32.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/33.js: Added. * web-platform-tests/server-timing/resources/parsing/33.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/34.js: Added. * web-platform-tests/server-timing/resources/parsing/34.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/35.js: Added. * web-platform-tests/server-timing/resources/parsing/35.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/36.js: Added. * web-platform-tests/server-timing/resources/parsing/36.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/37.js: Added. * web-platform-tests/server-timing/resources/parsing/37.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/38.js: Added. * web-platform-tests/server-timing/resources/parsing/38.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/39.js: Added. * web-platform-tests/server-timing/resources/parsing/39.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/4.js: Added. * web-platform-tests/server-timing/resources/parsing/4.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/40.js: Added. * web-platform-tests/server-timing/resources/parsing/40.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/41.js: Added. * web-platform-tests/server-timing/resources/parsing/41.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/42.js: Added. * web-platform-tests/server-timing/resources/parsing/42.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/43.js: Added. * web-platform-tests/server-timing/resources/parsing/43.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/44.js: Added. * web-platform-tests/server-timing/resources/parsing/44.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/45.js: Added. * web-platform-tests/server-timing/resources/parsing/45.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/46.js: Added. * web-platform-tests/server-timing/resources/parsing/46.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/47.js: Added. * web-platform-tests/server-timing/resources/parsing/47.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/48.js: Added. * web-platform-tests/server-timing/resources/parsing/48.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/49.js: Added. * web-platform-tests/server-timing/resources/parsing/49.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/5.js: Added. * web-platform-tests/server-timing/resources/parsing/5.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/50.js: Added. * web-platform-tests/server-timing/resources/parsing/50.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/51.js: Added. * web-platform-tests/server-timing/resources/parsing/51.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/52.js: Added. * web-platform-tests/server-timing/resources/parsing/52.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/53.js: Added. * web-platform-tests/server-timing/resources/parsing/53.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/54.js: Added. * web-platform-tests/server-timing/resources/parsing/54.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/55.js: Added. * web-platform-tests/server-timing/resources/parsing/55.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/56.js: Added. * web-platform-tests/server-timing/resources/parsing/56.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/57.js: Added. * web-platform-tests/server-timing/resources/parsing/57.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/58.js: Added. * web-platform-tests/server-timing/resources/parsing/58.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/59.js: Added. * web-platform-tests/server-timing/resources/parsing/59.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/6.js: Added. * web-platform-tests/server-timing/resources/parsing/6.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/60.js: Added. * web-platform-tests/server-timing/resources/parsing/60.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/61.js: Added. * web-platform-tests/server-timing/resources/parsing/61.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/62.js: Added. * web-platform-tests/server-timing/resources/parsing/62.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/63.js: Added. * web-platform-tests/server-timing/resources/parsing/63.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/64.js: Added. * web-platform-tests/server-timing/resources/parsing/64.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/65.js: Added. * web-platform-tests/server-timing/resources/parsing/65.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/66.js: Added. * web-platform-tests/server-timing/resources/parsing/66.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/67.js: Added. * web-platform-tests/server-timing/resources/parsing/67.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/68.js: Added. * web-platform-tests/server-timing/resources/parsing/68.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/69.js: Added. * web-platform-tests/server-timing/resources/parsing/69.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/7.js: Added. * web-platform-tests/server-timing/resources/parsing/7.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/70.js: Added. * web-platform-tests/server-timing/resources/parsing/70.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/71.js: Added. * web-platform-tests/server-timing/resources/parsing/71.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/72.js: Added. * web-platform-tests/server-timing/resources/parsing/72.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/73.js: Added. * web-platform-tests/server-timing/resources/parsing/73.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/74.js: Added. * web-platform-tests/server-timing/resources/parsing/74.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/75.js: Added. * web-platform-tests/server-timing/resources/parsing/75.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/76.js: Added. * web-platform-tests/server-timing/resources/parsing/76.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/77.js: Added. * web-platform-tests/server-timing/resources/parsing/77.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/78.js: Added. * web-platform-tests/server-timing/resources/parsing/78.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/79.js: Added. * web-platform-tests/server-timing/resources/parsing/79.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/8.js: Added. * web-platform-tests/server-timing/resources/parsing/8.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/80.js: Added. * web-platform-tests/server-timing/resources/parsing/80.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/81.js: Added. * web-platform-tests/server-timing/resources/parsing/81.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/82.js: Added. * web-platform-tests/server-timing/resources/parsing/82.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/83.js: Added. * web-platform-tests/server-timing/resources/parsing/83.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/9.js: Added. * web-platform-tests/server-timing/resources/parsing/9.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/w3c-import.log: Added. * web-platform-tests/server-timing/resources/w3c-import.log: Added. * web-platform-tests/server-timing/resource_timing_idl.html: Added. * web-platform-tests/server-timing/resource_timing_idl.https.html: Added. * web-platform-tests/server-timing/server_timing_header-parsing.html: Added. * web-platform-tests/server-timing/server_timing_header-parsing.https.html: Added. * web-platform-tests/server-timing/test_server_timing.html: Added. * web-platform-tests/server-timing/test_server_timing.html.sub.headers: Added. * web-platform-tests/server-timing/test_server_timing.https.html: Added. * web-platform-tests/server-timing/test_server_timing.https.html.sub.headers: Added. * web-platform-tests/server-timing/w3c-import.log: Added. Source/WebCore: * Sources.txt: Added references to HeaderFieldTokenizer.cpp, ServerTiming.cpp, and ServerTimingParser.cpp. * WebCore.xcodeproj/project.pbxproj: Added various files. * loader/HeaderFieldTokenizer.cpp: Added. (WebCore::HeaderFieldTokenizer::HeaderFieldTokenizer): Added class for tokenizing header values. (WebCore::HeaderFieldTokenizer::consume): Added method to consume a specified character. (WebCore::HeaderFieldTokenizer::consumeQuotedString): Added method to consume a quote-string. (WebCore::HeaderFieldTokenizer::consumeToken): Added a method to consume a token. (WebCore::HeaderFieldTokenizer::consumeTokenOrQuotedString): Added method to consume a quote-string or quote-string, depending on net character. (WebCore::HeaderFieldTokenizer::skipSpaces): Added method to skip whitespace. (WebCore::HeaderFieldTokenizer::consumeBeforeAnyCharMatch): Added method to advance the cursor up until any of a list of characters. * loader/HeaderFieldTokenizer.h: Added. * loader/HTTPHeaderField.cpp: Expose isTokenCharacter and isWhitespace. * loader/HTTPHeaderField.h: Expose isTokenCharacter and isWhitespace. * loader/PolicyChecker.cpp: Added #include so source compiled on my machine. * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::ResourceTiming): Added call to initServerTiming to parse the header. (WebCore::ResourceTiming::initServerTiming): Added method to parse the header. (WebCore::ResourceTiming::populateServerTiming): Added method to populate the server timing entries on a PerformanceResourceTiming object. (WebCore::ResourceTiming::isolatedCopy const): Added code to copy over the server timing entries. * loader/ResourceTiming.h: (WebCore::ResourceTiming::ResourceTiming): Accept collection of server timing entries in c'tor. * loader/ServerTiming.cpp: Added. (WebCore::ServerTiming::setParameter): Set named parameters, ignoring unrecognized or duplicates. (WebCore::ServerTiming::isolatedCopy const): Return a new pointer to the object. * loader/ServerTiming.h: Added. (WebCore::ServerTiming::ServerTiming): Added struct for the data needed by a server timing entry. (WebCore::ServerTiming::name const): Added name field of a server timing entry. (WebCore::ServerTiming::duration const): Added duration field of a server timing entry. (WebCore::ServerTiming::description const): Added description field of a server timing entry. * loader/ServerTimingParser.cpp: Added. (WebCore::ServerTimingParser::parseServerTiming): Parses the header generating a collection of server timing structs. * loader/ServerTimingParser.h: Added. * loader/WorkerThreadableLoader.h: Fix build. * page/Performance.cpp: (WebCore::Performance::addResourceTiming): Fixed a typo. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): Given a ResourceTiming object, populate our collection of PerformanceServerTiming objects. * page/PerformanceResourceTiming.h: Added serverTiming member and getter. * page/PerformanceResourceTiming.idl: Added serverTiming member to interface. * platform/network/HTTPHeaderNames.in: Added "Server-Timing" to the header enum. * platform/network/ResourceResponseBase.cpp: Added "Server-Timing" to isSafeCrossOriginResponseHeader whitelist. LayoutTests: * imported/w3c/web-platform-tests/server-timing/cross_origin-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/resource_timing_idl-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/resource_timing_idl.https-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/server_timing_header-parsing-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/server_timing_header-parsing.https-expected.txt: Added. Canonical link: https://commits.webkit.org/201126@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-15 19:24:30 +00:00
#include "PerformanceServerTiming.h"
Add Web API Statistics Collection https://bugs.webkit.org/show_bug.cgi?id=187773 <rdar://problem/44155162> Patch by Woodrow Wang <woodrow_wang@apple.com> on 2018-09-11 Reviewed by Brent Fulgham. Source/WebCore: Added data collection for web API statistics, specifically regarding the canvas, font loads, screen functions, and navigator functions. The data collection code is placed under a runtime enabled feature flag. The statistics are stored in a ResourceLoadStatistics object and written to a plist on disk. Added a new file CanvasActivityRecord.h and CanvasActivityRecord.cpp which includes a struct to keep track of HTML5 canvas element read and writes. Tests: http/tests/webAPIStatistics/canvas-read-and-write-data-collection.html http/tests/webAPIStatistics/font-load-data-collection.html http/tests/webAPIStatistics/navigator-functions-accessed-data-collection.html http/tests/webAPIStatistics/screen-functions-accessed-data-collection.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSFontFaceSource.cpp: (WebCore::CSSFontFaceSource::load): * css/CSSFontSelector.cpp: (WebCore::CSSFontSelector::fontRangesForFamily): (WebCore::CSSFontSelector::fallbackFontAt): The following are the functions where we'd like to record a canvas read. * html/HTMLCanvasElement.cpp: (WebCore::HTMLCanvasElement::toDataURL): (WebCore::HTMLCanvasElement::toBlob): (WebCore::HTMLCanvasElement::getImageData): (WebCore::HTMLCanvasElement::toMediaSample): (WebCore::HTMLCanvasElement::captureStream): The following are the functions where we'd like to record a canvas write. * html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::measureText): (WebCore::CanvasRenderingContext2D::drawTextInternal): The following files and functions handle the CanvasActivityRecord struct and its respective functions. * loader/CanvasActivityRecord.cpp: Added. (WebCore::CanvasActivityRecord::recordWrittenOrMeasuredText): (WebCore::CanvasActivityRecord::mergeWith): * loader/CanvasActivityRecord.h: Added. (WebCore::CanvasActivityRecord::encode const): (WebCore::CanvasActivityRecord::decode): * loader/DocumentThreadableLoader.cpp: * loader/FrameLoader.cpp: * loader/ResourceLoadObserver.cpp: (WebCore::ResourceLoadObserver::logFontLoad): (WebCore::ResourceLoadObserver::logCanvasRead): (WebCore::ResourceLoadObserver::logCanvasWriteOrMeasure): (WebCore::ResourceLoadObserver::logNavigatorAPIAccessed): (WebCore::ResourceLoadObserver::logScreenAPIAccessed): Before, entries in the ResourceLoadStatistics involving HashSets used "origin" as the key. Now the encodeHashSet function has been generalized to take any key to encode the entries in the HashSet. Also added functionality to encode an OptionSet by converting it to its raw bitmask state. * loader/ResourceLoadObserver.h: * loader/ResourceLoadStatistics.cpp: (WebCore::encodeHashSet): (WebCore::encodeOriginHashSet): (WebCore::encodeOptionSet): (WebCore::encodeFontHashSet): (WebCore::encodeCanvasActivityRecord): (WebCore::ResourceLoadStatistics::encode const): (WebCore::decodeHashSet): (WebCore::decodeOriginHashSet): (WebCore::decodeOptionSet): (WebCore::decodeFontHashSet): (WebCore::decodeCanvasActivityRecord): (WebCore::ResourceLoadStatistics::decode): (WebCore::navigatorAPIEnumToString): (WebCore::screenAPIEnumToString): (WebCore::appendNavigatorAPIOptionSet): (WebCore::appendScreenAPIOptionSet): (WebCore::ResourceLoadStatistics::toString const): (WebCore::ResourceLoadStatistics::merge): * loader/ResourceLoadStatistics.h: * loader/ResourceTiming.cpp: The following are the navigator functions recorded for the web API statistics. * page/Navigator.cpp: (WebCore::Navigator::appVersion const): (WebCore::Navigator::userAgent const): (WebCore::Navigator::plugins): (WebCore::Navigator::mimeTypes): (WebCore::Navigator::cookieEnabled const): (WebCore::Navigator::javaEnabled const): The following are the screen functions recorded for the web API statistics. * page/Screen.cpp: (WebCore::Screen::height const): (WebCore::Screen::width const): (WebCore::Screen::colorDepth const): (WebCore::Screen::pixelDepth const): (WebCore::Screen::availLeft const): (WebCore::Screen::availTop const): (WebCore::Screen::availHeight const): (WebCore::Screen::availWidth const): Source/WebKit: * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<ResourceLoadStatistics>::encode): (IPC::ArgumentCoder<ResourceLoadStatistics>::decode): * UIProcess/ResourceLoadStatisticsMemoryStore.cpp: LayoutTests: Added new tests and expectations for the web API statistics data collection. * TestExpectations: * http/tests/webAPIStatistics/canvas-read-and-write-data-collection-expected.txt: Added. * http/tests/webAPIStatistics/canvas-read-and-write-data-collection.html: Added. * http/tests/webAPIStatistics/font-load-data-collection-expected.txt: Added. * http/tests/webAPIStatistics/font-load-data-collection.html: Added. * http/tests/webAPIStatistics/navigator-functions-accessed-data-collection-expected.txt: Added. * http/tests/webAPIStatistics/navigator-functions-accessed-data-collection.html: Added. * http/tests/webAPIStatistics/screen-functions-accessed-data-collection-expected.txt: Added. * http/tests/webAPIStatistics/screen-functions-accessed-data-collection.html: Added. * platform/ios-wk2/TestExpectations: * platform/mac-wk2/TestExpectations: Canonical link: https://commits.webkit.org/204480@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235897 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-11 17:14:07 +00:00
#include "RuntimeEnabledFeatures.h"
[Resource Timing] Support Resource Timing in Workers https://bugs.webkit.org/show_bug.cgi?id=168086 <rdar://problem/30430117> Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/idlharness-expected.txt: * web-platform-tests/resource-timing/resource-timing-expected.txt: * web-platform-tests/resource-timing/resource_cached-expected.txt: * web-platform-tests/resource-timing/resource_connection_reuse-expected.txt: Progressions. * web-platform-tests/resource-timing/resources/data.json: Added. * web-platform-tests/resource-timing/resources/rt-iframe-1.html: Added. * web-platform-tests/resource-timing/resources/rt-iframe-2.html: Added. * web-platform-tests/resource-timing/resources/rt-module.js: Added. * web-platform-tests/resource-timing/resources/rt-sub-module.js: Added. * web-platform-tests/resource-timing/resources/rt-utilities.js: Added. * web-platform-tests/resource-timing/resources/rt-worker-resources.js: Added. New Resources. * web-platform-tests/resource-timing/rt-cors-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.html: Added. * web-platform-tests/resource-timing/rt-cors.js: Added. * web-platform-tests/resource-timing/rt-cors.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.worker.html: Added. * web-platform-tests/resource-timing/rt-cors.worker.js: Added. Tests for redirects and cross origin data hiding. * web-platform-tests/resource-timing/rt-initiatorType-css-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-css.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-element-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-element.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.js: Added. * web-platform-tests/resource-timing/rt-initiatorType-other-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-other.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.js: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.html: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.js: Added. Tests for producing different initiator types. * web-platform-tests/resource-timing/rt-initiatorType-media-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-media.html: Added. We currently fail these tests, so they are marked as fail. * web-platform-tests/resource-timing/rt-performance-extensions-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.js: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.js: Added. Tests for the new Performance APIs. * web-platform-tests/resource-timing/rt-serialization-expected.txt: Added. * web-platform-tests/resource-timing/rt-serialization.html: Added. Tests for JSON serialization. * web-platform-tests/resource-timing/rt-resource-errors-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-errors.html: Added. * web-platform-tests/resource-timing/rt-resource-ignored-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-ignored.html: Added. Tests for when PerformanceResourceTiming entries should not be included. * web-platform-tests/resource-timing/rt-resources-per-frame-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-frame.html: Added. * web-platform-tests/resource-timing/rt-resources-per-worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-worker.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers.html: Added. Tests for different entries in different contexts. * web-platform-tests/serve: Make executable. Source/WebCore: Worker's load resources through the Document that loaded them. However, their PerformanceResourceTiming entries should be added to the Performance object inside the Worker context, not the Document's context. This change adds an InitiatorContext to ResourceLoadOptions so that loaders can determine if the load was initiated by the Document or a Worker. This allows loaders to then know if the ResourceTiming data they collect should be added to the Document's Performance object or forwarded on to the Worker's. This adds a new ThreadableLoaderClient method intended only for the purpose of adding the ResourceTiming information to the Worker's Performance object. Unlike other ThreadableLoaderClient methods that are bridged and forwarded on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this method never needs to be handled by clients and can be uniformly handled by the WorkerThreadableLoader itself. We also add a new ResourceTiming object that encapsulates all of the data ultimately needed for a PerformanceResourceTimingEntry object. This allows for all of the information to be gathered while loading on the Document before serializing across to the Worker. That includes the Timing-Allow-Origin check which uses the SecurityOrigin of the Worker. This also modernizes and addresses issues in the Resource Timing implementation. Better handling cases like loading from the Cache, Synchronous Loads, and improving initiatorType information. Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html imported/w3c/web-platform-tests/resource-timing/rt-serialization.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html performance-api/resource-timing-apis.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: New files. * platform/network/NetworkLoadTiming.h: (WebCore::NetworkLoadTiming::reset): Deleted. We no longer need to reset. * loader/ResourceTiming.cpp: Added. (WebCore::passesTimingAllowCheck): (WebCore::ResourceTiming::fromCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: Added. (WebCore::ResourceTiming::url): (WebCore::ResourceTiming::initiator): (WebCore::ResourceTiming::loadTiming): (WebCore::ResourceTiming::networkLoadTiming): (WebCore::ResourceTiming::allowTimingDetails): (WebCore::ResourceTiming::overrideInitiatorName): (WebCore::ResourceTiming::ResourceTiming): Class that encapsulates all of the data needed for a PerformanceResourceTiming entry. There are three static constructors indicating the different ways this object can be constructed and the different data available at the time of construction. * loader/ResourceLoaderOptions.h: Add the new InitiatorContext, default to Document. * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishTiming): New client method only used by WorkerThreadableLoader. * loader/WorkerThreadableLoader.h: * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming): All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker. Add timing information to the Performance object when received. No need to inform clients. * loader/DocumentThreadableLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad): (WebCore::DocumentThreadableLoader::loadRequest): Provide APIs to pass timing data on to a WorkerThreadableLoader. Create ResourceTiming data for synchronous loads. * loader/LoadTiming.h: * loader/LoadTiming.cpp: (WebCore::LoadTiming::isolatedCopy): Add isolatedCopy to allow this data to be passed across to a Worker. * loader/ResourceTimingInformation.h: * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): (WebCore::ResourceTimingInformation::addResourceTiming): (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Refactor to remove unused / unnecessary bits. Extract out some helpful code. Changed this to match when Blink decides when to add or ignore entries, however this may change over time. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::notifyDone): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::finishedTimingForWorkerLoad): * loader/cache/CachedRawResource.h: * loader/cache/CachedRawResourceClient.h: (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad): Plumbing to report timing information to Worker if this resource was loaded for a Worker. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): * loader/cache/CachedResource.h: (WebCore::CachedResource::initiatorName): Store the initiator name on the CachedResource like other data added to the original CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and cleans up other hacks that worked around this later on. * loader/cache/CachedResourceLoader.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::revalidateResource): (WebCore::CachedResourceLoader::loadResource): Simply the creation of a ResourceTiming object for cache hits. Report timing information to Worker if this resource was loaded for a Worker. (WebCore::CachedResourceLoader::loadDone): Eliminate this redundant point attempting to add a ResourceTiming entry. * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName): Update to match the spec. The fallback is "other". * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::setResourceTimingBufferSize): (WebCore::Performance::addResourceTiming): Update to support PerformanceObservers. Update to match spec (event should bubble). * page/PerformanceResourceTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::create): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::fetchStart): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): Construct with a ResourceTiming object containing all the data we need for the entry. Update to match spec for what is required, should fallback, should be zero, etc. (WebCore::passesTimingAllowCheck): Deleted. Extracted this to ResourceTiming creation time in the loading context, since this can't be determined on the Worker context without also having all of the header information from each resource response. * page/PerformanceResourceTiming.idl: Expose to Workers! LayoutTests: * TestExpectations: Pre-emptively mark some tests as flakey that have seen flakiness. * platform/mac/TestExpectations: Skip some tests on ElCapitan because the network timing numbers appear incorrect. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: PerformanceResourceTiming is now available in Workers. * performance-api/resource-timing-apis-expected.txt: Added. * performance-api/resource-timing-apis.html: Added. * performance-api/resources/resource-timing-api.js: Added. Basic API test. We expect to fail nextHopProtocol and size properties right now. Canonical link: https://commits.webkit.org/185464@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-16 19:18:32 +00:00
#include "SecurityOrigin.h"
Add the PerformanceServerTiming Interface which makes Server-Timing header timing values available to JavaScript running in the browser. https://bugs.webkit.org/show_bug.cgi?id=175569 Patch by Charles Vazac <cvazac@gmail.com> on 2018-05-15 Reviewed by Youenn Fablet. Tests were imported from web-platform-tests: WebKit/LayoutTests/imported/w3c/web-platform-tests/server-timing/* LayoutTests/imported/w3c: * web-platform-tests/server-timing/cross_origin.html: Added. * web-platform-tests/server-timing/navigation_timing_idl.html: Added. * web-platform-tests/server-timing/navigation_timing_idl.https.html: Added. * web-platform-tests/server-timing/resources/blue.png: Added. * web-platform-tests/server-timing/resources/blue.png.sub.headers: Added. * web-platform-tests/server-timing/resources/blue_tao.png: Added. * web-platform-tests/server-timing/resources/blue_tao.png.sub.headers: Added. * web-platform-tests/server-timing/resources/green.png: Added. * web-platform-tests/server-timing/resources/green.png.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/0.js: Added. * web-platform-tests/server-timing/resources/parsing/0.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/1.js: Added. * web-platform-tests/server-timing/resources/parsing/1.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/10.js: Added. * web-platform-tests/server-timing/resources/parsing/10.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/11.js: Added. * web-platform-tests/server-timing/resources/parsing/11.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/12.js: Added. * web-platform-tests/server-timing/resources/parsing/12.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/13.js: Added. * web-platform-tests/server-timing/resources/parsing/13.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/14.js: Added. * web-platform-tests/server-timing/resources/parsing/14.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/15.js: Added. * web-platform-tests/server-timing/resources/parsing/15.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/16.js: Added. * web-platform-tests/server-timing/resources/parsing/16.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/17.js: Added. * web-platform-tests/server-timing/resources/parsing/17.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/18.js: Added. * web-platform-tests/server-timing/resources/parsing/18.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/19.js: Added. * web-platform-tests/server-timing/resources/parsing/19.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/2.js: Added. * web-platform-tests/server-timing/resources/parsing/2.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/20.js: Added. * web-platform-tests/server-timing/resources/parsing/20.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/21.js: Added. * web-platform-tests/server-timing/resources/parsing/21.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/22.js: Added. * web-platform-tests/server-timing/resources/parsing/22.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/23.js: Added. * web-platform-tests/server-timing/resources/parsing/23.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/24.js: Added. * web-platform-tests/server-timing/resources/parsing/24.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/25.js: Added. * web-platform-tests/server-timing/resources/parsing/25.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/26.js: Added. * web-platform-tests/server-timing/resources/parsing/26.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/27.js: Added. * web-platform-tests/server-timing/resources/parsing/27.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/28.js: Added. * web-platform-tests/server-timing/resources/parsing/28.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/29.js: Added. * web-platform-tests/server-timing/resources/parsing/29.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/3.js: Added. * web-platform-tests/server-timing/resources/parsing/3.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/30.js: Added. * web-platform-tests/server-timing/resources/parsing/30.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/31.js: Added. * web-platform-tests/server-timing/resources/parsing/31.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/32.js: Added. * web-platform-tests/server-timing/resources/parsing/32.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/33.js: Added. * web-platform-tests/server-timing/resources/parsing/33.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/34.js: Added. * web-platform-tests/server-timing/resources/parsing/34.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/35.js: Added. * web-platform-tests/server-timing/resources/parsing/35.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/36.js: Added. * web-platform-tests/server-timing/resources/parsing/36.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/37.js: Added. * web-platform-tests/server-timing/resources/parsing/37.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/38.js: Added. * web-platform-tests/server-timing/resources/parsing/38.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/39.js: Added. * web-platform-tests/server-timing/resources/parsing/39.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/4.js: Added. * web-platform-tests/server-timing/resources/parsing/4.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/40.js: Added. * web-platform-tests/server-timing/resources/parsing/40.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/41.js: Added. * web-platform-tests/server-timing/resources/parsing/41.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/42.js: Added. * web-platform-tests/server-timing/resources/parsing/42.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/43.js: Added. * web-platform-tests/server-timing/resources/parsing/43.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/44.js: Added. * web-platform-tests/server-timing/resources/parsing/44.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/45.js: Added. * web-platform-tests/server-timing/resources/parsing/45.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/46.js: Added. * web-platform-tests/server-timing/resources/parsing/46.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/47.js: Added. * web-platform-tests/server-timing/resources/parsing/47.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/48.js: Added. * web-platform-tests/server-timing/resources/parsing/48.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/49.js: Added. * web-platform-tests/server-timing/resources/parsing/49.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/5.js: Added. * web-platform-tests/server-timing/resources/parsing/5.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/50.js: Added. * web-platform-tests/server-timing/resources/parsing/50.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/51.js: Added. * web-platform-tests/server-timing/resources/parsing/51.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/52.js: Added. * web-platform-tests/server-timing/resources/parsing/52.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/53.js: Added. * web-platform-tests/server-timing/resources/parsing/53.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/54.js: Added. * web-platform-tests/server-timing/resources/parsing/54.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/55.js: Added. * web-platform-tests/server-timing/resources/parsing/55.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/56.js: Added. * web-platform-tests/server-timing/resources/parsing/56.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/57.js: Added. * web-platform-tests/server-timing/resources/parsing/57.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/58.js: Added. * web-platform-tests/server-timing/resources/parsing/58.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/59.js: Added. * web-platform-tests/server-timing/resources/parsing/59.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/6.js: Added. * web-platform-tests/server-timing/resources/parsing/6.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/60.js: Added. * web-platform-tests/server-timing/resources/parsing/60.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/61.js: Added. * web-platform-tests/server-timing/resources/parsing/61.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/62.js: Added. * web-platform-tests/server-timing/resources/parsing/62.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/63.js: Added. * web-platform-tests/server-timing/resources/parsing/63.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/64.js: Added. * web-platform-tests/server-timing/resources/parsing/64.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/65.js: Added. * web-platform-tests/server-timing/resources/parsing/65.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/66.js: Added. * web-platform-tests/server-timing/resources/parsing/66.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/67.js: Added. * web-platform-tests/server-timing/resources/parsing/67.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/68.js: Added. * web-platform-tests/server-timing/resources/parsing/68.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/69.js: Added. * web-platform-tests/server-timing/resources/parsing/69.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/7.js: Added. * web-platform-tests/server-timing/resources/parsing/7.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/70.js: Added. * web-platform-tests/server-timing/resources/parsing/70.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/71.js: Added. * web-platform-tests/server-timing/resources/parsing/71.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/72.js: Added. * web-platform-tests/server-timing/resources/parsing/72.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/73.js: Added. * web-platform-tests/server-timing/resources/parsing/73.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/74.js: Added. * web-platform-tests/server-timing/resources/parsing/74.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/75.js: Added. * web-platform-tests/server-timing/resources/parsing/75.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/76.js: Added. * web-platform-tests/server-timing/resources/parsing/76.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/77.js: Added. * web-platform-tests/server-timing/resources/parsing/77.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/78.js: Added. * web-platform-tests/server-timing/resources/parsing/78.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/79.js: Added. * web-platform-tests/server-timing/resources/parsing/79.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/8.js: Added. * web-platform-tests/server-timing/resources/parsing/8.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/80.js: Added. * web-platform-tests/server-timing/resources/parsing/80.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/81.js: Added. * web-platform-tests/server-timing/resources/parsing/81.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/82.js: Added. * web-platform-tests/server-timing/resources/parsing/82.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/83.js: Added. * web-platform-tests/server-timing/resources/parsing/83.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/9.js: Added. * web-platform-tests/server-timing/resources/parsing/9.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/w3c-import.log: Added. * web-platform-tests/server-timing/resources/w3c-import.log: Added. * web-platform-tests/server-timing/resource_timing_idl.html: Added. * web-platform-tests/server-timing/resource_timing_idl.https.html: Added. * web-platform-tests/server-timing/server_timing_header-parsing.html: Added. * web-platform-tests/server-timing/server_timing_header-parsing.https.html: Added. * web-platform-tests/server-timing/test_server_timing.html: Added. * web-platform-tests/server-timing/test_server_timing.html.sub.headers: Added. * web-platform-tests/server-timing/test_server_timing.https.html: Added. * web-platform-tests/server-timing/test_server_timing.https.html.sub.headers: Added. * web-platform-tests/server-timing/w3c-import.log: Added. Source/WebCore: * Sources.txt: Added references to HeaderFieldTokenizer.cpp, ServerTiming.cpp, and ServerTimingParser.cpp. * WebCore.xcodeproj/project.pbxproj: Added various files. * loader/HeaderFieldTokenizer.cpp: Added. (WebCore::HeaderFieldTokenizer::HeaderFieldTokenizer): Added class for tokenizing header values. (WebCore::HeaderFieldTokenizer::consume): Added method to consume a specified character. (WebCore::HeaderFieldTokenizer::consumeQuotedString): Added method to consume a quote-string. (WebCore::HeaderFieldTokenizer::consumeToken): Added a method to consume a token. (WebCore::HeaderFieldTokenizer::consumeTokenOrQuotedString): Added method to consume a quote-string or quote-string, depending on net character. (WebCore::HeaderFieldTokenizer::skipSpaces): Added method to skip whitespace. (WebCore::HeaderFieldTokenizer::consumeBeforeAnyCharMatch): Added method to advance the cursor up until any of a list of characters. * loader/HeaderFieldTokenizer.h: Added. * loader/HTTPHeaderField.cpp: Expose isTokenCharacter and isWhitespace. * loader/HTTPHeaderField.h: Expose isTokenCharacter and isWhitespace. * loader/PolicyChecker.cpp: Added #include so source compiled on my machine. * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::ResourceTiming): Added call to initServerTiming to parse the header. (WebCore::ResourceTiming::initServerTiming): Added method to parse the header. (WebCore::ResourceTiming::populateServerTiming): Added method to populate the server timing entries on a PerformanceResourceTiming object. (WebCore::ResourceTiming::isolatedCopy const): Added code to copy over the server timing entries. * loader/ResourceTiming.h: (WebCore::ResourceTiming::ResourceTiming): Accept collection of server timing entries in c'tor. * loader/ServerTiming.cpp: Added. (WebCore::ServerTiming::setParameter): Set named parameters, ignoring unrecognized or duplicates. (WebCore::ServerTiming::isolatedCopy const): Return a new pointer to the object. * loader/ServerTiming.h: Added. (WebCore::ServerTiming::ServerTiming): Added struct for the data needed by a server timing entry. (WebCore::ServerTiming::name const): Added name field of a server timing entry. (WebCore::ServerTiming::duration const): Added duration field of a server timing entry. (WebCore::ServerTiming::description const): Added description field of a server timing entry. * loader/ServerTimingParser.cpp: Added. (WebCore::ServerTimingParser::parseServerTiming): Parses the header generating a collection of server timing structs. * loader/ServerTimingParser.h: Added. * loader/WorkerThreadableLoader.h: Fix build. * page/Performance.cpp: (WebCore::Performance::addResourceTiming): Fixed a typo. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): Given a ResourceTiming object, populate our collection of PerformanceServerTiming objects. * page/PerformanceResourceTiming.h: Added serverTiming member and getter. * page/PerformanceResourceTiming.idl: Added serverTiming member to interface. * platform/network/HTTPHeaderNames.in: Added "Server-Timing" to the header enum. * platform/network/ResourceResponseBase.cpp: Added "Server-Timing" to isSafeCrossOriginResponseHeader whitelist. LayoutTests: * imported/w3c/web-platform-tests/server-timing/cross_origin-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/resource_timing_idl-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/resource_timing_idl.https-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/server_timing_header-parsing-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/server_timing_header-parsing.https-expected.txt: Added. Canonical link: https://commits.webkit.org/201126@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-15 19:24:30 +00:00
#include "ServerTimingParser.h"
Add Web API Statistics Collection https://bugs.webkit.org/show_bug.cgi?id=187773 <rdar://problem/44155162> Patch by Woodrow Wang <woodrow_wang@apple.com> on 2018-09-11 Reviewed by Brent Fulgham. Source/WebCore: Added data collection for web API statistics, specifically regarding the canvas, font loads, screen functions, and navigator functions. The data collection code is placed under a runtime enabled feature flag. The statistics are stored in a ResourceLoadStatistics object and written to a plist on disk. Added a new file CanvasActivityRecord.h and CanvasActivityRecord.cpp which includes a struct to keep track of HTML5 canvas element read and writes. Tests: http/tests/webAPIStatistics/canvas-read-and-write-data-collection.html http/tests/webAPIStatistics/font-load-data-collection.html http/tests/webAPIStatistics/navigator-functions-accessed-data-collection.html http/tests/webAPIStatistics/screen-functions-accessed-data-collection.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSFontFaceSource.cpp: (WebCore::CSSFontFaceSource::load): * css/CSSFontSelector.cpp: (WebCore::CSSFontSelector::fontRangesForFamily): (WebCore::CSSFontSelector::fallbackFontAt): The following are the functions where we'd like to record a canvas read. * html/HTMLCanvasElement.cpp: (WebCore::HTMLCanvasElement::toDataURL): (WebCore::HTMLCanvasElement::toBlob): (WebCore::HTMLCanvasElement::getImageData): (WebCore::HTMLCanvasElement::toMediaSample): (WebCore::HTMLCanvasElement::captureStream): The following are the functions where we'd like to record a canvas write. * html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::measureText): (WebCore::CanvasRenderingContext2D::drawTextInternal): The following files and functions handle the CanvasActivityRecord struct and its respective functions. * loader/CanvasActivityRecord.cpp: Added. (WebCore::CanvasActivityRecord::recordWrittenOrMeasuredText): (WebCore::CanvasActivityRecord::mergeWith): * loader/CanvasActivityRecord.h: Added. (WebCore::CanvasActivityRecord::encode const): (WebCore::CanvasActivityRecord::decode): * loader/DocumentThreadableLoader.cpp: * loader/FrameLoader.cpp: * loader/ResourceLoadObserver.cpp: (WebCore::ResourceLoadObserver::logFontLoad): (WebCore::ResourceLoadObserver::logCanvasRead): (WebCore::ResourceLoadObserver::logCanvasWriteOrMeasure): (WebCore::ResourceLoadObserver::logNavigatorAPIAccessed): (WebCore::ResourceLoadObserver::logScreenAPIAccessed): Before, entries in the ResourceLoadStatistics involving HashSets used "origin" as the key. Now the encodeHashSet function has been generalized to take any key to encode the entries in the HashSet. Also added functionality to encode an OptionSet by converting it to its raw bitmask state. * loader/ResourceLoadObserver.h: * loader/ResourceLoadStatistics.cpp: (WebCore::encodeHashSet): (WebCore::encodeOriginHashSet): (WebCore::encodeOptionSet): (WebCore::encodeFontHashSet): (WebCore::encodeCanvasActivityRecord): (WebCore::ResourceLoadStatistics::encode const): (WebCore::decodeHashSet): (WebCore::decodeOriginHashSet): (WebCore::decodeOptionSet): (WebCore::decodeFontHashSet): (WebCore::decodeCanvasActivityRecord): (WebCore::ResourceLoadStatistics::decode): (WebCore::navigatorAPIEnumToString): (WebCore::screenAPIEnumToString): (WebCore::appendNavigatorAPIOptionSet): (WebCore::appendScreenAPIOptionSet): (WebCore::ResourceLoadStatistics::toString const): (WebCore::ResourceLoadStatistics::merge): * loader/ResourceLoadStatistics.h: * loader/ResourceTiming.cpp: The following are the navigator functions recorded for the web API statistics. * page/Navigator.cpp: (WebCore::Navigator::appVersion const): (WebCore::Navigator::userAgent const): (WebCore::Navigator::plugins): (WebCore::Navigator::mimeTypes): (WebCore::Navigator::cookieEnabled const): (WebCore::Navigator::javaEnabled const): The following are the screen functions recorded for the web API statistics. * page/Screen.cpp: (WebCore::Screen::height const): (WebCore::Screen::width const): (WebCore::Screen::colorDepth const): (WebCore::Screen::pixelDepth const): (WebCore::Screen::availLeft const): (WebCore::Screen::availTop const): (WebCore::Screen::availHeight const): (WebCore::Screen::availWidth const): Source/WebKit: * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<ResourceLoadStatistics>::encode): (IPC::ArgumentCoder<ResourceLoadStatistics>::decode): * UIProcess/ResourceLoadStatisticsMemoryStore.cpp: LayoutTests: Added new tests and expectations for the web API statistics data collection. * TestExpectations: * http/tests/webAPIStatistics/canvas-read-and-write-data-collection-expected.txt: Added. * http/tests/webAPIStatistics/canvas-read-and-write-data-collection.html: Added. * http/tests/webAPIStatistics/font-load-data-collection-expected.txt: Added. * http/tests/webAPIStatistics/font-load-data-collection.html: Added. * http/tests/webAPIStatistics/navigator-functions-accessed-data-collection-expected.txt: Added. * http/tests/webAPIStatistics/navigator-functions-accessed-data-collection.html: Added. * http/tests/webAPIStatistics/screen-functions-accessed-data-collection-expected.txt: Added. * http/tests/webAPIStatistics/screen-functions-accessed-data-collection.html: Added. * platform/ios-wk2/TestExpectations: * platform/mac-wk2/TestExpectations: Canonical link: https://commits.webkit.org/204480@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235897 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-11 17:14:07 +00:00
#include <wtf/CrossThreadCopier.h>
[Resource Timing] Support Resource Timing in Workers https://bugs.webkit.org/show_bug.cgi?id=168086 <rdar://problem/30430117> Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/idlharness-expected.txt: * web-platform-tests/resource-timing/resource-timing-expected.txt: * web-platform-tests/resource-timing/resource_cached-expected.txt: * web-platform-tests/resource-timing/resource_connection_reuse-expected.txt: Progressions. * web-platform-tests/resource-timing/resources/data.json: Added. * web-platform-tests/resource-timing/resources/rt-iframe-1.html: Added. * web-platform-tests/resource-timing/resources/rt-iframe-2.html: Added. * web-platform-tests/resource-timing/resources/rt-module.js: Added. * web-platform-tests/resource-timing/resources/rt-sub-module.js: Added. * web-platform-tests/resource-timing/resources/rt-utilities.js: Added. * web-platform-tests/resource-timing/resources/rt-worker-resources.js: Added. New Resources. * web-platform-tests/resource-timing/rt-cors-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.html: Added. * web-platform-tests/resource-timing/rt-cors.js: Added. * web-platform-tests/resource-timing/rt-cors.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.worker.html: Added. * web-platform-tests/resource-timing/rt-cors.worker.js: Added. Tests for redirects and cross origin data hiding. * web-platform-tests/resource-timing/rt-initiatorType-css-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-css.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-element-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-element.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.js: Added. * web-platform-tests/resource-timing/rt-initiatorType-other-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-other.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.js: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.html: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.js: Added. Tests for producing different initiator types. * web-platform-tests/resource-timing/rt-initiatorType-media-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-media.html: Added. We currently fail these tests, so they are marked as fail. * web-platform-tests/resource-timing/rt-performance-extensions-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.js: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.js: Added. Tests for the new Performance APIs. * web-platform-tests/resource-timing/rt-serialization-expected.txt: Added. * web-platform-tests/resource-timing/rt-serialization.html: Added. Tests for JSON serialization. * web-platform-tests/resource-timing/rt-resource-errors-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-errors.html: Added. * web-platform-tests/resource-timing/rt-resource-ignored-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-ignored.html: Added. Tests for when PerformanceResourceTiming entries should not be included. * web-platform-tests/resource-timing/rt-resources-per-frame-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-frame.html: Added. * web-platform-tests/resource-timing/rt-resources-per-worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-worker.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers.html: Added. Tests for different entries in different contexts. * web-platform-tests/serve: Make executable. Source/WebCore: Worker's load resources through the Document that loaded them. However, their PerformanceResourceTiming entries should be added to the Performance object inside the Worker context, not the Document's context. This change adds an InitiatorContext to ResourceLoadOptions so that loaders can determine if the load was initiated by the Document or a Worker. This allows loaders to then know if the ResourceTiming data they collect should be added to the Document's Performance object or forwarded on to the Worker's. This adds a new ThreadableLoaderClient method intended only for the purpose of adding the ResourceTiming information to the Worker's Performance object. Unlike other ThreadableLoaderClient methods that are bridged and forwarded on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this method never needs to be handled by clients and can be uniformly handled by the WorkerThreadableLoader itself. We also add a new ResourceTiming object that encapsulates all of the data ultimately needed for a PerformanceResourceTimingEntry object. This allows for all of the information to be gathered while loading on the Document before serializing across to the Worker. That includes the Timing-Allow-Origin check which uses the SecurityOrigin of the Worker. This also modernizes and addresses issues in the Resource Timing implementation. Better handling cases like loading from the Cache, Synchronous Loads, and improving initiatorType information. Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html imported/w3c/web-platform-tests/resource-timing/rt-serialization.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html performance-api/resource-timing-apis.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: New files. * platform/network/NetworkLoadTiming.h: (WebCore::NetworkLoadTiming::reset): Deleted. We no longer need to reset. * loader/ResourceTiming.cpp: Added. (WebCore::passesTimingAllowCheck): (WebCore::ResourceTiming::fromCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: Added. (WebCore::ResourceTiming::url): (WebCore::ResourceTiming::initiator): (WebCore::ResourceTiming::loadTiming): (WebCore::ResourceTiming::networkLoadTiming): (WebCore::ResourceTiming::allowTimingDetails): (WebCore::ResourceTiming::overrideInitiatorName): (WebCore::ResourceTiming::ResourceTiming): Class that encapsulates all of the data needed for a PerformanceResourceTiming entry. There are three static constructors indicating the different ways this object can be constructed and the different data available at the time of construction. * loader/ResourceLoaderOptions.h: Add the new InitiatorContext, default to Document. * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishTiming): New client method only used by WorkerThreadableLoader. * loader/WorkerThreadableLoader.h: * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming): All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker. Add timing information to the Performance object when received. No need to inform clients. * loader/DocumentThreadableLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad): (WebCore::DocumentThreadableLoader::loadRequest): Provide APIs to pass timing data on to a WorkerThreadableLoader. Create ResourceTiming data for synchronous loads. * loader/LoadTiming.h: * loader/LoadTiming.cpp: (WebCore::LoadTiming::isolatedCopy): Add isolatedCopy to allow this data to be passed across to a Worker. * loader/ResourceTimingInformation.h: * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): (WebCore::ResourceTimingInformation::addResourceTiming): (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Refactor to remove unused / unnecessary bits. Extract out some helpful code. Changed this to match when Blink decides when to add or ignore entries, however this may change over time. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::notifyDone): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::finishedTimingForWorkerLoad): * loader/cache/CachedRawResource.h: * loader/cache/CachedRawResourceClient.h: (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad): Plumbing to report timing information to Worker if this resource was loaded for a Worker. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): * loader/cache/CachedResource.h: (WebCore::CachedResource::initiatorName): Store the initiator name on the CachedResource like other data added to the original CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and cleans up other hacks that worked around this later on. * loader/cache/CachedResourceLoader.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::revalidateResource): (WebCore::CachedResourceLoader::loadResource): Simply the creation of a ResourceTiming object for cache hits. Report timing information to Worker if this resource was loaded for a Worker. (WebCore::CachedResourceLoader::loadDone): Eliminate this redundant point attempting to add a ResourceTiming entry. * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName): Update to match the spec. The fallback is "other". * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::setResourceTimingBufferSize): (WebCore::Performance::addResourceTiming): Update to support PerformanceObservers. Update to match spec (event should bubble). * page/PerformanceResourceTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::create): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::fetchStart): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): Construct with a ResourceTiming object containing all the data we need for the entry. Update to match spec for what is required, should fallback, should be zero, etc. (WebCore::passesTimingAllowCheck): Deleted. Extracted this to ResourceTiming creation time in the loading context, since this can't be determined on the Worker context without also having all of the header information from each resource response. * page/PerformanceResourceTiming.idl: Expose to Workers! LayoutTests: * TestExpectations: Pre-emptively mark some tests as flakey that have seen flakiness. * platform/mac/TestExpectations: Skip some tests on ElCapitan because the network timing numbers appear incorrect. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: PerformanceResourceTiming is now available in Workers. * performance-api/resource-timing-apis-expected.txt: Added. * performance-api/resource-timing-apis.html: Added. * performance-api/resources/resource-timing-api.js: Added. Basic API test. We expect to fail nextHopProtocol and size properties right now. Canonical link: https://commits.webkit.org/185464@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-16 19:18:32 +00:00
namespace WebCore {
Resource Timing: Duration is 0 in many cases https://bugs.webkit.org/show_bug.cgi?id=225737 Reviewed by Chris Dumez. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/cors-preflight.any-expected.txt: * web-platform-tests/resource-timing/crossorigin-sandwich-no-TAO.sub-expected.txt: * web-platform-tests/resource-timing/crossorigin-sandwich-partial-TAO.sub-expected.txt: * web-platform-tests/resource-timing/resource_timing_cross_origin_redirect_chain-expected.txt: * web-platform-tests/resource-timing/status-codes-create-entry-expected.txt: Source/WebCore: This fixes two problems with our PerformanceResourceTiming implementation: 1. ResourceTimingInformation::shouldAddResourceTiming wasn't adding timing data if CachedResource::errorOccurred returned true, which includes when the server responds with an HTTP 404. We want loadFailedOrCanceled instead, which only returns true if there's a network error or if the load is cancelled. This matches the behavior of other browsers. 2. ResourceTiming::fromMemoryCache was assuming that it never had network information to report because we pulled from the cache, not the network. However, a common case is that HTMLPreloadScanner::scan calls HTMLResourcePreloader::preload which loads the resource while the HTML parser is blocked on loading scripts or other things, then CachedResourceLoader::requestResource pulls it out of the memory cache. In this case, use the network metrics that we are already storing if it's the first time we are pulling this resource out of the memory cache. After that, 0 load time is quite accurate. Covered by newly passing Web Platform Tests, which Chrome and Firefox already passed. * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::initServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::ResourceTiming): * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): * loader/cache/CachedResource.h: (WebCore::CachedResource::takeNetworkLoadMetrics): * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * platform/network/ResourceResponseBase.h: (WebCore::ResourceResponseBase::deprecatedNetworkLoadMetricsOrNull const): (WebCore::ResourceResponseBase::takeNetworkLoadMetrics): Canonical link: https://commits.webkit.org/240569@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281110 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-16 21:43:02 +00:00
ResourceTiming ResourceTiming::fromMemoryCache(const URL& url, const String& initiator, const ResourceLoadTiming& loadTiming, const ResourceResponse& response, const NetworkLoadMetrics& networkLoadMetrics, const SecurityOrigin& securityOrigin)
[Resource Timing] Support Resource Timing in Workers https://bugs.webkit.org/show_bug.cgi?id=168086 <rdar://problem/30430117> Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/idlharness-expected.txt: * web-platform-tests/resource-timing/resource-timing-expected.txt: * web-platform-tests/resource-timing/resource_cached-expected.txt: * web-platform-tests/resource-timing/resource_connection_reuse-expected.txt: Progressions. * web-platform-tests/resource-timing/resources/data.json: Added. * web-platform-tests/resource-timing/resources/rt-iframe-1.html: Added. * web-platform-tests/resource-timing/resources/rt-iframe-2.html: Added. * web-platform-tests/resource-timing/resources/rt-module.js: Added. * web-platform-tests/resource-timing/resources/rt-sub-module.js: Added. * web-platform-tests/resource-timing/resources/rt-utilities.js: Added. * web-platform-tests/resource-timing/resources/rt-worker-resources.js: Added. New Resources. * web-platform-tests/resource-timing/rt-cors-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.html: Added. * web-platform-tests/resource-timing/rt-cors.js: Added. * web-platform-tests/resource-timing/rt-cors.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.worker.html: Added. * web-platform-tests/resource-timing/rt-cors.worker.js: Added. Tests for redirects and cross origin data hiding. * web-platform-tests/resource-timing/rt-initiatorType-css-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-css.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-element-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-element.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.js: Added. * web-platform-tests/resource-timing/rt-initiatorType-other-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-other.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.js: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.html: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.js: Added. Tests for producing different initiator types. * web-platform-tests/resource-timing/rt-initiatorType-media-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-media.html: Added. We currently fail these tests, so they are marked as fail. * web-platform-tests/resource-timing/rt-performance-extensions-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.js: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.js: Added. Tests for the new Performance APIs. * web-platform-tests/resource-timing/rt-serialization-expected.txt: Added. * web-platform-tests/resource-timing/rt-serialization.html: Added. Tests for JSON serialization. * web-platform-tests/resource-timing/rt-resource-errors-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-errors.html: Added. * web-platform-tests/resource-timing/rt-resource-ignored-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-ignored.html: Added. Tests for when PerformanceResourceTiming entries should not be included. * web-platform-tests/resource-timing/rt-resources-per-frame-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-frame.html: Added. * web-platform-tests/resource-timing/rt-resources-per-worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-worker.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers.html: Added. Tests for different entries in different contexts. * web-platform-tests/serve: Make executable. Source/WebCore: Worker's load resources through the Document that loaded them. However, their PerformanceResourceTiming entries should be added to the Performance object inside the Worker context, not the Document's context. This change adds an InitiatorContext to ResourceLoadOptions so that loaders can determine if the load was initiated by the Document or a Worker. This allows loaders to then know if the ResourceTiming data they collect should be added to the Document's Performance object or forwarded on to the Worker's. This adds a new ThreadableLoaderClient method intended only for the purpose of adding the ResourceTiming information to the Worker's Performance object. Unlike other ThreadableLoaderClient methods that are bridged and forwarded on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this method never needs to be handled by clients and can be uniformly handled by the WorkerThreadableLoader itself. We also add a new ResourceTiming object that encapsulates all of the data ultimately needed for a PerformanceResourceTimingEntry object. This allows for all of the information to be gathered while loading on the Document before serializing across to the Worker. That includes the Timing-Allow-Origin check which uses the SecurityOrigin of the Worker. This also modernizes and addresses issues in the Resource Timing implementation. Better handling cases like loading from the Cache, Synchronous Loads, and improving initiatorType information. Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html imported/w3c/web-platform-tests/resource-timing/rt-serialization.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html performance-api/resource-timing-apis.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: New files. * platform/network/NetworkLoadTiming.h: (WebCore::NetworkLoadTiming::reset): Deleted. We no longer need to reset. * loader/ResourceTiming.cpp: Added. (WebCore::passesTimingAllowCheck): (WebCore::ResourceTiming::fromCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: Added. (WebCore::ResourceTiming::url): (WebCore::ResourceTiming::initiator): (WebCore::ResourceTiming::loadTiming): (WebCore::ResourceTiming::networkLoadTiming): (WebCore::ResourceTiming::allowTimingDetails): (WebCore::ResourceTiming::overrideInitiatorName): (WebCore::ResourceTiming::ResourceTiming): Class that encapsulates all of the data needed for a PerformanceResourceTiming entry. There are three static constructors indicating the different ways this object can be constructed and the different data available at the time of construction. * loader/ResourceLoaderOptions.h: Add the new InitiatorContext, default to Document. * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishTiming): New client method only used by WorkerThreadableLoader. * loader/WorkerThreadableLoader.h: * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming): All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker. Add timing information to the Performance object when received. No need to inform clients. * loader/DocumentThreadableLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad): (WebCore::DocumentThreadableLoader::loadRequest): Provide APIs to pass timing data on to a WorkerThreadableLoader. Create ResourceTiming data for synchronous loads. * loader/LoadTiming.h: * loader/LoadTiming.cpp: (WebCore::LoadTiming::isolatedCopy): Add isolatedCopy to allow this data to be passed across to a Worker. * loader/ResourceTimingInformation.h: * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): (WebCore::ResourceTimingInformation::addResourceTiming): (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Refactor to remove unused / unnecessary bits. Extract out some helpful code. Changed this to match when Blink decides when to add or ignore entries, however this may change over time. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::notifyDone): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::finishedTimingForWorkerLoad): * loader/cache/CachedRawResource.h: * loader/cache/CachedRawResourceClient.h: (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad): Plumbing to report timing information to Worker if this resource was loaded for a Worker. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): * loader/cache/CachedResource.h: (WebCore::CachedResource::initiatorName): Store the initiator name on the CachedResource like other data added to the original CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and cleans up other hacks that worked around this later on. * loader/cache/CachedResourceLoader.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::revalidateResource): (WebCore::CachedResourceLoader::loadResource): Simply the creation of a ResourceTiming object for cache hits. Report timing information to Worker if this resource was loaded for a Worker. (WebCore::CachedResourceLoader::loadDone): Eliminate this redundant point attempting to add a ResourceTiming entry. * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName): Update to match the spec. The fallback is "other". * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::setResourceTimingBufferSize): (WebCore::Performance::addResourceTiming): Update to support PerformanceObservers. Update to match spec (event should bubble). * page/PerformanceResourceTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::create): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::fetchStart): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): Construct with a ResourceTiming object containing all the data we need for the entry. Update to match spec for what is required, should fallback, should be zero, etc. (WebCore::passesTimingAllowCheck): Deleted. Extracted this to ResourceTiming creation time in the loading context, since this can't be determined on the Worker context without also having all of the header information from each resource response. * page/PerformanceResourceTiming.idl: Expose to Workers! LayoutTests: * TestExpectations: Pre-emptively mark some tests as flakey that have seen flakiness. * platform/mac/TestExpectations: Skip some tests on ElCapitan because the network timing numbers appear incorrect. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: PerformanceResourceTiming is now available in Workers. * performance-api/resource-timing-apis-expected.txt: Added. * performance-api/resource-timing-apis.html: Added. * performance-api/resources/resource-timing-api.js: Added. Basic API test. We expect to fail nextHopProtocol and size properties right now. Canonical link: https://commits.webkit.org/185464@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-16 19:18:32 +00:00
{
Resource Timing: Duration is 0 in many cases https://bugs.webkit.org/show_bug.cgi?id=225737 Reviewed by Chris Dumez. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/cors-preflight.any-expected.txt: * web-platform-tests/resource-timing/crossorigin-sandwich-no-TAO.sub-expected.txt: * web-platform-tests/resource-timing/crossorigin-sandwich-partial-TAO.sub-expected.txt: * web-platform-tests/resource-timing/resource_timing_cross_origin_redirect_chain-expected.txt: * web-platform-tests/resource-timing/status-codes-create-entry-expected.txt: Source/WebCore: This fixes two problems with our PerformanceResourceTiming implementation: 1. ResourceTimingInformation::shouldAddResourceTiming wasn't adding timing data if CachedResource::errorOccurred returned true, which includes when the server responds with an HTTP 404. We want loadFailedOrCanceled instead, which only returns true if there's a network error or if the load is cancelled. This matches the behavior of other browsers. 2. ResourceTiming::fromMemoryCache was assuming that it never had network information to report because we pulled from the cache, not the network. However, a common case is that HTMLPreloadScanner::scan calls HTMLResourcePreloader::preload which loads the resource while the HTML parser is blocked on loading scripts or other things, then CachedResourceLoader::requestResource pulls it out of the memory cache. In this case, use the network metrics that we are already storing if it's the first time we are pulling this resource out of the memory cache. After that, 0 load time is quite accurate. Covered by newly passing Web Platform Tests, which Chrome and Firefox already passed. * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromMemoryCache): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::initServerTiming): Deleted. * loader/ResourceTiming.h: (WebCore::ResourceTiming::ResourceTiming): * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): * loader/cache/CachedResource.h: (WebCore::CachedResource::takeNetworkLoadMetrics): * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * platform/network/ResourceResponseBase.h: (WebCore::ResourceResponseBase::deprecatedNetworkLoadMetricsOrNull const): (WebCore::ResourceResponseBase::takeNetworkLoadMetrics): Canonical link: https://commits.webkit.org/240569@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281110 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-16 21:43:02 +00:00
return ResourceTiming(url, initiator, loadTiming, networkLoadMetrics, response, securityOrigin);
[Resource Timing] Support Resource Timing in Workers https://bugs.webkit.org/show_bug.cgi?id=168086 <rdar://problem/30430117> Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/idlharness-expected.txt: * web-platform-tests/resource-timing/resource-timing-expected.txt: * web-platform-tests/resource-timing/resource_cached-expected.txt: * web-platform-tests/resource-timing/resource_connection_reuse-expected.txt: Progressions. * web-platform-tests/resource-timing/resources/data.json: Added. * web-platform-tests/resource-timing/resources/rt-iframe-1.html: Added. * web-platform-tests/resource-timing/resources/rt-iframe-2.html: Added. * web-platform-tests/resource-timing/resources/rt-module.js: Added. * web-platform-tests/resource-timing/resources/rt-sub-module.js: Added. * web-platform-tests/resource-timing/resources/rt-utilities.js: Added. * web-platform-tests/resource-timing/resources/rt-worker-resources.js: Added. New Resources. * web-platform-tests/resource-timing/rt-cors-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.html: Added. * web-platform-tests/resource-timing/rt-cors.js: Added. * web-platform-tests/resource-timing/rt-cors.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.worker.html: Added. * web-platform-tests/resource-timing/rt-cors.worker.js: Added. Tests for redirects and cross origin data hiding. * web-platform-tests/resource-timing/rt-initiatorType-css-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-css.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-element-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-element.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.js: Added. * web-platform-tests/resource-timing/rt-initiatorType-other-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-other.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.js: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.html: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.js: Added. Tests for producing different initiator types. * web-platform-tests/resource-timing/rt-initiatorType-media-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-media.html: Added. We currently fail these tests, so they are marked as fail. * web-platform-tests/resource-timing/rt-performance-extensions-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.js: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.js: Added. Tests for the new Performance APIs. * web-platform-tests/resource-timing/rt-serialization-expected.txt: Added. * web-platform-tests/resource-timing/rt-serialization.html: Added. Tests for JSON serialization. * web-platform-tests/resource-timing/rt-resource-errors-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-errors.html: Added. * web-platform-tests/resource-timing/rt-resource-ignored-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-ignored.html: Added. Tests for when PerformanceResourceTiming entries should not be included. * web-platform-tests/resource-timing/rt-resources-per-frame-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-frame.html: Added. * web-platform-tests/resource-timing/rt-resources-per-worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-worker.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers.html: Added. Tests for different entries in different contexts. * web-platform-tests/serve: Make executable. Source/WebCore: Worker's load resources through the Document that loaded them. However, their PerformanceResourceTiming entries should be added to the Performance object inside the Worker context, not the Document's context. This change adds an InitiatorContext to ResourceLoadOptions so that loaders can determine if the load was initiated by the Document or a Worker. This allows loaders to then know if the ResourceTiming data they collect should be added to the Document's Performance object or forwarded on to the Worker's. This adds a new ThreadableLoaderClient method intended only for the purpose of adding the ResourceTiming information to the Worker's Performance object. Unlike other ThreadableLoaderClient methods that are bridged and forwarded on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this method never needs to be handled by clients and can be uniformly handled by the WorkerThreadableLoader itself. We also add a new ResourceTiming object that encapsulates all of the data ultimately needed for a PerformanceResourceTimingEntry object. This allows for all of the information to be gathered while loading on the Document before serializing across to the Worker. That includes the Timing-Allow-Origin check which uses the SecurityOrigin of the Worker. This also modernizes and addresses issues in the Resource Timing implementation. Better handling cases like loading from the Cache, Synchronous Loads, and improving initiatorType information. Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html imported/w3c/web-platform-tests/resource-timing/rt-serialization.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html performance-api/resource-timing-apis.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: New files. * platform/network/NetworkLoadTiming.h: (WebCore::NetworkLoadTiming::reset): Deleted. We no longer need to reset. * loader/ResourceTiming.cpp: Added. (WebCore::passesTimingAllowCheck): (WebCore::ResourceTiming::fromCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: Added. (WebCore::ResourceTiming::url): (WebCore::ResourceTiming::initiator): (WebCore::ResourceTiming::loadTiming): (WebCore::ResourceTiming::networkLoadTiming): (WebCore::ResourceTiming::allowTimingDetails): (WebCore::ResourceTiming::overrideInitiatorName): (WebCore::ResourceTiming::ResourceTiming): Class that encapsulates all of the data needed for a PerformanceResourceTiming entry. There are three static constructors indicating the different ways this object can be constructed and the different data available at the time of construction. * loader/ResourceLoaderOptions.h: Add the new InitiatorContext, default to Document. * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishTiming): New client method only used by WorkerThreadableLoader. * loader/WorkerThreadableLoader.h: * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming): All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker. Add timing information to the Performance object when received. No need to inform clients. * loader/DocumentThreadableLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad): (WebCore::DocumentThreadableLoader::loadRequest): Provide APIs to pass timing data on to a WorkerThreadableLoader. Create ResourceTiming data for synchronous loads. * loader/LoadTiming.h: * loader/LoadTiming.cpp: (WebCore::LoadTiming::isolatedCopy): Add isolatedCopy to allow this data to be passed across to a Worker. * loader/ResourceTimingInformation.h: * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): (WebCore::ResourceTimingInformation::addResourceTiming): (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Refactor to remove unused / unnecessary bits. Extract out some helpful code. Changed this to match when Blink decides when to add or ignore entries, however this may change over time. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::notifyDone): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::finishedTimingForWorkerLoad): * loader/cache/CachedRawResource.h: * loader/cache/CachedRawResourceClient.h: (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad): Plumbing to report timing information to Worker if this resource was loaded for a Worker. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): * loader/cache/CachedResource.h: (WebCore::CachedResource::initiatorName): Store the initiator name on the CachedResource like other data added to the original CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and cleans up other hacks that worked around this later on. * loader/cache/CachedResourceLoader.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::revalidateResource): (WebCore::CachedResourceLoader::loadResource): Simply the creation of a ResourceTiming object for cache hits. Report timing information to Worker if this resource was loaded for a Worker. (WebCore::CachedResourceLoader::loadDone): Eliminate this redundant point attempting to add a ResourceTiming entry. * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName): Update to match the spec. The fallback is "other". * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::setResourceTimingBufferSize): (WebCore::Performance::addResourceTiming): Update to support PerformanceObservers. Update to match spec (event should bubble). * page/PerformanceResourceTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::create): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::fetchStart): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): Construct with a ResourceTiming object containing all the data we need for the entry. Update to match spec for what is required, should fallback, should be zero, etc. (WebCore::passesTimingAllowCheck): Deleted. Extracted this to ResourceTiming creation time in the loading context, since this can't be determined on the Worker context without also having all of the header information from each resource response. * page/PerformanceResourceTiming.idl: Expose to Workers! LayoutTests: * TestExpectations: Pre-emptively mark some tests as flakey that have seen flakiness. * platform/mac/TestExpectations: Skip some tests on ElCapitan because the network timing numbers appear incorrect. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: PerformanceResourceTiming is now available in Workers. * performance-api/resource-timing-apis-expected.txt: Added. * performance-api/resource-timing-apis.html: Added. * performance-api/resources/resource-timing-api.js: Added. Basic API test. We expect to fail nextHopProtocol and size properties right now. Canonical link: https://commits.webkit.org/185464@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-16 19:18:32 +00:00
}
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
ResourceTiming ResourceTiming::fromLoad(CachedResource& resource, const URL& url, const String& initiator, const ResourceLoadTiming& loadTiming, const NetworkLoadMetrics& networkLoadMetrics, const SecurityOrigin& securityOrigin)
[Resource Timing] Support Resource Timing in Workers https://bugs.webkit.org/show_bug.cgi?id=168086 <rdar://problem/30430117> Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/idlharness-expected.txt: * web-platform-tests/resource-timing/resource-timing-expected.txt: * web-platform-tests/resource-timing/resource_cached-expected.txt: * web-platform-tests/resource-timing/resource_connection_reuse-expected.txt: Progressions. * web-platform-tests/resource-timing/resources/data.json: Added. * web-platform-tests/resource-timing/resources/rt-iframe-1.html: Added. * web-platform-tests/resource-timing/resources/rt-iframe-2.html: Added. * web-platform-tests/resource-timing/resources/rt-module.js: Added. * web-platform-tests/resource-timing/resources/rt-sub-module.js: Added. * web-platform-tests/resource-timing/resources/rt-utilities.js: Added. * web-platform-tests/resource-timing/resources/rt-worker-resources.js: Added. New Resources. * web-platform-tests/resource-timing/rt-cors-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.html: Added. * web-platform-tests/resource-timing/rt-cors.js: Added. * web-platform-tests/resource-timing/rt-cors.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.worker.html: Added. * web-platform-tests/resource-timing/rt-cors.worker.js: Added. Tests for redirects and cross origin data hiding. * web-platform-tests/resource-timing/rt-initiatorType-css-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-css.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-element-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-element.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.js: Added. * web-platform-tests/resource-timing/rt-initiatorType-other-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-other.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.js: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.html: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.js: Added. Tests for producing different initiator types. * web-platform-tests/resource-timing/rt-initiatorType-media-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-media.html: Added. We currently fail these tests, so they are marked as fail. * web-platform-tests/resource-timing/rt-performance-extensions-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.js: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.js: Added. Tests for the new Performance APIs. * web-platform-tests/resource-timing/rt-serialization-expected.txt: Added. * web-platform-tests/resource-timing/rt-serialization.html: Added. Tests for JSON serialization. * web-platform-tests/resource-timing/rt-resource-errors-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-errors.html: Added. * web-platform-tests/resource-timing/rt-resource-ignored-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-ignored.html: Added. Tests for when PerformanceResourceTiming entries should not be included. * web-platform-tests/resource-timing/rt-resources-per-frame-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-frame.html: Added. * web-platform-tests/resource-timing/rt-resources-per-worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-worker.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers.html: Added. Tests for different entries in different contexts. * web-platform-tests/serve: Make executable. Source/WebCore: Worker's load resources through the Document that loaded them. However, their PerformanceResourceTiming entries should be added to the Performance object inside the Worker context, not the Document's context. This change adds an InitiatorContext to ResourceLoadOptions so that loaders can determine if the load was initiated by the Document or a Worker. This allows loaders to then know if the ResourceTiming data they collect should be added to the Document's Performance object or forwarded on to the Worker's. This adds a new ThreadableLoaderClient method intended only for the purpose of adding the ResourceTiming information to the Worker's Performance object. Unlike other ThreadableLoaderClient methods that are bridged and forwarded on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this method never needs to be handled by clients and can be uniformly handled by the WorkerThreadableLoader itself. We also add a new ResourceTiming object that encapsulates all of the data ultimately needed for a PerformanceResourceTimingEntry object. This allows for all of the information to be gathered while loading on the Document before serializing across to the Worker. That includes the Timing-Allow-Origin check which uses the SecurityOrigin of the Worker. This also modernizes and addresses issues in the Resource Timing implementation. Better handling cases like loading from the Cache, Synchronous Loads, and improving initiatorType information. Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html imported/w3c/web-platform-tests/resource-timing/rt-serialization.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html performance-api/resource-timing-apis.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: New files. * platform/network/NetworkLoadTiming.h: (WebCore::NetworkLoadTiming::reset): Deleted. We no longer need to reset. * loader/ResourceTiming.cpp: Added. (WebCore::passesTimingAllowCheck): (WebCore::ResourceTiming::fromCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: Added. (WebCore::ResourceTiming::url): (WebCore::ResourceTiming::initiator): (WebCore::ResourceTiming::loadTiming): (WebCore::ResourceTiming::networkLoadTiming): (WebCore::ResourceTiming::allowTimingDetails): (WebCore::ResourceTiming::overrideInitiatorName): (WebCore::ResourceTiming::ResourceTiming): Class that encapsulates all of the data needed for a PerformanceResourceTiming entry. There are three static constructors indicating the different ways this object can be constructed and the different data available at the time of construction. * loader/ResourceLoaderOptions.h: Add the new InitiatorContext, default to Document. * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishTiming): New client method only used by WorkerThreadableLoader. * loader/WorkerThreadableLoader.h: * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming): All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker. Add timing information to the Performance object when received. No need to inform clients. * loader/DocumentThreadableLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad): (WebCore::DocumentThreadableLoader::loadRequest): Provide APIs to pass timing data on to a WorkerThreadableLoader. Create ResourceTiming data for synchronous loads. * loader/LoadTiming.h: * loader/LoadTiming.cpp: (WebCore::LoadTiming::isolatedCopy): Add isolatedCopy to allow this data to be passed across to a Worker. * loader/ResourceTimingInformation.h: * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): (WebCore::ResourceTimingInformation::addResourceTiming): (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Refactor to remove unused / unnecessary bits. Extract out some helpful code. Changed this to match when Blink decides when to add or ignore entries, however this may change over time. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::notifyDone): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::finishedTimingForWorkerLoad): * loader/cache/CachedRawResource.h: * loader/cache/CachedRawResourceClient.h: (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad): Plumbing to report timing information to Worker if this resource was loaded for a Worker. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): * loader/cache/CachedResource.h: (WebCore::CachedResource::initiatorName): Store the initiator name on the CachedResource like other data added to the original CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and cleans up other hacks that worked around this later on. * loader/cache/CachedResourceLoader.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::revalidateResource): (WebCore::CachedResourceLoader::loadResource): Simply the creation of a ResourceTiming object for cache hits. Report timing information to Worker if this resource was loaded for a Worker. (WebCore::CachedResourceLoader::loadDone): Eliminate this redundant point attempting to add a ResourceTiming entry. * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName): Update to match the spec. The fallback is "other". * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::setResourceTimingBufferSize): (WebCore::Performance::addResourceTiming): Update to support PerformanceObservers. Update to match spec (event should bubble). * page/PerformanceResourceTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::create): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::fetchStart): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): Construct with a ResourceTiming object containing all the data we need for the entry. Update to match spec for what is required, should fallback, should be zero, etc. (WebCore::passesTimingAllowCheck): Deleted. Extracted this to ResourceTiming creation time in the loading context, since this can't be determined on the Worker context without also having all of the header information from each resource response. * page/PerformanceResourceTiming.idl: Expose to Workers! LayoutTests: * TestExpectations: Pre-emptively mark some tests as flakey that have seen flakiness. * platform/mac/TestExpectations: Skip some tests on ElCapitan because the network timing numbers appear incorrect. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: PerformanceResourceTiming is now available in Workers. * performance-api/resource-timing-apis-expected.txt: Added. * performance-api/resource-timing-apis.html: Added. * performance-api/resources/resource-timing-api.js: Added. Basic API test. We expect to fail nextHopProtocol and size properties right now. Canonical link: https://commits.webkit.org/185464@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-16 19:18:32 +00:00
{
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 ResourceTiming(url, initiator, loadTiming, networkLoadMetrics, resource.response(), securityOrigin);
[Resource Timing] Support Resource Timing in Workers https://bugs.webkit.org/show_bug.cgi?id=168086 <rdar://problem/30430117> Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/idlharness-expected.txt: * web-platform-tests/resource-timing/resource-timing-expected.txt: * web-platform-tests/resource-timing/resource_cached-expected.txt: * web-platform-tests/resource-timing/resource_connection_reuse-expected.txt: Progressions. * web-platform-tests/resource-timing/resources/data.json: Added. * web-platform-tests/resource-timing/resources/rt-iframe-1.html: Added. * web-platform-tests/resource-timing/resources/rt-iframe-2.html: Added. * web-platform-tests/resource-timing/resources/rt-module.js: Added. * web-platform-tests/resource-timing/resources/rt-sub-module.js: Added. * web-platform-tests/resource-timing/resources/rt-utilities.js: Added. * web-platform-tests/resource-timing/resources/rt-worker-resources.js: Added. New Resources. * web-platform-tests/resource-timing/rt-cors-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.html: Added. * web-platform-tests/resource-timing/rt-cors.js: Added. * web-platform-tests/resource-timing/rt-cors.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.worker.html: Added. * web-platform-tests/resource-timing/rt-cors.worker.js: Added. Tests for redirects and cross origin data hiding. * web-platform-tests/resource-timing/rt-initiatorType-css-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-css.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-element-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-element.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.js: Added. * web-platform-tests/resource-timing/rt-initiatorType-other-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-other.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.js: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.html: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.js: Added. Tests for producing different initiator types. * web-platform-tests/resource-timing/rt-initiatorType-media-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-media.html: Added. We currently fail these tests, so they are marked as fail. * web-platform-tests/resource-timing/rt-performance-extensions-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.js: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.js: Added. Tests for the new Performance APIs. * web-platform-tests/resource-timing/rt-serialization-expected.txt: Added. * web-platform-tests/resource-timing/rt-serialization.html: Added. Tests for JSON serialization. * web-platform-tests/resource-timing/rt-resource-errors-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-errors.html: Added. * web-platform-tests/resource-timing/rt-resource-ignored-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-ignored.html: Added. Tests for when PerformanceResourceTiming entries should not be included. * web-platform-tests/resource-timing/rt-resources-per-frame-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-frame.html: Added. * web-platform-tests/resource-timing/rt-resources-per-worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-worker.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers.html: Added. Tests for different entries in different contexts. * web-platform-tests/serve: Make executable. Source/WebCore: Worker's load resources through the Document that loaded them. However, their PerformanceResourceTiming entries should be added to the Performance object inside the Worker context, not the Document's context. This change adds an InitiatorContext to ResourceLoadOptions so that loaders can determine if the load was initiated by the Document or a Worker. This allows loaders to then know if the ResourceTiming data they collect should be added to the Document's Performance object or forwarded on to the Worker's. This adds a new ThreadableLoaderClient method intended only for the purpose of adding the ResourceTiming information to the Worker's Performance object. Unlike other ThreadableLoaderClient methods that are bridged and forwarded on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this method never needs to be handled by clients and can be uniformly handled by the WorkerThreadableLoader itself. We also add a new ResourceTiming object that encapsulates all of the data ultimately needed for a PerformanceResourceTimingEntry object. This allows for all of the information to be gathered while loading on the Document before serializing across to the Worker. That includes the Timing-Allow-Origin check which uses the SecurityOrigin of the Worker. This also modernizes and addresses issues in the Resource Timing implementation. Better handling cases like loading from the Cache, Synchronous Loads, and improving initiatorType information. Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html imported/w3c/web-platform-tests/resource-timing/rt-serialization.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html performance-api/resource-timing-apis.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: New files. * platform/network/NetworkLoadTiming.h: (WebCore::NetworkLoadTiming::reset): Deleted. We no longer need to reset. * loader/ResourceTiming.cpp: Added. (WebCore::passesTimingAllowCheck): (WebCore::ResourceTiming::fromCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: Added. (WebCore::ResourceTiming::url): (WebCore::ResourceTiming::initiator): (WebCore::ResourceTiming::loadTiming): (WebCore::ResourceTiming::networkLoadTiming): (WebCore::ResourceTiming::allowTimingDetails): (WebCore::ResourceTiming::overrideInitiatorName): (WebCore::ResourceTiming::ResourceTiming): Class that encapsulates all of the data needed for a PerformanceResourceTiming entry. There are three static constructors indicating the different ways this object can be constructed and the different data available at the time of construction. * loader/ResourceLoaderOptions.h: Add the new InitiatorContext, default to Document. * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishTiming): New client method only used by WorkerThreadableLoader. * loader/WorkerThreadableLoader.h: * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming): All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker. Add timing information to the Performance object when received. No need to inform clients. * loader/DocumentThreadableLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad): (WebCore::DocumentThreadableLoader::loadRequest): Provide APIs to pass timing data on to a WorkerThreadableLoader. Create ResourceTiming data for synchronous loads. * loader/LoadTiming.h: * loader/LoadTiming.cpp: (WebCore::LoadTiming::isolatedCopy): Add isolatedCopy to allow this data to be passed across to a Worker. * loader/ResourceTimingInformation.h: * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): (WebCore::ResourceTimingInformation::addResourceTiming): (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Refactor to remove unused / unnecessary bits. Extract out some helpful code. Changed this to match when Blink decides when to add or ignore entries, however this may change over time. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::notifyDone): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::finishedTimingForWorkerLoad): * loader/cache/CachedRawResource.h: * loader/cache/CachedRawResourceClient.h: (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad): Plumbing to report timing information to Worker if this resource was loaded for a Worker. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): * loader/cache/CachedResource.h: (WebCore::CachedResource::initiatorName): Store the initiator name on the CachedResource like other data added to the original CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and cleans up other hacks that worked around this later on. * loader/cache/CachedResourceLoader.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::revalidateResource): (WebCore::CachedResourceLoader::loadResource): Simply the creation of a ResourceTiming object for cache hits. Report timing information to Worker if this resource was loaded for a Worker. (WebCore::CachedResourceLoader::loadDone): Eliminate this redundant point attempting to add a ResourceTiming entry. * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName): Update to match the spec. The fallback is "other". * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::setResourceTimingBufferSize): (WebCore::Performance::addResourceTiming): Update to support PerformanceObservers. Update to match spec (event should bubble). * page/PerformanceResourceTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::create): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::fetchStart): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): Construct with a ResourceTiming object containing all the data we need for the entry. Update to match spec for what is required, should fallback, should be zero, etc. (WebCore::passesTimingAllowCheck): Deleted. Extracted this to ResourceTiming creation time in the loading context, since this can't be determined on the Worker context without also having all of the header information from each resource response. * page/PerformanceResourceTiming.idl: Expose to Workers! LayoutTests: * TestExpectations: Pre-emptively mark some tests as flakey that have seen flakiness. * platform/mac/TestExpectations: Skip some tests on ElCapitan because the network timing numbers appear incorrect. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: PerformanceResourceTiming is now available in Workers. * performance-api/resource-timing-apis-expected.txt: Added. * performance-api/resource-timing-apis.html: Added. * performance-api/resources/resource-timing-api.js: Added. Basic API test. We expect to fail nextHopProtocol and size properties right now. Canonical link: https://commits.webkit.org/185464@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-16 19:18:32 +00:00
}
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
ResourceTiming ResourceTiming::fromSynchronousLoad(const URL& url, const String& initiator, const ResourceLoadTiming& loadTiming, const NetworkLoadMetrics& networkLoadMetrics, const ResourceResponse& response, const SecurityOrigin& securityOrigin)
[Resource Timing] Support Resource Timing in Workers https://bugs.webkit.org/show_bug.cgi?id=168086 <rdar://problem/30430117> Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/idlharness-expected.txt: * web-platform-tests/resource-timing/resource-timing-expected.txt: * web-platform-tests/resource-timing/resource_cached-expected.txt: * web-platform-tests/resource-timing/resource_connection_reuse-expected.txt: Progressions. * web-platform-tests/resource-timing/resources/data.json: Added. * web-platform-tests/resource-timing/resources/rt-iframe-1.html: Added. * web-platform-tests/resource-timing/resources/rt-iframe-2.html: Added. * web-platform-tests/resource-timing/resources/rt-module.js: Added. * web-platform-tests/resource-timing/resources/rt-sub-module.js: Added. * web-platform-tests/resource-timing/resources/rt-utilities.js: Added. * web-platform-tests/resource-timing/resources/rt-worker-resources.js: Added. New Resources. * web-platform-tests/resource-timing/rt-cors-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.html: Added. * web-platform-tests/resource-timing/rt-cors.js: Added. * web-platform-tests/resource-timing/rt-cors.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.worker.html: Added. * web-platform-tests/resource-timing/rt-cors.worker.js: Added. Tests for redirects and cross origin data hiding. * web-platform-tests/resource-timing/rt-initiatorType-css-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-css.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-element-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-element.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.js: Added. * web-platform-tests/resource-timing/rt-initiatorType-other-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-other.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.js: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.html: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.js: Added. Tests for producing different initiator types. * web-platform-tests/resource-timing/rt-initiatorType-media-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-media.html: Added. We currently fail these tests, so they are marked as fail. * web-platform-tests/resource-timing/rt-performance-extensions-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.js: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.js: Added. Tests for the new Performance APIs. * web-platform-tests/resource-timing/rt-serialization-expected.txt: Added. * web-platform-tests/resource-timing/rt-serialization.html: Added. Tests for JSON serialization. * web-platform-tests/resource-timing/rt-resource-errors-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-errors.html: Added. * web-platform-tests/resource-timing/rt-resource-ignored-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-ignored.html: Added. Tests for when PerformanceResourceTiming entries should not be included. * web-platform-tests/resource-timing/rt-resources-per-frame-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-frame.html: Added. * web-platform-tests/resource-timing/rt-resources-per-worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-worker.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers.html: Added. Tests for different entries in different contexts. * web-platform-tests/serve: Make executable. Source/WebCore: Worker's load resources through the Document that loaded them. However, their PerformanceResourceTiming entries should be added to the Performance object inside the Worker context, not the Document's context. This change adds an InitiatorContext to ResourceLoadOptions so that loaders can determine if the load was initiated by the Document or a Worker. This allows loaders to then know if the ResourceTiming data they collect should be added to the Document's Performance object or forwarded on to the Worker's. This adds a new ThreadableLoaderClient method intended only for the purpose of adding the ResourceTiming information to the Worker's Performance object. Unlike other ThreadableLoaderClient methods that are bridged and forwarded on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this method never needs to be handled by clients and can be uniformly handled by the WorkerThreadableLoader itself. We also add a new ResourceTiming object that encapsulates all of the data ultimately needed for a PerformanceResourceTimingEntry object. This allows for all of the information to be gathered while loading on the Document before serializing across to the Worker. That includes the Timing-Allow-Origin check which uses the SecurityOrigin of the Worker. This also modernizes and addresses issues in the Resource Timing implementation. Better handling cases like loading from the Cache, Synchronous Loads, and improving initiatorType information. Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html imported/w3c/web-platform-tests/resource-timing/rt-serialization.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html performance-api/resource-timing-apis.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: New files. * platform/network/NetworkLoadTiming.h: (WebCore::NetworkLoadTiming::reset): Deleted. We no longer need to reset. * loader/ResourceTiming.cpp: Added. (WebCore::passesTimingAllowCheck): (WebCore::ResourceTiming::fromCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: Added. (WebCore::ResourceTiming::url): (WebCore::ResourceTiming::initiator): (WebCore::ResourceTiming::loadTiming): (WebCore::ResourceTiming::networkLoadTiming): (WebCore::ResourceTiming::allowTimingDetails): (WebCore::ResourceTiming::overrideInitiatorName): (WebCore::ResourceTiming::ResourceTiming): Class that encapsulates all of the data needed for a PerformanceResourceTiming entry. There are three static constructors indicating the different ways this object can be constructed and the different data available at the time of construction. * loader/ResourceLoaderOptions.h: Add the new InitiatorContext, default to Document. * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishTiming): New client method only used by WorkerThreadableLoader. * loader/WorkerThreadableLoader.h: * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming): All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker. Add timing information to the Performance object when received. No need to inform clients. * loader/DocumentThreadableLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad): (WebCore::DocumentThreadableLoader::loadRequest): Provide APIs to pass timing data on to a WorkerThreadableLoader. Create ResourceTiming data for synchronous loads. * loader/LoadTiming.h: * loader/LoadTiming.cpp: (WebCore::LoadTiming::isolatedCopy): Add isolatedCopy to allow this data to be passed across to a Worker. * loader/ResourceTimingInformation.h: * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): (WebCore::ResourceTimingInformation::addResourceTiming): (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Refactor to remove unused / unnecessary bits. Extract out some helpful code. Changed this to match when Blink decides when to add or ignore entries, however this may change over time. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::notifyDone): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::finishedTimingForWorkerLoad): * loader/cache/CachedRawResource.h: * loader/cache/CachedRawResourceClient.h: (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad): Plumbing to report timing information to Worker if this resource was loaded for a Worker. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): * loader/cache/CachedResource.h: (WebCore::CachedResource::initiatorName): Store the initiator name on the CachedResource like other data added to the original CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and cleans up other hacks that worked around this later on. * loader/cache/CachedResourceLoader.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::revalidateResource): (WebCore::CachedResourceLoader::loadResource): Simply the creation of a ResourceTiming object for cache hits. Report timing information to Worker if this resource was loaded for a Worker. (WebCore::CachedResourceLoader::loadDone): Eliminate this redundant point attempting to add a ResourceTiming entry. * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName): Update to match the spec. The fallback is "other". * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::setResourceTimingBufferSize): (WebCore::Performance::addResourceTiming): Update to support PerformanceObservers. Update to match spec (event should bubble). * page/PerformanceResourceTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::create): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::fetchStart): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): Construct with a ResourceTiming object containing all the data we need for the entry. Update to match spec for what is required, should fallback, should be zero, etc. (WebCore::passesTimingAllowCheck): Deleted. Extracted this to ResourceTiming creation time in the loading context, since this can't be determined on the Worker context without also having all of the header information from each resource response. * page/PerformanceResourceTiming.idl: Expose to Workers! LayoutTests: * TestExpectations: Pre-emptively mark some tests as flakey that have seen flakiness. * platform/mac/TestExpectations: Skip some tests on ElCapitan because the network timing numbers appear incorrect. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: PerformanceResourceTiming is now available in Workers. * performance-api/resource-timing-apis-expected.txt: Added. * performance-api/resource-timing-apis.html: Added. * performance-api/resources/resource-timing-api.js: Added. Basic API test. We expect to fail nextHopProtocol and size properties right now. Canonical link: https://commits.webkit.org/185464@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-16 19:18:32 +00:00
{
[Resource Timing] Gather timing information with reliable responseEnd time https://bugs.webkit.org/show_bug.cgi?id=168351 Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/fetch/api/redirect/redirect-count-cross-origin-expected.txt: * web-platform-tests/fetch/api/redirect/redirect-count-cross-origin-worker-expected.txt: * web-platform-tests/fetch/api/redirect/redirect-count-expected.txt: * web-platform-tests/fetch/api/redirect/redirect-count-worker-expected.txt: * web-platform-tests/fetch/api/redirect/redirect-location-expected.txt: * web-platform-tests/fetch/api/redirect/redirect-location-worker-expected.txt: New behavior for too many redirects caused by <rdar://problem/30610988>. * web-platform-tests/resource-timing/rt-nextHopProtocol-expected.txt: Added. * web-platform-tests/resource-timing/rt-nextHopProtocol.html: Added. * web-platform-tests/resource-timing/rt-nextHopProtocol.js: Added. * web-platform-tests/resource-timing/rt-nextHopProtocol.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-nextHopProtocol.worker.html: Added. * web-platform-tests/resource-timing/rt-nextHopProtocol.worker.js: Added. New tests specific to just checking the nextHopProtocol property with a non-cached resource to avoid flakeyness. Source/WebCore: This patch replaces the unused `double finishTime` in ResourceLoader's didFinishLoad with a complete WebCore::NetworkLoadMetrics object. This allows the NetworkProcess to give complete timing information, and more final metrics about the load, to WebCore. Currently this is only used by ResourceTiming, but it will soon be used by Web Inspector as well. We may also end up extending this to the didFail path as well, since it is possible that we have some metrics for load failures. At the same time we want to start moving away from the legacy path that populated a subset of this information in ResourceResponse's NetworkLoadMetrics. It doesn't make sense to store this information on the ResourceResponse for a few reasons: We don't want to store the metrics in our Network Cache and not all of the load timing metrics have been populated yet (responseEnd). In an effort to move off of this data we've renamed the accessor to "deprecatedNetworkLoadMetrics". There are a few remaining clients (ResourceHandle, PerformanceTiming, InspectorNetworkAgent) which can be migrated separately from this patch. Having both the legacy and new code paths adds a little bit of complexity. One advantage of the new path is that the complete load timing data (fetchStart -> dns -> connect -> request -> response -> responseEnd) can be packaged together. The legacy path could not include a responseEnd, so WebCore faked that value with its own timestamp. Having the fake responseEnd caused issues as timestamps / clocks are different between processes. In order for PerformanceResponseTiming to know whether or not the NetworkLoadMetrics has the complete network timing metrics it checks isComplete(). If true it knows it can use the responseEnd time from NetworkLoadMetrics, otherwise it must fallback to the legacy value from LoadTiming. Once all of the deprecatedNetworkLoadMetrics clients go away, we should always have the complete data and this can be eliminated. Tests: imported/w3c/web-platform-tests/resource-timing/rt-nextHopProtocol.html imported/w3c/web-platform-tests/resource-timing/rt-nextHopProtocol.worker.html * PlatformMac.cmake: * WebCore.xcodeproj/project.pbxproj: Rename NetworkLoadTiming -> NetworkLoadMetrics. * page/PerformanceResourceTiming.cpp: (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): * page/PerformanceResourceTiming.h: Mostly just updating names and types. This does however need to get the correct endTime based on whether the NetworkLoadMetrics are complete (meaning includes responseEnd) or not (legacy, use LoadTiming value). * page/PerformanceResourceTiming.idl: Add nextHopProtocol. * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::domainLookupStart): (WebCore::PerformanceTiming::domainLookupEnd): (WebCore::PerformanceTiming::connectStart): (WebCore::PerformanceTiming::connectEnd): (WebCore::PerformanceTiming::secureConnectionStart): (WebCore::PerformanceTiming::requestStart): (WebCore::PerformanceTiming::responseStart): (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart): * page/PerformanceTiming.h: Navigation Timing values still uses the NetworkLoadTiming values stored on the DocumentLoader. This should be moved off of the deprecated path separately. * platform/network/NetworkLoadMetrics.h: Renamed from Source/WebCore/platform/network/NetworkLoadTiming.h. (WebCore::NetworkLoadMetrics::NetworkLoadMetrics): (WebCore::NetworkLoadMetrics::isolatedCopy): (WebCore::NetworkLoadMetrics::reset): (WebCore::NetworkLoadMetrics::operator==): (WebCore::NetworkLoadMetrics::operator!=): (WebCore::NetworkLoadMetrics::isComplete): (WebCore::NetworkLoadMetrics::markComplete): (WebCore::NetworkLoadMetrics::encode): (WebCore::NetworkLoadMetrics::decode): Re-introduce a reset() method (for NetworkLoadSoup to reset between redirects). Add protocolName and "complete" boolean. * platform/network/cocoa/NetworkLoadMetrics.mm: Renamed from Source/WebCore/platform/network/cocoa/NetworkLoadTiming.mm. (WebCore::timingValue): (WebCore::copyTimingData): (WebCore::setCollectsTimingData): Use this opportunity to convert NetworkLoadTiming timestamps to WTF::Seconds. Since we already have to modify all the clients this moves us to use the more strongly typed units that are less ambiguous then "double". The rest of the Performance API has already moved to these units. * inspector/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/InspectorNetworkAgent.h: Inspector was the only client of the finishTime, and since the value was erratically coming from clients in different ways it was almost certainly inaccurate. Simplify this in preparation for using NetworkLoadMetrics. * Modules/fetch/FetchLoader.cpp: (WebCore::FetchLoader::didFinishLoading): * Modules/fetch/FetchLoader.h: * fileapi/FileReaderLoader.cpp: (WebCore::FileReaderLoader::didFinishLoading): * fileapi/FileReaderLoader.h: * html/MediaFragmentURIParser.cpp: (WebCore::MediaFragmentURIParser::parseNPTTime): * inspector/InspectorInstrumentation.cpp: (WebCore::InspectorInstrumentation::didFinishLoadingImpl): * inspector/InspectorInstrumentation.h: (WebCore::InspectorInstrumentation::didFinishLoading): * loader/CrossOriginPreflightChecker.cpp: (WebCore::CrossOriginPreflightChecker::validatePreflightResponse): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::continueAfterContentPolicy): (WebCore::DocumentLoader::maybeLoadEmpty): * loader/DocumentLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::didReceiveResponse): (WebCore::DocumentThreadableLoader::notifyFinished): (WebCore::DocumentThreadableLoader::didFinishLoading): (WebCore::DocumentThreadableLoader::loadRequest): * loader/DocumentThreadableLoader.h: * loader/NetscapePlugInStreamLoader.cpp: (WebCore::NetscapePlugInStreamLoader::didFinishLoading): * loader/NetscapePlugInStreamLoader.h: * loader/ResourceLoadNotifier.cpp: (WebCore::ResourceLoadNotifier::didFinishLoad): (WebCore::ResourceLoadNotifier::dispatchDidFinishLoading): (WebCore::ResourceLoadNotifier::sendRemainingDelegateMessages): * loader/ResourceLoadNotifier.h: * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::deliverResponseAndData): (WebCore::ResourceLoader::loadDataURL): (WebCore::ResourceLoader::didFinishLoading): (WebCore::ResourceLoader::didFinishLoadingOnePart): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: (WebCore::ResourceTiming::networkLoadMetrics): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::networkLoadTiming): Deleted. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::SubresourceLoader): (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didReceiveResponse): (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishLoading): * loader/ThreadableLoaderClientWrapper.h: (WebCore::ThreadableLoaderClientWrapper::didFinishLoading): * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishLoading): * loader/WorkerThreadableLoader.h: * loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::didFinishLoading): * loader/appcache/ApplicationCacheGroup.h: * loader/cache/CachedResource.h: (WebCore::CachedResource::setLoadFinishTime): * loader/ios/QuickLook.mm: (-[WebPreviewLoader connectionDidFinishLoading:]): * page/EventSource.cpp: (WebCore::EventSource::didFinishLoading): * page/EventSource.h: * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp: (ResourceHandleStreamingClient::didFinishLoading): * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/PingHandle.h: * platform/network/ResourceHandle.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/ResourceResponseBase.cpp: (WebCore::ResourceResponseBase::crossThreadData): (WebCore::ResourceResponseBase::fromCrossThreadData): (WebCore::ResourceResponseBase::compare): * platform/network/ResourceResponseBase.h: (WebCore::ResourceResponseBase::deprecatedNetworkLoadMetrics): (WebCore::ResourceResponseBase::encode): (WebCore::ResourceResponseBase::decode): (WebCore::ResourceResponseBase::networkLoadTiming): Deleted. * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveResponse): (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): * platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp: (WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didReceiveResponse): (WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didFinishLoading): * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::WebCoreSynchronousLoader::didFinishLoading): * platform/network/curl/ResourceHandleManager.cpp: (WebCore::calculateWebTimingInformations): (WebCore::ResourceHandleManager::downloadTimerCallback): (WebCore::handleDataURL): (WebCore::milisecondsSinceRequest): Deleted. * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::getConnectionTimingData): * platform/network/mac/WebCoreResourceHandleAsDelegate.mm: (-[WebCoreResourceHandleAsDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsDelegate connectionDidFinishLoading:]): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): * platform/network/soup/ResourceHandleSoup.cpp: (WebCore::restartedCallback): (WebCore::nextMultipartResponsePartCallback): (WebCore::sendRequestCallback): (WebCore::ResourceHandle::didStartRequest): (WebCore::networkEventCallback): (WebCore::ResourceHandle::sendPendingRequest): (WebCore::readCallback): (WebCore::milisecondsSinceRequest): Deleted. * workers/WorkerScriptLoader.cpp: (WebCore::WorkerScriptLoader::didFinishLoading): * workers/WorkerScriptLoader.h: * xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::didFinishLoading): * xml/XMLHttpRequest.h: Eliminate the unused finishTime double. Source/WebKit2: Change from an unused `double finishTime` to a complete WebCore::NetworkLoadMetrics object in the didFinishLoad ResourceLoader path. We may also extend this in the didFail path later on. This allows the NetworkProcess to give complete timing information, and more final metrics about the load, to WebCore. * NetworkProcess/NetworkDataTask.h: (WebKit::NetworkDataTaskClient::didCompleteWithError): Give the NetworkDataTaskClient a basic didCompleteWithError for a completion without metrics. For loads that complete with an error, or haven't populated any metrics, this will pass empty metrics onward. * NetworkProcess/Downloads/BlobDownloadClient.cpp: (WebKit::BlobDownloadClient::didFinishLoading): * NetworkProcess/Downloads/BlobDownloadClient.h: * NetworkProcess/Downloads/PendingDownload.h: * NetworkProcess/PingLoad.h: * NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp: (WebKit::NetworkCache::SpeculativeLoad::didFinishLoading): * NetworkProcess/cache/NetworkCacheSpeculativeLoad.h: * NetworkProcess/NetworkDataTaskBlob.cpp: (WebKit::NetworkDataTaskBlob::didFail): * NetworkProcess/NetworkLoad.cpp: (WebKit::NetworkLoad::continueWillSendRequest): (WebKit::NetworkLoad::didCompleteWithError): (WebKit::NetworkLoad::didFinishLoading): * NetworkProcess/NetworkLoad.h: * NetworkProcess/NetworkLoadClient.h: * NetworkProcess/NetworkResourceLoader.cpp: (WebKit::NetworkResourceLoader::didFinishLoading): (WebKit::NetworkResourceLoader::sendResultForCacheEntry): * NetworkProcess/NetworkResourceLoader.h: * WebProcess/Network/WebResourceLoader.cpp: (WebKit::WebResourceLoader::didFinishResourceLoad): (WebKit::WebResourceLoader::didReceiveResource): * WebProcess/Network/WebResourceLoader.h: * WebProcess/Network/WebResourceLoader.messages.in: Change didFinishLoad paths to take a NetworkLoadMetrics object instead of finishTime. Change didCompleteWithError pathes to include a NetworkLoadMetrics object instead of finishTime. * NetworkProcess/cocoa/NetworkDataTaskCocoa.h: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::didCompleteWithError): Own a NetworkLoadTiming that will be populated with the load. * NetworkProcess/cocoa/NetworkSessionCocoa.h: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didCompleteWithError:]): (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): Populate NetworkLoadMetrics in the didFinishCollectingMetrics NSURLSessionTaskDelegate method. * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::timeoutFired): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidReceiveResponse): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::tlsErrorsChanged): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::didFinishRead): (WebKit::NetworkDataTaskSoup::didFinishRequestNextPart): (WebKit::NetworkDataTaskSoup::didFailDownload): (WebKit::NetworkDataTaskSoup::didFail): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): * NetworkProcess/soup/NetworkDataTaskSoup.h: Instead of populating the NetworkLoadMetrics on the ResourceResponse, populate a member variable during the entire load and dispatch didFinishCollectingMetrics right before didCompleteLoadWithError. Source/WTF: * wtf/persistence/Coders.h: (WTF::Persistence::Coder<Seconds>::encode): (WTF::Persistence::Coder<Seconds>::decode): LayoutTests: * TestExpectations: Now that nextHopProtocol is available on Mac mark the test as flakey because the value can be set or not depending on whether or not the resource was loaded from a cache. * platform/ios-simulator/TestExpectations: * platform/gtk/TestExpectations: * platform/mac/TestExpectations: * platform/win/TestExpectations: Mark nextHopProtocol tests as expected to fail on ports that do not yet support those values. Mark redirect tests as failing on ports that encounter the CFNetwork issue causing unexpected callbacks. * performance-api/resource-timing-apis-expected.txt: * performance-api/resources/resource-timing-api.js: Progressions. * platform/mac-elcapitan/imported/w3c/web-platform-tests/resource-timing/test_resource_timing-expected.txt: Added. * platform/mac/imported/w3c/web-platform-tests/resource-timing/test_resource_timing-expected.txt: Added. Expected passing values on mac, except el capitan where this new resource timing data is unavailable. Canonical link: https://commits.webkit.org/185854@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212993 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-25 05:48:51 +00:00
return ResourceTiming(url, initiator, loadTiming, networkLoadMetrics, response, securityOrigin);
[Resource Timing] Support Resource Timing in Workers https://bugs.webkit.org/show_bug.cgi?id=168086 <rdar://problem/30430117> Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/idlharness-expected.txt: * web-platform-tests/resource-timing/resource-timing-expected.txt: * web-platform-tests/resource-timing/resource_cached-expected.txt: * web-platform-tests/resource-timing/resource_connection_reuse-expected.txt: Progressions. * web-platform-tests/resource-timing/resources/data.json: Added. * web-platform-tests/resource-timing/resources/rt-iframe-1.html: Added. * web-platform-tests/resource-timing/resources/rt-iframe-2.html: Added. * web-platform-tests/resource-timing/resources/rt-module.js: Added. * web-platform-tests/resource-timing/resources/rt-sub-module.js: Added. * web-platform-tests/resource-timing/resources/rt-utilities.js: Added. * web-platform-tests/resource-timing/resources/rt-worker-resources.js: Added. New Resources. * web-platform-tests/resource-timing/rt-cors-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.html: Added. * web-platform-tests/resource-timing/rt-cors.js: Added. * web-platform-tests/resource-timing/rt-cors.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.worker.html: Added. * web-platform-tests/resource-timing/rt-cors.worker.js: Added. Tests for redirects and cross origin data hiding. * web-platform-tests/resource-timing/rt-initiatorType-css-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-css.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-element-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-element.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.js: Added. * web-platform-tests/resource-timing/rt-initiatorType-other-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-other.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.js: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.html: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.js: Added. Tests for producing different initiator types. * web-platform-tests/resource-timing/rt-initiatorType-media-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-media.html: Added. We currently fail these tests, so they are marked as fail. * web-platform-tests/resource-timing/rt-performance-extensions-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.js: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.js: Added. Tests for the new Performance APIs. * web-platform-tests/resource-timing/rt-serialization-expected.txt: Added. * web-platform-tests/resource-timing/rt-serialization.html: Added. Tests for JSON serialization. * web-platform-tests/resource-timing/rt-resource-errors-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-errors.html: Added. * web-platform-tests/resource-timing/rt-resource-ignored-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-ignored.html: Added. Tests for when PerformanceResourceTiming entries should not be included. * web-platform-tests/resource-timing/rt-resources-per-frame-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-frame.html: Added. * web-platform-tests/resource-timing/rt-resources-per-worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-worker.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers.html: Added. Tests for different entries in different contexts. * web-platform-tests/serve: Make executable. Source/WebCore: Worker's load resources through the Document that loaded them. However, their PerformanceResourceTiming entries should be added to the Performance object inside the Worker context, not the Document's context. This change adds an InitiatorContext to ResourceLoadOptions so that loaders can determine if the load was initiated by the Document or a Worker. This allows loaders to then know if the ResourceTiming data they collect should be added to the Document's Performance object or forwarded on to the Worker's. This adds a new ThreadableLoaderClient method intended only for the purpose of adding the ResourceTiming information to the Worker's Performance object. Unlike other ThreadableLoaderClient methods that are bridged and forwarded on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this method never needs to be handled by clients and can be uniformly handled by the WorkerThreadableLoader itself. We also add a new ResourceTiming object that encapsulates all of the data ultimately needed for a PerformanceResourceTimingEntry object. This allows for all of the information to be gathered while loading on the Document before serializing across to the Worker. That includes the Timing-Allow-Origin check which uses the SecurityOrigin of the Worker. This also modernizes and addresses issues in the Resource Timing implementation. Better handling cases like loading from the Cache, Synchronous Loads, and improving initiatorType information. Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html imported/w3c/web-platform-tests/resource-timing/rt-serialization.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html performance-api/resource-timing-apis.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: New files. * platform/network/NetworkLoadTiming.h: (WebCore::NetworkLoadTiming::reset): Deleted. We no longer need to reset. * loader/ResourceTiming.cpp: Added. (WebCore::passesTimingAllowCheck): (WebCore::ResourceTiming::fromCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: Added. (WebCore::ResourceTiming::url): (WebCore::ResourceTiming::initiator): (WebCore::ResourceTiming::loadTiming): (WebCore::ResourceTiming::networkLoadTiming): (WebCore::ResourceTiming::allowTimingDetails): (WebCore::ResourceTiming::overrideInitiatorName): (WebCore::ResourceTiming::ResourceTiming): Class that encapsulates all of the data needed for a PerformanceResourceTiming entry. There are three static constructors indicating the different ways this object can be constructed and the different data available at the time of construction. * loader/ResourceLoaderOptions.h: Add the new InitiatorContext, default to Document. * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishTiming): New client method only used by WorkerThreadableLoader. * loader/WorkerThreadableLoader.h: * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming): All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker. Add timing information to the Performance object when received. No need to inform clients. * loader/DocumentThreadableLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad): (WebCore::DocumentThreadableLoader::loadRequest): Provide APIs to pass timing data on to a WorkerThreadableLoader. Create ResourceTiming data for synchronous loads. * loader/LoadTiming.h: * loader/LoadTiming.cpp: (WebCore::LoadTiming::isolatedCopy): Add isolatedCopy to allow this data to be passed across to a Worker. * loader/ResourceTimingInformation.h: * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): (WebCore::ResourceTimingInformation::addResourceTiming): (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Refactor to remove unused / unnecessary bits. Extract out some helpful code. Changed this to match when Blink decides when to add or ignore entries, however this may change over time. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::notifyDone): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::finishedTimingForWorkerLoad): * loader/cache/CachedRawResource.h: * loader/cache/CachedRawResourceClient.h: (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad): Plumbing to report timing information to Worker if this resource was loaded for a Worker. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): * loader/cache/CachedResource.h: (WebCore::CachedResource::initiatorName): Store the initiator name on the CachedResource like other data added to the original CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and cleans up other hacks that worked around this later on. * loader/cache/CachedResourceLoader.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::revalidateResource): (WebCore::CachedResourceLoader::loadResource): Simply the creation of a ResourceTiming object for cache hits. Report timing information to Worker if this resource was loaded for a Worker. (WebCore::CachedResourceLoader::loadDone): Eliminate this redundant point attempting to add a ResourceTiming entry. * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName): Update to match the spec. The fallback is "other". * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::setResourceTimingBufferSize): (WebCore::Performance::addResourceTiming): Update to support PerformanceObservers. Update to match spec (event should bubble). * page/PerformanceResourceTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::create): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::fetchStart): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): Construct with a ResourceTiming object containing all the data we need for the entry. Update to match spec for what is required, should fallback, should be zero, etc. (WebCore::passesTimingAllowCheck): Deleted. Extracted this to ResourceTiming creation time in the loading context, since this can't be determined on the Worker context without also having all of the header information from each resource response. * page/PerformanceResourceTiming.idl: Expose to Workers! LayoutTests: * TestExpectations: Pre-emptively mark some tests as flakey that have seen flakiness. * platform/mac/TestExpectations: Skip some tests on ElCapitan because the network timing numbers appear incorrect. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: PerformanceResourceTiming is now available in Workers. * performance-api/resource-timing-apis-expected.txt: Added. * performance-api/resource-timing-apis.html: Added. * performance-api/resources/resource-timing-api.js: Added. Basic API test. We expect to fail nextHopProtocol and size properties right now. Canonical link: https://commits.webkit.org/185464@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-16 19:18:32 +00:00
}
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
ResourceTiming::ResourceTiming(const URL& url, const String& initiator, const ResourceLoadTiming& timing, const NetworkLoadMetrics& networkLoadMetrics, const ResourceResponse& response, const SecurityOrigin&)
[Resource Timing] Support Resource Timing in Workers https://bugs.webkit.org/show_bug.cgi?id=168086 <rdar://problem/30430117> Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/idlharness-expected.txt: * web-platform-tests/resource-timing/resource-timing-expected.txt: * web-platform-tests/resource-timing/resource_cached-expected.txt: * web-platform-tests/resource-timing/resource_connection_reuse-expected.txt: Progressions. * web-platform-tests/resource-timing/resources/data.json: Added. * web-platform-tests/resource-timing/resources/rt-iframe-1.html: Added. * web-platform-tests/resource-timing/resources/rt-iframe-2.html: Added. * web-platform-tests/resource-timing/resources/rt-module.js: Added. * web-platform-tests/resource-timing/resources/rt-sub-module.js: Added. * web-platform-tests/resource-timing/resources/rt-utilities.js: Added. * web-platform-tests/resource-timing/resources/rt-worker-resources.js: Added. New Resources. * web-platform-tests/resource-timing/rt-cors-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.html: Added. * web-platform-tests/resource-timing/rt-cors.js: Added. * web-platform-tests/resource-timing/rt-cors.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.worker.html: Added. * web-platform-tests/resource-timing/rt-cors.worker.js: Added. Tests for redirects and cross origin data hiding. * web-platform-tests/resource-timing/rt-initiatorType-css-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-css.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-element-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-element.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.js: Added. * web-platform-tests/resource-timing/rt-initiatorType-other-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-other.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.js: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.html: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.js: Added. Tests for producing different initiator types. * web-platform-tests/resource-timing/rt-initiatorType-media-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-media.html: Added. We currently fail these tests, so they are marked as fail. * web-platform-tests/resource-timing/rt-performance-extensions-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.js: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.js: Added. Tests for the new Performance APIs. * web-platform-tests/resource-timing/rt-serialization-expected.txt: Added. * web-platform-tests/resource-timing/rt-serialization.html: Added. Tests for JSON serialization. * web-platform-tests/resource-timing/rt-resource-errors-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-errors.html: Added. * web-platform-tests/resource-timing/rt-resource-ignored-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-ignored.html: Added. Tests for when PerformanceResourceTiming entries should not be included. * web-platform-tests/resource-timing/rt-resources-per-frame-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-frame.html: Added. * web-platform-tests/resource-timing/rt-resources-per-worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-worker.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers.html: Added. Tests for different entries in different contexts. * web-platform-tests/serve: Make executable. Source/WebCore: Worker's load resources through the Document that loaded them. However, their PerformanceResourceTiming entries should be added to the Performance object inside the Worker context, not the Document's context. This change adds an InitiatorContext to ResourceLoadOptions so that loaders can determine if the load was initiated by the Document or a Worker. This allows loaders to then know if the ResourceTiming data they collect should be added to the Document's Performance object or forwarded on to the Worker's. This adds a new ThreadableLoaderClient method intended only for the purpose of adding the ResourceTiming information to the Worker's Performance object. Unlike other ThreadableLoaderClient methods that are bridged and forwarded on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this method never needs to be handled by clients and can be uniformly handled by the WorkerThreadableLoader itself. We also add a new ResourceTiming object that encapsulates all of the data ultimately needed for a PerformanceResourceTimingEntry object. This allows for all of the information to be gathered while loading on the Document before serializing across to the Worker. That includes the Timing-Allow-Origin check which uses the SecurityOrigin of the Worker. This also modernizes and addresses issues in the Resource Timing implementation. Better handling cases like loading from the Cache, Synchronous Loads, and improving initiatorType information. Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html imported/w3c/web-platform-tests/resource-timing/rt-serialization.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html performance-api/resource-timing-apis.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: New files. * platform/network/NetworkLoadTiming.h: (WebCore::NetworkLoadTiming::reset): Deleted. We no longer need to reset. * loader/ResourceTiming.cpp: Added. (WebCore::passesTimingAllowCheck): (WebCore::ResourceTiming::fromCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: Added. (WebCore::ResourceTiming::url): (WebCore::ResourceTiming::initiator): (WebCore::ResourceTiming::loadTiming): (WebCore::ResourceTiming::networkLoadTiming): (WebCore::ResourceTiming::allowTimingDetails): (WebCore::ResourceTiming::overrideInitiatorName): (WebCore::ResourceTiming::ResourceTiming): Class that encapsulates all of the data needed for a PerformanceResourceTiming entry. There are three static constructors indicating the different ways this object can be constructed and the different data available at the time of construction. * loader/ResourceLoaderOptions.h: Add the new InitiatorContext, default to Document. * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishTiming): New client method only used by WorkerThreadableLoader. * loader/WorkerThreadableLoader.h: * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming): All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker. Add timing information to the Performance object when received. No need to inform clients. * loader/DocumentThreadableLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad): (WebCore::DocumentThreadableLoader::loadRequest): Provide APIs to pass timing data on to a WorkerThreadableLoader. Create ResourceTiming data for synchronous loads. * loader/LoadTiming.h: * loader/LoadTiming.cpp: (WebCore::LoadTiming::isolatedCopy): Add isolatedCopy to allow this data to be passed across to a Worker. * loader/ResourceTimingInformation.h: * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): (WebCore::ResourceTimingInformation::addResourceTiming): (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Refactor to remove unused / unnecessary bits. Extract out some helpful code. Changed this to match when Blink decides when to add or ignore entries, however this may change over time. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::notifyDone): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::finishedTimingForWorkerLoad): * loader/cache/CachedRawResource.h: * loader/cache/CachedRawResourceClient.h: (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad): Plumbing to report timing information to Worker if this resource was loaded for a Worker. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): * loader/cache/CachedResource.h: (WebCore::CachedResource::initiatorName): Store the initiator name on the CachedResource like other data added to the original CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and cleans up other hacks that worked around this later on. * loader/cache/CachedResourceLoader.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::revalidateResource): (WebCore::CachedResourceLoader::loadResource): Simply the creation of a ResourceTiming object for cache hits. Report timing information to Worker if this resource was loaded for a Worker. (WebCore::CachedResourceLoader::loadDone): Eliminate this redundant point attempting to add a ResourceTiming entry. * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName): Update to match the spec. The fallback is "other". * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::setResourceTimingBufferSize): (WebCore::Performance::addResourceTiming): Update to support PerformanceObservers. Update to match spec (event should bubble). * page/PerformanceResourceTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::create): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::fetchStart): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): Construct with a ResourceTiming object containing all the data we need for the entry. Update to match spec for what is required, should fallback, should be zero, etc. (WebCore::passesTimingAllowCheck): Deleted. Extracted this to ResourceTiming creation time in the loading context, since this can't be determined on the Worker context without also having all of the header information from each resource response. * page/PerformanceResourceTiming.idl: Expose to Workers! LayoutTests: * TestExpectations: Pre-emptively mark some tests as flakey that have seen flakiness. * platform/mac/TestExpectations: Skip some tests on ElCapitan because the network timing numbers appear incorrect. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: PerformanceResourceTiming is now available in Workers. * performance-api/resource-timing-apis-expected.txt: Added. * performance-api/resource-timing-apis.html: Added. * performance-api/resources/resource-timing-api.js: Added. Basic API test. We expect to fail nextHopProtocol and size properties right now. Canonical link: https://commits.webkit.org/185464@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-16 19:18:32 +00:00
: m_url(url)
, m_initiator(initiator)
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_resourceLoadTiming(timing)
[Resource Timing] Gather timing information with reliable responseEnd time https://bugs.webkit.org/show_bug.cgi?id=168351 Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/fetch/api/redirect/redirect-count-cross-origin-expected.txt: * web-platform-tests/fetch/api/redirect/redirect-count-cross-origin-worker-expected.txt: * web-platform-tests/fetch/api/redirect/redirect-count-expected.txt: * web-platform-tests/fetch/api/redirect/redirect-count-worker-expected.txt: * web-platform-tests/fetch/api/redirect/redirect-location-expected.txt: * web-platform-tests/fetch/api/redirect/redirect-location-worker-expected.txt: New behavior for too many redirects caused by <rdar://problem/30610988>. * web-platform-tests/resource-timing/rt-nextHopProtocol-expected.txt: Added. * web-platform-tests/resource-timing/rt-nextHopProtocol.html: Added. * web-platform-tests/resource-timing/rt-nextHopProtocol.js: Added. * web-platform-tests/resource-timing/rt-nextHopProtocol.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-nextHopProtocol.worker.html: Added. * web-platform-tests/resource-timing/rt-nextHopProtocol.worker.js: Added. New tests specific to just checking the nextHopProtocol property with a non-cached resource to avoid flakeyness. Source/WebCore: This patch replaces the unused `double finishTime` in ResourceLoader's didFinishLoad with a complete WebCore::NetworkLoadMetrics object. This allows the NetworkProcess to give complete timing information, and more final metrics about the load, to WebCore. Currently this is only used by ResourceTiming, but it will soon be used by Web Inspector as well. We may also end up extending this to the didFail path as well, since it is possible that we have some metrics for load failures. At the same time we want to start moving away from the legacy path that populated a subset of this information in ResourceResponse's NetworkLoadMetrics. It doesn't make sense to store this information on the ResourceResponse for a few reasons: We don't want to store the metrics in our Network Cache and not all of the load timing metrics have been populated yet (responseEnd). In an effort to move off of this data we've renamed the accessor to "deprecatedNetworkLoadMetrics". There are a few remaining clients (ResourceHandle, PerformanceTiming, InspectorNetworkAgent) which can be migrated separately from this patch. Having both the legacy and new code paths adds a little bit of complexity. One advantage of the new path is that the complete load timing data (fetchStart -> dns -> connect -> request -> response -> responseEnd) can be packaged together. The legacy path could not include a responseEnd, so WebCore faked that value with its own timestamp. Having the fake responseEnd caused issues as timestamps / clocks are different between processes. In order for PerformanceResponseTiming to know whether or not the NetworkLoadMetrics has the complete network timing metrics it checks isComplete(). If true it knows it can use the responseEnd time from NetworkLoadMetrics, otherwise it must fallback to the legacy value from LoadTiming. Once all of the deprecatedNetworkLoadMetrics clients go away, we should always have the complete data and this can be eliminated. Tests: imported/w3c/web-platform-tests/resource-timing/rt-nextHopProtocol.html imported/w3c/web-platform-tests/resource-timing/rt-nextHopProtocol.worker.html * PlatformMac.cmake: * WebCore.xcodeproj/project.pbxproj: Rename NetworkLoadTiming -> NetworkLoadMetrics. * page/PerformanceResourceTiming.cpp: (WebCore::entryStartTime): (WebCore::entryEndTime): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::nextHopProtocol): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): * page/PerformanceResourceTiming.h: Mostly just updating names and types. This does however need to get the correct endTime based on whether the NetworkLoadMetrics are complete (meaning includes responseEnd) or not (legacy, use LoadTiming value). * page/PerformanceResourceTiming.idl: Add nextHopProtocol. * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::domainLookupStart): (WebCore::PerformanceTiming::domainLookupEnd): (WebCore::PerformanceTiming::connectStart): (WebCore::PerformanceTiming::connectEnd): (WebCore::PerformanceTiming::secureConnectionStart): (WebCore::PerformanceTiming::requestStart): (WebCore::PerformanceTiming::responseStart): (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart): * page/PerformanceTiming.h: Navigation Timing values still uses the NetworkLoadTiming values stored on the DocumentLoader. This should be moved off of the deprecated path separately. * platform/network/NetworkLoadMetrics.h: Renamed from Source/WebCore/platform/network/NetworkLoadTiming.h. (WebCore::NetworkLoadMetrics::NetworkLoadMetrics): (WebCore::NetworkLoadMetrics::isolatedCopy): (WebCore::NetworkLoadMetrics::reset): (WebCore::NetworkLoadMetrics::operator==): (WebCore::NetworkLoadMetrics::operator!=): (WebCore::NetworkLoadMetrics::isComplete): (WebCore::NetworkLoadMetrics::markComplete): (WebCore::NetworkLoadMetrics::encode): (WebCore::NetworkLoadMetrics::decode): Re-introduce a reset() method (for NetworkLoadSoup to reset between redirects). Add protocolName and "complete" boolean. * platform/network/cocoa/NetworkLoadMetrics.mm: Renamed from Source/WebCore/platform/network/cocoa/NetworkLoadTiming.mm. (WebCore::timingValue): (WebCore::copyTimingData): (WebCore::setCollectsTimingData): Use this opportunity to convert NetworkLoadTiming timestamps to WTF::Seconds. Since we already have to modify all the clients this moves us to use the more strongly typed units that are less ambiguous then "double". The rest of the Performance API has already moved to these units. * inspector/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): (WebCore::InspectorNetworkAgent::didFinishLoading): * inspector/InspectorNetworkAgent.h: Inspector was the only client of the finishTime, and since the value was erratically coming from clients in different ways it was almost certainly inaccurate. Simplify this in preparation for using NetworkLoadMetrics. * Modules/fetch/FetchLoader.cpp: (WebCore::FetchLoader::didFinishLoading): * Modules/fetch/FetchLoader.h: * fileapi/FileReaderLoader.cpp: (WebCore::FileReaderLoader::didFinishLoading): * fileapi/FileReaderLoader.h: * html/MediaFragmentURIParser.cpp: (WebCore::MediaFragmentURIParser::parseNPTTime): * inspector/InspectorInstrumentation.cpp: (WebCore::InspectorInstrumentation::didFinishLoadingImpl): * inspector/InspectorInstrumentation.h: (WebCore::InspectorInstrumentation::didFinishLoading): * loader/CrossOriginPreflightChecker.cpp: (WebCore::CrossOriginPreflightChecker::validatePreflightResponse): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::notifyFinished): (WebCore::DocumentLoader::finishedLoading): (WebCore::DocumentLoader::continueAfterContentPolicy): (WebCore::DocumentLoader::maybeLoadEmpty): * loader/DocumentLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::didReceiveResponse): (WebCore::DocumentThreadableLoader::notifyFinished): (WebCore::DocumentThreadableLoader::didFinishLoading): (WebCore::DocumentThreadableLoader::loadRequest): * loader/DocumentThreadableLoader.h: * loader/NetscapePlugInStreamLoader.cpp: (WebCore::NetscapePlugInStreamLoader::didFinishLoading): * loader/NetscapePlugInStreamLoader.h: * loader/ResourceLoadNotifier.cpp: (WebCore::ResourceLoadNotifier::didFinishLoad): (WebCore::ResourceLoadNotifier::dispatchDidFinishLoading): (WebCore::ResourceLoadNotifier::sendRemainingDelegateMessages): * loader/ResourceLoadNotifier.h: * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::deliverResponseAndData): (WebCore::ResourceLoader::loadDataURL): (WebCore::ResourceLoader::didFinishLoading): (WebCore::ResourceLoader::didFinishLoadingOnePart): * loader/ResourceLoader.h: * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: (WebCore::ResourceTiming::networkLoadMetrics): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::networkLoadTiming): Deleted. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::SubresourceLoader): (WebCore::SubresourceLoader::willSendRequestInternal): (WebCore::SubresourceLoader::didReceiveResponse): (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishLoading): * loader/ThreadableLoaderClientWrapper.h: (WebCore::ThreadableLoaderClientWrapper::didFinishLoading): * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishLoading): * loader/WorkerThreadableLoader.h: * loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::didFinishLoading): * loader/appcache/ApplicationCacheGroup.h: * loader/cache/CachedResource.h: (WebCore::CachedResource::setLoadFinishTime): * loader/ios/QuickLook.mm: (-[WebPreviewLoader connectionDidFinishLoading:]): * page/EventSource.cpp: (WebCore::EventSource::didFinishLoading): * page/EventSource.h: * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp: (ResourceHandleStreamingClient::didFinishLoading): * platform/network/BlobResourceHandle.cpp: (WebCore::doNotifyFinish): * platform/network/PingHandle.h: * platform/network/ResourceHandle.h: * platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::didFinishLoading): * platform/network/ResourceResponseBase.cpp: (WebCore::ResourceResponseBase::crossThreadData): (WebCore::ResourceResponseBase::fromCrossThreadData): (WebCore::ResourceResponseBase::compare): * platform/network/ResourceResponseBase.h: (WebCore::ResourceResponseBase::deprecatedNetworkLoadMetrics): (WebCore::ResourceResponseBase::encode): (WebCore::ResourceResponseBase::decode): (WebCore::ResourceResponseBase::networkLoadTiming): Deleted. * platform/network/SynchronousLoaderClient.cpp: (WebCore::SynchronousLoaderClient::didFinishLoading): * platform/network/SynchronousLoaderClient.h: * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp: (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveResponse): (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading): * platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp: (WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didReceiveResponse): (WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didFinishLoading): * platform/network/curl/ResourceHandleCurl.cpp: (WebCore::WebCoreSynchronousLoader::didFinishLoading): * platform/network/curl/ResourceHandleManager.cpp: (WebCore::calculateWebTimingInformations): (WebCore::ResourceHandleManager::downloadTimerCallback): (WebCore::handleDataURL): (WebCore::milisecondsSinceRequest): Deleted. * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::getConnectionTimingData): * platform/network/mac/WebCoreResourceHandleAsDelegate.mm: (-[WebCoreResourceHandleAsDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsDelegate connectionDidFinishLoading:]): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]): * platform/network/soup/ResourceHandleSoup.cpp: (WebCore::restartedCallback): (WebCore::nextMultipartResponsePartCallback): (WebCore::sendRequestCallback): (WebCore::ResourceHandle::didStartRequest): (WebCore::networkEventCallback): (WebCore::ResourceHandle::sendPendingRequest): (WebCore::readCallback): (WebCore::milisecondsSinceRequest): Deleted. * workers/WorkerScriptLoader.cpp: (WebCore::WorkerScriptLoader::didFinishLoading): * workers/WorkerScriptLoader.h: * xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::didFinishLoading): * xml/XMLHttpRequest.h: Eliminate the unused finishTime double. Source/WebKit2: Change from an unused `double finishTime` to a complete WebCore::NetworkLoadMetrics object in the didFinishLoad ResourceLoader path. We may also extend this in the didFail path later on. This allows the NetworkProcess to give complete timing information, and more final metrics about the load, to WebCore. * NetworkProcess/NetworkDataTask.h: (WebKit::NetworkDataTaskClient::didCompleteWithError): Give the NetworkDataTaskClient a basic didCompleteWithError for a completion without metrics. For loads that complete with an error, or haven't populated any metrics, this will pass empty metrics onward. * NetworkProcess/Downloads/BlobDownloadClient.cpp: (WebKit::BlobDownloadClient::didFinishLoading): * NetworkProcess/Downloads/BlobDownloadClient.h: * NetworkProcess/Downloads/PendingDownload.h: * NetworkProcess/PingLoad.h: * NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp: (WebKit::NetworkCache::SpeculativeLoad::didFinishLoading): * NetworkProcess/cache/NetworkCacheSpeculativeLoad.h: * NetworkProcess/NetworkDataTaskBlob.cpp: (WebKit::NetworkDataTaskBlob::didFail): * NetworkProcess/NetworkLoad.cpp: (WebKit::NetworkLoad::continueWillSendRequest): (WebKit::NetworkLoad::didCompleteWithError): (WebKit::NetworkLoad::didFinishLoading): * NetworkProcess/NetworkLoad.h: * NetworkProcess/NetworkLoadClient.h: * NetworkProcess/NetworkResourceLoader.cpp: (WebKit::NetworkResourceLoader::didFinishLoading): (WebKit::NetworkResourceLoader::sendResultForCacheEntry): * NetworkProcess/NetworkResourceLoader.h: * WebProcess/Network/WebResourceLoader.cpp: (WebKit::WebResourceLoader::didFinishResourceLoad): (WebKit::WebResourceLoader::didReceiveResource): * WebProcess/Network/WebResourceLoader.h: * WebProcess/Network/WebResourceLoader.messages.in: Change didFinishLoad paths to take a NetworkLoadMetrics object instead of finishTime. Change didCompleteWithError pathes to include a NetworkLoadMetrics object instead of finishTime. * NetworkProcess/cocoa/NetworkDataTaskCocoa.h: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::didCompleteWithError): Own a NetworkLoadTiming that will be populated with the load. * NetworkProcess/cocoa/NetworkSessionCocoa.h: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didCompleteWithError:]): (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]): (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): Populate NetworkLoadMetrics in the didFinishCollectingMetrics NSURLSessionTaskDelegate method. * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): (WebKit::NetworkDataTaskSoup::timeoutFired): (WebKit::NetworkDataTaskSoup::didSendRequest): (WebKit::NetworkDataTaskSoup::dispatchDidReceiveResponse): (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError): (WebKit::NetworkDataTaskSoup::tlsErrorsChanged): (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): (WebKit::NetworkDataTaskSoup::didFinishRead): (WebKit::NetworkDataTaskSoup::didFinishRequestNextPart): (WebKit::NetworkDataTaskSoup::didFailDownload): (WebKit::NetworkDataTaskSoup::didFail): (WebKit::NetworkDataTaskSoup::networkEvent): (WebKit::NetworkDataTaskSoup::didStartRequest): (WebKit::NetworkDataTaskSoup::didRestart): * NetworkProcess/soup/NetworkDataTaskSoup.h: Instead of populating the NetworkLoadMetrics on the ResourceResponse, populate a member variable during the entire load and dispatch didFinishCollectingMetrics right before didCompleteLoadWithError. Source/WTF: * wtf/persistence/Coders.h: (WTF::Persistence::Coder<Seconds>::encode): (WTF::Persistence::Coder<Seconds>::decode): LayoutTests: * TestExpectations: Now that nextHopProtocol is available on Mac mark the test as flakey because the value can be set or not depending on whether or not the resource was loaded from a cache. * platform/ios-simulator/TestExpectations: * platform/gtk/TestExpectations: * platform/mac/TestExpectations: * platform/win/TestExpectations: Mark nextHopProtocol tests as expected to fail on ports that do not yet support those values. Mark redirect tests as failing on ports that encounter the CFNetwork issue causing unexpected callbacks. * performance-api/resource-timing-apis-expected.txt: * performance-api/resources/resource-timing-api.js: Progressions. * platform/mac-elcapitan/imported/w3c/web-platform-tests/resource-timing/test_resource_timing-expected.txt: Added. * platform/mac/imported/w3c/web-platform-tests/resource-timing/test_resource_timing-expected.txt: Added. Expected passing values on mac, except el capitan where this new resource timing data is unavailable. Canonical link: https://commits.webkit.org/185854@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212993 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-25 05:48:51 +00:00
, m_networkLoadMetrics(networkLoadMetrics)
Add the PerformanceServerTiming Interface which makes Server-Timing header timing values available to JavaScript running in the browser. https://bugs.webkit.org/show_bug.cgi?id=175569 Patch by Charles Vazac <cvazac@gmail.com> on 2018-05-15 Reviewed by Youenn Fablet. Tests were imported from web-platform-tests: WebKit/LayoutTests/imported/w3c/web-platform-tests/server-timing/* LayoutTests/imported/w3c: * web-platform-tests/server-timing/cross_origin.html: Added. * web-platform-tests/server-timing/navigation_timing_idl.html: Added. * web-platform-tests/server-timing/navigation_timing_idl.https.html: Added. * web-platform-tests/server-timing/resources/blue.png: Added. * web-platform-tests/server-timing/resources/blue.png.sub.headers: Added. * web-platform-tests/server-timing/resources/blue_tao.png: Added. * web-platform-tests/server-timing/resources/blue_tao.png.sub.headers: Added. * web-platform-tests/server-timing/resources/green.png: Added. * web-platform-tests/server-timing/resources/green.png.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/0.js: Added. * web-platform-tests/server-timing/resources/parsing/0.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/1.js: Added. * web-platform-tests/server-timing/resources/parsing/1.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/10.js: Added. * web-platform-tests/server-timing/resources/parsing/10.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/11.js: Added. * web-platform-tests/server-timing/resources/parsing/11.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/12.js: Added. * web-platform-tests/server-timing/resources/parsing/12.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/13.js: Added. * web-platform-tests/server-timing/resources/parsing/13.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/14.js: Added. * web-platform-tests/server-timing/resources/parsing/14.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/15.js: Added. * web-platform-tests/server-timing/resources/parsing/15.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/16.js: Added. * web-platform-tests/server-timing/resources/parsing/16.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/17.js: Added. * web-platform-tests/server-timing/resources/parsing/17.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/18.js: Added. * web-platform-tests/server-timing/resources/parsing/18.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/19.js: Added. * web-platform-tests/server-timing/resources/parsing/19.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/2.js: Added. * web-platform-tests/server-timing/resources/parsing/2.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/20.js: Added. * web-platform-tests/server-timing/resources/parsing/20.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/21.js: Added. * web-platform-tests/server-timing/resources/parsing/21.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/22.js: Added. * web-platform-tests/server-timing/resources/parsing/22.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/23.js: Added. * web-platform-tests/server-timing/resources/parsing/23.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/24.js: Added. * web-platform-tests/server-timing/resources/parsing/24.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/25.js: Added. * web-platform-tests/server-timing/resources/parsing/25.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/26.js: Added. * web-platform-tests/server-timing/resources/parsing/26.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/27.js: Added. * web-platform-tests/server-timing/resources/parsing/27.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/28.js: Added. * web-platform-tests/server-timing/resources/parsing/28.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/29.js: Added. * web-platform-tests/server-timing/resources/parsing/29.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/3.js: Added. * web-platform-tests/server-timing/resources/parsing/3.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/30.js: Added. * web-platform-tests/server-timing/resources/parsing/30.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/31.js: Added. * web-platform-tests/server-timing/resources/parsing/31.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/32.js: Added. * web-platform-tests/server-timing/resources/parsing/32.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/33.js: Added. * web-platform-tests/server-timing/resources/parsing/33.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/34.js: Added. * web-platform-tests/server-timing/resources/parsing/34.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/35.js: Added. * web-platform-tests/server-timing/resources/parsing/35.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/36.js: Added. * web-platform-tests/server-timing/resources/parsing/36.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/37.js: Added. * web-platform-tests/server-timing/resources/parsing/37.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/38.js: Added. * web-platform-tests/server-timing/resources/parsing/38.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/39.js: Added. * web-platform-tests/server-timing/resources/parsing/39.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/4.js: Added. * web-platform-tests/server-timing/resources/parsing/4.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/40.js: Added. * web-platform-tests/server-timing/resources/parsing/40.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/41.js: Added. * web-platform-tests/server-timing/resources/parsing/41.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/42.js: Added. * web-platform-tests/server-timing/resources/parsing/42.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/43.js: Added. * web-platform-tests/server-timing/resources/parsing/43.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/44.js: Added. * web-platform-tests/server-timing/resources/parsing/44.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/45.js: Added. * web-platform-tests/server-timing/resources/parsing/45.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/46.js: Added. * web-platform-tests/server-timing/resources/parsing/46.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/47.js: Added. * web-platform-tests/server-timing/resources/parsing/47.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/48.js: Added. * web-platform-tests/server-timing/resources/parsing/48.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/49.js: Added. * web-platform-tests/server-timing/resources/parsing/49.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/5.js: Added. * web-platform-tests/server-timing/resources/parsing/5.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/50.js: Added. * web-platform-tests/server-timing/resources/parsing/50.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/51.js: Added. * web-platform-tests/server-timing/resources/parsing/51.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/52.js: Added. * web-platform-tests/server-timing/resources/parsing/52.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/53.js: Added. * web-platform-tests/server-timing/resources/parsing/53.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/54.js: Added. * web-platform-tests/server-timing/resources/parsing/54.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/55.js: Added. * web-platform-tests/server-timing/resources/parsing/55.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/56.js: Added. * web-platform-tests/server-timing/resources/parsing/56.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/57.js: Added. * web-platform-tests/server-timing/resources/parsing/57.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/58.js: Added. * web-platform-tests/server-timing/resources/parsing/58.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/59.js: Added. * web-platform-tests/server-timing/resources/parsing/59.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/6.js: Added. * web-platform-tests/server-timing/resources/parsing/6.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/60.js: Added. * web-platform-tests/server-timing/resources/parsing/60.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/61.js: Added. * web-platform-tests/server-timing/resources/parsing/61.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/62.js: Added. * web-platform-tests/server-timing/resources/parsing/62.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/63.js: Added. * web-platform-tests/server-timing/resources/parsing/63.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/64.js: Added. * web-platform-tests/server-timing/resources/parsing/64.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/65.js: Added. * web-platform-tests/server-timing/resources/parsing/65.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/66.js: Added. * web-platform-tests/server-timing/resources/parsing/66.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/67.js: Added. * web-platform-tests/server-timing/resources/parsing/67.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/68.js: Added. * web-platform-tests/server-timing/resources/parsing/68.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/69.js: Added. * web-platform-tests/server-timing/resources/parsing/69.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/7.js: Added. * web-platform-tests/server-timing/resources/parsing/7.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/70.js: Added. * web-platform-tests/server-timing/resources/parsing/70.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/71.js: Added. * web-platform-tests/server-timing/resources/parsing/71.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/72.js: Added. * web-platform-tests/server-timing/resources/parsing/72.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/73.js: Added. * web-platform-tests/server-timing/resources/parsing/73.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/74.js: Added. * web-platform-tests/server-timing/resources/parsing/74.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/75.js: Added. * web-platform-tests/server-timing/resources/parsing/75.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/76.js: Added. * web-platform-tests/server-timing/resources/parsing/76.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/77.js: Added. * web-platform-tests/server-timing/resources/parsing/77.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/78.js: Added. * web-platform-tests/server-timing/resources/parsing/78.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/79.js: Added. * web-platform-tests/server-timing/resources/parsing/79.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/8.js: Added. * web-platform-tests/server-timing/resources/parsing/8.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/80.js: Added. * web-platform-tests/server-timing/resources/parsing/80.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/81.js: Added. * web-platform-tests/server-timing/resources/parsing/81.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/82.js: Added. * web-platform-tests/server-timing/resources/parsing/82.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/83.js: Added. * web-platform-tests/server-timing/resources/parsing/83.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/9.js: Added. * web-platform-tests/server-timing/resources/parsing/9.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/w3c-import.log: Added. * web-platform-tests/server-timing/resources/w3c-import.log: Added. * web-platform-tests/server-timing/resource_timing_idl.html: Added. * web-platform-tests/server-timing/resource_timing_idl.https.html: Added. * web-platform-tests/server-timing/server_timing_header-parsing.html: Added. * web-platform-tests/server-timing/server_timing_header-parsing.https.html: Added. * web-platform-tests/server-timing/test_server_timing.html: Added. * web-platform-tests/server-timing/test_server_timing.html.sub.headers: Added. * web-platform-tests/server-timing/test_server_timing.https.html: Added. * web-platform-tests/server-timing/test_server_timing.https.html.sub.headers: Added. * web-platform-tests/server-timing/w3c-import.log: Added. Source/WebCore: * Sources.txt: Added references to HeaderFieldTokenizer.cpp, ServerTiming.cpp, and ServerTimingParser.cpp. * WebCore.xcodeproj/project.pbxproj: Added various files. * loader/HeaderFieldTokenizer.cpp: Added. (WebCore::HeaderFieldTokenizer::HeaderFieldTokenizer): Added class for tokenizing header values. (WebCore::HeaderFieldTokenizer::consume): Added method to consume a specified character. (WebCore::HeaderFieldTokenizer::consumeQuotedString): Added method to consume a quote-string. (WebCore::HeaderFieldTokenizer::consumeToken): Added a method to consume a token. (WebCore::HeaderFieldTokenizer::consumeTokenOrQuotedString): Added method to consume a quote-string or quote-string, depending on net character. (WebCore::HeaderFieldTokenizer::skipSpaces): Added method to skip whitespace. (WebCore::HeaderFieldTokenizer::consumeBeforeAnyCharMatch): Added method to advance the cursor up until any of a list of characters. * loader/HeaderFieldTokenizer.h: Added. * loader/HTTPHeaderField.cpp: Expose isTokenCharacter and isWhitespace. * loader/HTTPHeaderField.h: Expose isTokenCharacter and isWhitespace. * loader/PolicyChecker.cpp: Added #include so source compiled on my machine. * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::ResourceTiming): Added call to initServerTiming to parse the header. (WebCore::ResourceTiming::initServerTiming): Added method to parse the header. (WebCore::ResourceTiming::populateServerTiming): Added method to populate the server timing entries on a PerformanceResourceTiming object. (WebCore::ResourceTiming::isolatedCopy const): Added code to copy over the server timing entries. * loader/ResourceTiming.h: (WebCore::ResourceTiming::ResourceTiming): Accept collection of server timing entries in c'tor. * loader/ServerTiming.cpp: Added. (WebCore::ServerTiming::setParameter): Set named parameters, ignoring unrecognized or duplicates. (WebCore::ServerTiming::isolatedCopy const): Return a new pointer to the object. * loader/ServerTiming.h: Added. (WebCore::ServerTiming::ServerTiming): Added struct for the data needed by a server timing entry. (WebCore::ServerTiming::name const): Added name field of a server timing entry. (WebCore::ServerTiming::duration const): Added duration field of a server timing entry. (WebCore::ServerTiming::description const): Added description field of a server timing entry. * loader/ServerTimingParser.cpp: Added. (WebCore::ServerTimingParser::parseServerTiming): Parses the header generating a collection of server timing structs. * loader/ServerTimingParser.h: Added. * loader/WorkerThreadableLoader.h: Fix build. * page/Performance.cpp: (WebCore::Performance::addResourceTiming): Fixed a typo. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): Given a ResourceTiming object, populate our collection of PerformanceServerTiming objects. * page/PerformanceResourceTiming.h: Added serverTiming member and getter. * page/PerformanceResourceTiming.idl: Added serverTiming member to interface. * platform/network/HTTPHeaderNames.in: Added "Server-Timing" to the header enum. * platform/network/ResourceResponseBase.cpp: Added "Server-Timing" to isSafeCrossOriginResponseHeader whitelist. LayoutTests: * imported/w3c/web-platform-tests/server-timing/cross_origin-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/resource_timing_idl-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/resource_timing_idl.https-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/server_timing_header-parsing-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/server_timing_header-parsing.https-expected.txt: Added. Canonical link: https://commits.webkit.org/201126@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-15 19:24:30 +00:00
{
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
if (RuntimeEnabledFeatures::sharedFeatures().serverTimingEnabled() && !m_networkLoadMetrics.failsTAOCheck)
Add the PerformanceServerTiming Interface which makes Server-Timing header timing values available to JavaScript running in the browser. https://bugs.webkit.org/show_bug.cgi?id=175569 Patch by Charles Vazac <cvazac@gmail.com> on 2018-05-15 Reviewed by Youenn Fablet. Tests were imported from web-platform-tests: WebKit/LayoutTests/imported/w3c/web-platform-tests/server-timing/* LayoutTests/imported/w3c: * web-platform-tests/server-timing/cross_origin.html: Added. * web-platform-tests/server-timing/navigation_timing_idl.html: Added. * web-platform-tests/server-timing/navigation_timing_idl.https.html: Added. * web-platform-tests/server-timing/resources/blue.png: Added. * web-platform-tests/server-timing/resources/blue.png.sub.headers: Added. * web-platform-tests/server-timing/resources/blue_tao.png: Added. * web-platform-tests/server-timing/resources/blue_tao.png.sub.headers: Added. * web-platform-tests/server-timing/resources/green.png: Added. * web-platform-tests/server-timing/resources/green.png.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/0.js: Added. * web-platform-tests/server-timing/resources/parsing/0.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/1.js: Added. * web-platform-tests/server-timing/resources/parsing/1.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/10.js: Added. * web-platform-tests/server-timing/resources/parsing/10.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/11.js: Added. * web-platform-tests/server-timing/resources/parsing/11.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/12.js: Added. * web-platform-tests/server-timing/resources/parsing/12.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/13.js: Added. * web-platform-tests/server-timing/resources/parsing/13.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/14.js: Added. * web-platform-tests/server-timing/resources/parsing/14.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/15.js: Added. * web-platform-tests/server-timing/resources/parsing/15.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/16.js: Added. * web-platform-tests/server-timing/resources/parsing/16.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/17.js: Added. * web-platform-tests/server-timing/resources/parsing/17.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/18.js: Added. * web-platform-tests/server-timing/resources/parsing/18.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/19.js: Added. * web-platform-tests/server-timing/resources/parsing/19.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/2.js: Added. * web-platform-tests/server-timing/resources/parsing/2.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/20.js: Added. * web-platform-tests/server-timing/resources/parsing/20.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/21.js: Added. * web-platform-tests/server-timing/resources/parsing/21.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/22.js: Added. * web-platform-tests/server-timing/resources/parsing/22.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/23.js: Added. * web-platform-tests/server-timing/resources/parsing/23.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/24.js: Added. * web-platform-tests/server-timing/resources/parsing/24.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/25.js: Added. * web-platform-tests/server-timing/resources/parsing/25.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/26.js: Added. * web-platform-tests/server-timing/resources/parsing/26.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/27.js: Added. * web-platform-tests/server-timing/resources/parsing/27.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/28.js: Added. * web-platform-tests/server-timing/resources/parsing/28.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/29.js: Added. * web-platform-tests/server-timing/resources/parsing/29.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/3.js: Added. * web-platform-tests/server-timing/resources/parsing/3.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/30.js: Added. * web-platform-tests/server-timing/resources/parsing/30.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/31.js: Added. * web-platform-tests/server-timing/resources/parsing/31.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/32.js: Added. * web-platform-tests/server-timing/resources/parsing/32.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/33.js: Added. * web-platform-tests/server-timing/resources/parsing/33.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/34.js: Added. * web-platform-tests/server-timing/resources/parsing/34.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/35.js: Added. * web-platform-tests/server-timing/resources/parsing/35.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/36.js: Added. * web-platform-tests/server-timing/resources/parsing/36.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/37.js: Added. * web-platform-tests/server-timing/resources/parsing/37.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/38.js: Added. * web-platform-tests/server-timing/resources/parsing/38.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/39.js: Added. * web-platform-tests/server-timing/resources/parsing/39.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/4.js: Added. * web-platform-tests/server-timing/resources/parsing/4.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/40.js: Added. * web-platform-tests/server-timing/resources/parsing/40.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/41.js: Added. * web-platform-tests/server-timing/resources/parsing/41.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/42.js: Added. * web-platform-tests/server-timing/resources/parsing/42.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/43.js: Added. * web-platform-tests/server-timing/resources/parsing/43.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/44.js: Added. * web-platform-tests/server-timing/resources/parsing/44.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/45.js: Added. * web-platform-tests/server-timing/resources/parsing/45.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/46.js: Added. * web-platform-tests/server-timing/resources/parsing/46.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/47.js: Added. * web-platform-tests/server-timing/resources/parsing/47.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/48.js: Added. * web-platform-tests/server-timing/resources/parsing/48.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/49.js: Added. * web-platform-tests/server-timing/resources/parsing/49.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/5.js: Added. * web-platform-tests/server-timing/resources/parsing/5.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/50.js: Added. * web-platform-tests/server-timing/resources/parsing/50.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/51.js: Added. * web-platform-tests/server-timing/resources/parsing/51.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/52.js: Added. * web-platform-tests/server-timing/resources/parsing/52.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/53.js: Added. * web-platform-tests/server-timing/resources/parsing/53.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/54.js: Added. * web-platform-tests/server-timing/resources/parsing/54.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/55.js: Added. * web-platform-tests/server-timing/resources/parsing/55.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/56.js: Added. * web-platform-tests/server-timing/resources/parsing/56.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/57.js: Added. * web-platform-tests/server-timing/resources/parsing/57.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/58.js: Added. * web-platform-tests/server-timing/resources/parsing/58.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/59.js: Added. * web-platform-tests/server-timing/resources/parsing/59.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/6.js: Added. * web-platform-tests/server-timing/resources/parsing/6.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/60.js: Added. * web-platform-tests/server-timing/resources/parsing/60.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/61.js: Added. * web-platform-tests/server-timing/resources/parsing/61.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/62.js: Added. * web-platform-tests/server-timing/resources/parsing/62.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/63.js: Added. * web-platform-tests/server-timing/resources/parsing/63.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/64.js: Added. * web-platform-tests/server-timing/resources/parsing/64.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/65.js: Added. * web-platform-tests/server-timing/resources/parsing/65.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/66.js: Added. * web-platform-tests/server-timing/resources/parsing/66.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/67.js: Added. * web-platform-tests/server-timing/resources/parsing/67.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/68.js: Added. * web-platform-tests/server-timing/resources/parsing/68.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/69.js: Added. * web-platform-tests/server-timing/resources/parsing/69.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/7.js: Added. * web-platform-tests/server-timing/resources/parsing/7.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/70.js: Added. * web-platform-tests/server-timing/resources/parsing/70.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/71.js: Added. * web-platform-tests/server-timing/resources/parsing/71.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/72.js: Added. * web-platform-tests/server-timing/resources/parsing/72.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/73.js: Added. * web-platform-tests/server-timing/resources/parsing/73.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/74.js: Added. * web-platform-tests/server-timing/resources/parsing/74.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/75.js: Added. * web-platform-tests/server-timing/resources/parsing/75.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/76.js: Added. * web-platform-tests/server-timing/resources/parsing/76.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/77.js: Added. * web-platform-tests/server-timing/resources/parsing/77.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/78.js: Added. * web-platform-tests/server-timing/resources/parsing/78.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/79.js: Added. * web-platform-tests/server-timing/resources/parsing/79.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/8.js: Added. * web-platform-tests/server-timing/resources/parsing/8.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/80.js: Added. * web-platform-tests/server-timing/resources/parsing/80.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/81.js: Added. * web-platform-tests/server-timing/resources/parsing/81.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/82.js: Added. * web-platform-tests/server-timing/resources/parsing/82.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/83.js: Added. * web-platform-tests/server-timing/resources/parsing/83.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/9.js: Added. * web-platform-tests/server-timing/resources/parsing/9.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/w3c-import.log: Added. * web-platform-tests/server-timing/resources/w3c-import.log: Added. * web-platform-tests/server-timing/resource_timing_idl.html: Added. * web-platform-tests/server-timing/resource_timing_idl.https.html: Added. * web-platform-tests/server-timing/server_timing_header-parsing.html: Added. * web-platform-tests/server-timing/server_timing_header-parsing.https.html: Added. * web-platform-tests/server-timing/test_server_timing.html: Added. * web-platform-tests/server-timing/test_server_timing.html.sub.headers: Added. * web-platform-tests/server-timing/test_server_timing.https.html: Added. * web-platform-tests/server-timing/test_server_timing.https.html.sub.headers: Added. * web-platform-tests/server-timing/w3c-import.log: Added. Source/WebCore: * Sources.txt: Added references to HeaderFieldTokenizer.cpp, ServerTiming.cpp, and ServerTimingParser.cpp. * WebCore.xcodeproj/project.pbxproj: Added various files. * loader/HeaderFieldTokenizer.cpp: Added. (WebCore::HeaderFieldTokenizer::HeaderFieldTokenizer): Added class for tokenizing header values. (WebCore::HeaderFieldTokenizer::consume): Added method to consume a specified character. (WebCore::HeaderFieldTokenizer::consumeQuotedString): Added method to consume a quote-string. (WebCore::HeaderFieldTokenizer::consumeToken): Added a method to consume a token. (WebCore::HeaderFieldTokenizer::consumeTokenOrQuotedString): Added method to consume a quote-string or quote-string, depending on net character. (WebCore::HeaderFieldTokenizer::skipSpaces): Added method to skip whitespace. (WebCore::HeaderFieldTokenizer::consumeBeforeAnyCharMatch): Added method to advance the cursor up until any of a list of characters. * loader/HeaderFieldTokenizer.h: Added. * loader/HTTPHeaderField.cpp: Expose isTokenCharacter and isWhitespace. * loader/HTTPHeaderField.h: Expose isTokenCharacter and isWhitespace. * loader/PolicyChecker.cpp: Added #include so source compiled on my machine. * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::ResourceTiming): Added call to initServerTiming to parse the header. (WebCore::ResourceTiming::initServerTiming): Added method to parse the header. (WebCore::ResourceTiming::populateServerTiming): Added method to populate the server timing entries on a PerformanceResourceTiming object. (WebCore::ResourceTiming::isolatedCopy const): Added code to copy over the server timing entries. * loader/ResourceTiming.h: (WebCore::ResourceTiming::ResourceTiming): Accept collection of server timing entries in c'tor. * loader/ServerTiming.cpp: Added. (WebCore::ServerTiming::setParameter): Set named parameters, ignoring unrecognized or duplicates. (WebCore::ServerTiming::isolatedCopy const): Return a new pointer to the object. * loader/ServerTiming.h: Added. (WebCore::ServerTiming::ServerTiming): Added struct for the data needed by a server timing entry. (WebCore::ServerTiming::name const): Added name field of a server timing entry. (WebCore::ServerTiming::duration const): Added duration field of a server timing entry. (WebCore::ServerTiming::description const): Added description field of a server timing entry. * loader/ServerTimingParser.cpp: Added. (WebCore::ServerTimingParser::parseServerTiming): Parses the header generating a collection of server timing structs. * loader/ServerTimingParser.h: Added. * loader/WorkerThreadableLoader.h: Fix build. * page/Performance.cpp: (WebCore::Performance::addResourceTiming): Fixed a typo. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): Given a ResourceTiming object, populate our collection of PerformanceServerTiming objects. * page/PerformanceResourceTiming.h: Added serverTiming member and getter. * page/PerformanceResourceTiming.idl: Added serverTiming member to interface. * platform/network/HTTPHeaderNames.in: Added "Server-Timing" to the header enum. * platform/network/ResourceResponseBase.cpp: Added "Server-Timing" to isSafeCrossOriginResponseHeader whitelist. LayoutTests: * imported/w3c/web-platform-tests/server-timing/cross_origin-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/resource_timing_idl-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/resource_timing_idl.https-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/server_timing_header-parsing-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/server_timing_header-parsing.https-expected.txt: Added. Canonical link: https://commits.webkit.org/201126@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-15 19:24:30 +00:00
m_serverTiming = ServerTimingParser::parseServerTiming(response.httpHeaderField(HTTPHeaderName::ServerTiming));
}
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
Vector<Ref<PerformanceServerTiming>> ResourceTiming::populateServerTiming() const
Add the PerformanceServerTiming Interface which makes Server-Timing header timing values available to JavaScript running in the browser. https://bugs.webkit.org/show_bug.cgi?id=175569 Patch by Charles Vazac <cvazac@gmail.com> on 2018-05-15 Reviewed by Youenn Fablet. Tests were imported from web-platform-tests: WebKit/LayoutTests/imported/w3c/web-platform-tests/server-timing/* LayoutTests/imported/w3c: * web-platform-tests/server-timing/cross_origin.html: Added. * web-platform-tests/server-timing/navigation_timing_idl.html: Added. * web-platform-tests/server-timing/navigation_timing_idl.https.html: Added. * web-platform-tests/server-timing/resources/blue.png: Added. * web-platform-tests/server-timing/resources/blue.png.sub.headers: Added. * web-platform-tests/server-timing/resources/blue_tao.png: Added. * web-platform-tests/server-timing/resources/blue_tao.png.sub.headers: Added. * web-platform-tests/server-timing/resources/green.png: Added. * web-platform-tests/server-timing/resources/green.png.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/0.js: Added. * web-platform-tests/server-timing/resources/parsing/0.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/1.js: Added. * web-platform-tests/server-timing/resources/parsing/1.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/10.js: Added. * web-platform-tests/server-timing/resources/parsing/10.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/11.js: Added. * web-platform-tests/server-timing/resources/parsing/11.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/12.js: Added. * web-platform-tests/server-timing/resources/parsing/12.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/13.js: Added. * web-platform-tests/server-timing/resources/parsing/13.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/14.js: Added. * web-platform-tests/server-timing/resources/parsing/14.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/15.js: Added. * web-platform-tests/server-timing/resources/parsing/15.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/16.js: Added. * web-platform-tests/server-timing/resources/parsing/16.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/17.js: Added. * web-platform-tests/server-timing/resources/parsing/17.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/18.js: Added. * web-platform-tests/server-timing/resources/parsing/18.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/19.js: Added. * web-platform-tests/server-timing/resources/parsing/19.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/2.js: Added. * web-platform-tests/server-timing/resources/parsing/2.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/20.js: Added. * web-platform-tests/server-timing/resources/parsing/20.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/21.js: Added. * web-platform-tests/server-timing/resources/parsing/21.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/22.js: Added. * web-platform-tests/server-timing/resources/parsing/22.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/23.js: Added. * web-platform-tests/server-timing/resources/parsing/23.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/24.js: Added. * web-platform-tests/server-timing/resources/parsing/24.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/25.js: Added. * web-platform-tests/server-timing/resources/parsing/25.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/26.js: Added. * web-platform-tests/server-timing/resources/parsing/26.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/27.js: Added. * web-platform-tests/server-timing/resources/parsing/27.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/28.js: Added. * web-platform-tests/server-timing/resources/parsing/28.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/29.js: Added. * web-platform-tests/server-timing/resources/parsing/29.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/3.js: Added. * web-platform-tests/server-timing/resources/parsing/3.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/30.js: Added. * web-platform-tests/server-timing/resources/parsing/30.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/31.js: Added. * web-platform-tests/server-timing/resources/parsing/31.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/32.js: Added. * web-platform-tests/server-timing/resources/parsing/32.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/33.js: Added. * web-platform-tests/server-timing/resources/parsing/33.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/34.js: Added. * web-platform-tests/server-timing/resources/parsing/34.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/35.js: Added. * web-platform-tests/server-timing/resources/parsing/35.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/36.js: Added. * web-platform-tests/server-timing/resources/parsing/36.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/37.js: Added. * web-platform-tests/server-timing/resources/parsing/37.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/38.js: Added. * web-platform-tests/server-timing/resources/parsing/38.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/39.js: Added. * web-platform-tests/server-timing/resources/parsing/39.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/4.js: Added. * web-platform-tests/server-timing/resources/parsing/4.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/40.js: Added. * web-platform-tests/server-timing/resources/parsing/40.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/41.js: Added. * web-platform-tests/server-timing/resources/parsing/41.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/42.js: Added. * web-platform-tests/server-timing/resources/parsing/42.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/43.js: Added. * web-platform-tests/server-timing/resources/parsing/43.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/44.js: Added. * web-platform-tests/server-timing/resources/parsing/44.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/45.js: Added. * web-platform-tests/server-timing/resources/parsing/45.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/46.js: Added. * web-platform-tests/server-timing/resources/parsing/46.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/47.js: Added. * web-platform-tests/server-timing/resources/parsing/47.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/48.js: Added. * web-platform-tests/server-timing/resources/parsing/48.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/49.js: Added. * web-platform-tests/server-timing/resources/parsing/49.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/5.js: Added. * web-platform-tests/server-timing/resources/parsing/5.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/50.js: Added. * web-platform-tests/server-timing/resources/parsing/50.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/51.js: Added. * web-platform-tests/server-timing/resources/parsing/51.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/52.js: Added. * web-platform-tests/server-timing/resources/parsing/52.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/53.js: Added. * web-platform-tests/server-timing/resources/parsing/53.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/54.js: Added. * web-platform-tests/server-timing/resources/parsing/54.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/55.js: Added. * web-platform-tests/server-timing/resources/parsing/55.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/56.js: Added. * web-platform-tests/server-timing/resources/parsing/56.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/57.js: Added. * web-platform-tests/server-timing/resources/parsing/57.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/58.js: Added. * web-platform-tests/server-timing/resources/parsing/58.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/59.js: Added. * web-platform-tests/server-timing/resources/parsing/59.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/6.js: Added. * web-platform-tests/server-timing/resources/parsing/6.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/60.js: Added. * web-platform-tests/server-timing/resources/parsing/60.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/61.js: Added. * web-platform-tests/server-timing/resources/parsing/61.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/62.js: Added. * web-platform-tests/server-timing/resources/parsing/62.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/63.js: Added. * web-platform-tests/server-timing/resources/parsing/63.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/64.js: Added. * web-platform-tests/server-timing/resources/parsing/64.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/65.js: Added. * web-platform-tests/server-timing/resources/parsing/65.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/66.js: Added. * web-platform-tests/server-timing/resources/parsing/66.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/67.js: Added. * web-platform-tests/server-timing/resources/parsing/67.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/68.js: Added. * web-platform-tests/server-timing/resources/parsing/68.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/69.js: Added. * web-platform-tests/server-timing/resources/parsing/69.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/7.js: Added. * web-platform-tests/server-timing/resources/parsing/7.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/70.js: Added. * web-platform-tests/server-timing/resources/parsing/70.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/71.js: Added. * web-platform-tests/server-timing/resources/parsing/71.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/72.js: Added. * web-platform-tests/server-timing/resources/parsing/72.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/73.js: Added. * web-platform-tests/server-timing/resources/parsing/73.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/74.js: Added. * web-platform-tests/server-timing/resources/parsing/74.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/75.js: Added. * web-platform-tests/server-timing/resources/parsing/75.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/76.js: Added. * web-platform-tests/server-timing/resources/parsing/76.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/77.js: Added. * web-platform-tests/server-timing/resources/parsing/77.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/78.js: Added. * web-platform-tests/server-timing/resources/parsing/78.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/79.js: Added. * web-platform-tests/server-timing/resources/parsing/79.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/8.js: Added. * web-platform-tests/server-timing/resources/parsing/8.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/80.js: Added. * web-platform-tests/server-timing/resources/parsing/80.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/81.js: Added. * web-platform-tests/server-timing/resources/parsing/81.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/82.js: Added. * web-platform-tests/server-timing/resources/parsing/82.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/83.js: Added. * web-platform-tests/server-timing/resources/parsing/83.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/9.js: Added. * web-platform-tests/server-timing/resources/parsing/9.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/w3c-import.log: Added. * web-platform-tests/server-timing/resources/w3c-import.log: Added. * web-platform-tests/server-timing/resource_timing_idl.html: Added. * web-platform-tests/server-timing/resource_timing_idl.https.html: Added. * web-platform-tests/server-timing/server_timing_header-parsing.html: Added. * web-platform-tests/server-timing/server_timing_header-parsing.https.html: Added. * web-platform-tests/server-timing/test_server_timing.html: Added. * web-platform-tests/server-timing/test_server_timing.html.sub.headers: Added. * web-platform-tests/server-timing/test_server_timing.https.html: Added. * web-platform-tests/server-timing/test_server_timing.https.html.sub.headers: Added. * web-platform-tests/server-timing/w3c-import.log: Added. Source/WebCore: * Sources.txt: Added references to HeaderFieldTokenizer.cpp, ServerTiming.cpp, and ServerTimingParser.cpp. * WebCore.xcodeproj/project.pbxproj: Added various files. * loader/HeaderFieldTokenizer.cpp: Added. (WebCore::HeaderFieldTokenizer::HeaderFieldTokenizer): Added class for tokenizing header values. (WebCore::HeaderFieldTokenizer::consume): Added method to consume a specified character. (WebCore::HeaderFieldTokenizer::consumeQuotedString): Added method to consume a quote-string. (WebCore::HeaderFieldTokenizer::consumeToken): Added a method to consume a token. (WebCore::HeaderFieldTokenizer::consumeTokenOrQuotedString): Added method to consume a quote-string or quote-string, depending on net character. (WebCore::HeaderFieldTokenizer::skipSpaces): Added method to skip whitespace. (WebCore::HeaderFieldTokenizer::consumeBeforeAnyCharMatch): Added method to advance the cursor up until any of a list of characters. * loader/HeaderFieldTokenizer.h: Added. * loader/HTTPHeaderField.cpp: Expose isTokenCharacter and isWhitespace. * loader/HTTPHeaderField.h: Expose isTokenCharacter and isWhitespace. * loader/PolicyChecker.cpp: Added #include so source compiled on my machine. * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::ResourceTiming): Added call to initServerTiming to parse the header. (WebCore::ResourceTiming::initServerTiming): Added method to parse the header. (WebCore::ResourceTiming::populateServerTiming): Added method to populate the server timing entries on a PerformanceResourceTiming object. (WebCore::ResourceTiming::isolatedCopy const): Added code to copy over the server timing entries. * loader/ResourceTiming.h: (WebCore::ResourceTiming::ResourceTiming): Accept collection of server timing entries in c'tor. * loader/ServerTiming.cpp: Added. (WebCore::ServerTiming::setParameter): Set named parameters, ignoring unrecognized or duplicates. (WebCore::ServerTiming::isolatedCopy const): Return a new pointer to the object. * loader/ServerTiming.h: Added. (WebCore::ServerTiming::ServerTiming): Added struct for the data needed by a server timing entry. (WebCore::ServerTiming::name const): Added name field of a server timing entry. (WebCore::ServerTiming::duration const): Added duration field of a server timing entry. (WebCore::ServerTiming::description const): Added description field of a server timing entry. * loader/ServerTimingParser.cpp: Added. (WebCore::ServerTimingParser::parseServerTiming): Parses the header generating a collection of server timing structs. * loader/ServerTimingParser.h: Added. * loader/WorkerThreadableLoader.h: Fix build. * page/Performance.cpp: (WebCore::Performance::addResourceTiming): Fixed a typo. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): Given a ResourceTiming object, populate our collection of PerformanceServerTiming objects. * page/PerformanceResourceTiming.h: Added serverTiming member and getter. * page/PerformanceResourceTiming.idl: Added serverTiming member to interface. * platform/network/HTTPHeaderNames.in: Added "Server-Timing" to the header enum. * platform/network/ResourceResponseBase.cpp: Added "Server-Timing" to isSafeCrossOriginResponseHeader whitelist. LayoutTests: * imported/w3c/web-platform-tests/server-timing/cross_origin-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/resource_timing_idl-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/resource_timing_idl.https-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/server_timing_header-parsing-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/server_timing_header-parsing.https-expected.txt: Added. Canonical link: https://commits.webkit.org/201126@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-15 19:24:30 +00:00
{
return WTF::map(m_serverTiming, [] (auto& entry) {
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 PerformanceServerTiming::create(String(entry.name), entry.duration, String(entry.description));
Add the PerformanceServerTiming Interface which makes Server-Timing header timing values available to JavaScript running in the browser. https://bugs.webkit.org/show_bug.cgi?id=175569 Patch by Charles Vazac <cvazac@gmail.com> on 2018-05-15 Reviewed by Youenn Fablet. Tests were imported from web-platform-tests: WebKit/LayoutTests/imported/w3c/web-platform-tests/server-timing/* LayoutTests/imported/w3c: * web-platform-tests/server-timing/cross_origin.html: Added. * web-platform-tests/server-timing/navigation_timing_idl.html: Added. * web-platform-tests/server-timing/navigation_timing_idl.https.html: Added. * web-platform-tests/server-timing/resources/blue.png: Added. * web-platform-tests/server-timing/resources/blue.png.sub.headers: Added. * web-platform-tests/server-timing/resources/blue_tao.png: Added. * web-platform-tests/server-timing/resources/blue_tao.png.sub.headers: Added. * web-platform-tests/server-timing/resources/green.png: Added. * web-platform-tests/server-timing/resources/green.png.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/0.js: Added. * web-platform-tests/server-timing/resources/parsing/0.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/1.js: Added. * web-platform-tests/server-timing/resources/parsing/1.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/10.js: Added. * web-platform-tests/server-timing/resources/parsing/10.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/11.js: Added. * web-platform-tests/server-timing/resources/parsing/11.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/12.js: Added. * web-platform-tests/server-timing/resources/parsing/12.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/13.js: Added. * web-platform-tests/server-timing/resources/parsing/13.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/14.js: Added. * web-platform-tests/server-timing/resources/parsing/14.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/15.js: Added. * web-platform-tests/server-timing/resources/parsing/15.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/16.js: Added. * web-platform-tests/server-timing/resources/parsing/16.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/17.js: Added. * web-platform-tests/server-timing/resources/parsing/17.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/18.js: Added. * web-platform-tests/server-timing/resources/parsing/18.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/19.js: Added. * web-platform-tests/server-timing/resources/parsing/19.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/2.js: Added. * web-platform-tests/server-timing/resources/parsing/2.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/20.js: Added. * web-platform-tests/server-timing/resources/parsing/20.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/21.js: Added. * web-platform-tests/server-timing/resources/parsing/21.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/22.js: Added. * web-platform-tests/server-timing/resources/parsing/22.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/23.js: Added. * web-platform-tests/server-timing/resources/parsing/23.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/24.js: Added. * web-platform-tests/server-timing/resources/parsing/24.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/25.js: Added. * web-platform-tests/server-timing/resources/parsing/25.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/26.js: Added. * web-platform-tests/server-timing/resources/parsing/26.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/27.js: Added. * web-platform-tests/server-timing/resources/parsing/27.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/28.js: Added. * web-platform-tests/server-timing/resources/parsing/28.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/29.js: Added. * web-platform-tests/server-timing/resources/parsing/29.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/3.js: Added. * web-platform-tests/server-timing/resources/parsing/3.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/30.js: Added. * web-platform-tests/server-timing/resources/parsing/30.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/31.js: Added. * web-platform-tests/server-timing/resources/parsing/31.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/32.js: Added. * web-platform-tests/server-timing/resources/parsing/32.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/33.js: Added. * web-platform-tests/server-timing/resources/parsing/33.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/34.js: Added. * web-platform-tests/server-timing/resources/parsing/34.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/35.js: Added. * web-platform-tests/server-timing/resources/parsing/35.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/36.js: Added. * web-platform-tests/server-timing/resources/parsing/36.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/37.js: Added. * web-platform-tests/server-timing/resources/parsing/37.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/38.js: Added. * web-platform-tests/server-timing/resources/parsing/38.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/39.js: Added. * web-platform-tests/server-timing/resources/parsing/39.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/4.js: Added. * web-platform-tests/server-timing/resources/parsing/4.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/40.js: Added. * web-platform-tests/server-timing/resources/parsing/40.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/41.js: Added. * web-platform-tests/server-timing/resources/parsing/41.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/42.js: Added. * web-platform-tests/server-timing/resources/parsing/42.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/43.js: Added. * web-platform-tests/server-timing/resources/parsing/43.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/44.js: Added. * web-platform-tests/server-timing/resources/parsing/44.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/45.js: Added. * web-platform-tests/server-timing/resources/parsing/45.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/46.js: Added. * web-platform-tests/server-timing/resources/parsing/46.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/47.js: Added. * web-platform-tests/server-timing/resources/parsing/47.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/48.js: Added. * web-platform-tests/server-timing/resources/parsing/48.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/49.js: Added. * web-platform-tests/server-timing/resources/parsing/49.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/5.js: Added. * web-platform-tests/server-timing/resources/parsing/5.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/50.js: Added. * web-platform-tests/server-timing/resources/parsing/50.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/51.js: Added. * web-platform-tests/server-timing/resources/parsing/51.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/52.js: Added. * web-platform-tests/server-timing/resources/parsing/52.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/53.js: Added. * web-platform-tests/server-timing/resources/parsing/53.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/54.js: Added. * web-platform-tests/server-timing/resources/parsing/54.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/55.js: Added. * web-platform-tests/server-timing/resources/parsing/55.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/56.js: Added. * web-platform-tests/server-timing/resources/parsing/56.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/57.js: Added. * web-platform-tests/server-timing/resources/parsing/57.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/58.js: Added. * web-platform-tests/server-timing/resources/parsing/58.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/59.js: Added. * web-platform-tests/server-timing/resources/parsing/59.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/6.js: Added. * web-platform-tests/server-timing/resources/parsing/6.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/60.js: Added. * web-platform-tests/server-timing/resources/parsing/60.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/61.js: Added. * web-platform-tests/server-timing/resources/parsing/61.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/62.js: Added. * web-platform-tests/server-timing/resources/parsing/62.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/63.js: Added. * web-platform-tests/server-timing/resources/parsing/63.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/64.js: Added. * web-platform-tests/server-timing/resources/parsing/64.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/65.js: Added. * web-platform-tests/server-timing/resources/parsing/65.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/66.js: Added. * web-platform-tests/server-timing/resources/parsing/66.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/67.js: Added. * web-platform-tests/server-timing/resources/parsing/67.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/68.js: Added. * web-platform-tests/server-timing/resources/parsing/68.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/69.js: Added. * web-platform-tests/server-timing/resources/parsing/69.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/7.js: Added. * web-platform-tests/server-timing/resources/parsing/7.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/70.js: Added. * web-platform-tests/server-timing/resources/parsing/70.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/71.js: Added. * web-platform-tests/server-timing/resources/parsing/71.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/72.js: Added. * web-platform-tests/server-timing/resources/parsing/72.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/73.js: Added. * web-platform-tests/server-timing/resources/parsing/73.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/74.js: Added. * web-platform-tests/server-timing/resources/parsing/74.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/75.js: Added. * web-platform-tests/server-timing/resources/parsing/75.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/76.js: Added. * web-platform-tests/server-timing/resources/parsing/76.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/77.js: Added. * web-platform-tests/server-timing/resources/parsing/77.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/78.js: Added. * web-platform-tests/server-timing/resources/parsing/78.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/79.js: Added. * web-platform-tests/server-timing/resources/parsing/79.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/8.js: Added. * web-platform-tests/server-timing/resources/parsing/8.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/80.js: Added. * web-platform-tests/server-timing/resources/parsing/80.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/81.js: Added. * web-platform-tests/server-timing/resources/parsing/81.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/82.js: Added. * web-platform-tests/server-timing/resources/parsing/82.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/83.js: Added. * web-platform-tests/server-timing/resources/parsing/83.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/9.js: Added. * web-platform-tests/server-timing/resources/parsing/9.js.sub.headers: Added. * web-platform-tests/server-timing/resources/parsing/w3c-import.log: Added. * web-platform-tests/server-timing/resources/w3c-import.log: Added. * web-platform-tests/server-timing/resource_timing_idl.html: Added. * web-platform-tests/server-timing/resource_timing_idl.https.html: Added. * web-platform-tests/server-timing/server_timing_header-parsing.html: Added. * web-platform-tests/server-timing/server_timing_header-parsing.https.html: Added. * web-platform-tests/server-timing/test_server_timing.html: Added. * web-platform-tests/server-timing/test_server_timing.html.sub.headers: Added. * web-platform-tests/server-timing/test_server_timing.https.html: Added. * web-platform-tests/server-timing/test_server_timing.https.html.sub.headers: Added. * web-platform-tests/server-timing/w3c-import.log: Added. Source/WebCore: * Sources.txt: Added references to HeaderFieldTokenizer.cpp, ServerTiming.cpp, and ServerTimingParser.cpp. * WebCore.xcodeproj/project.pbxproj: Added various files. * loader/HeaderFieldTokenizer.cpp: Added. (WebCore::HeaderFieldTokenizer::HeaderFieldTokenizer): Added class for tokenizing header values. (WebCore::HeaderFieldTokenizer::consume): Added method to consume a specified character. (WebCore::HeaderFieldTokenizer::consumeQuotedString): Added method to consume a quote-string. (WebCore::HeaderFieldTokenizer::consumeToken): Added a method to consume a token. (WebCore::HeaderFieldTokenizer::consumeTokenOrQuotedString): Added method to consume a quote-string or quote-string, depending on net character. (WebCore::HeaderFieldTokenizer::skipSpaces): Added method to skip whitespace. (WebCore::HeaderFieldTokenizer::consumeBeforeAnyCharMatch): Added method to advance the cursor up until any of a list of characters. * loader/HeaderFieldTokenizer.h: Added. * loader/HTTPHeaderField.cpp: Expose isTokenCharacter and isWhitespace. * loader/HTTPHeaderField.h: Expose isTokenCharacter and isWhitespace. * loader/PolicyChecker.cpp: Added #include so source compiled on my machine. * loader/ResourceTiming.cpp: (WebCore::ResourceTiming::ResourceTiming): Added call to initServerTiming to parse the header. (WebCore::ResourceTiming::initServerTiming): Added method to parse the header. (WebCore::ResourceTiming::populateServerTiming): Added method to populate the server timing entries on a PerformanceResourceTiming object. (WebCore::ResourceTiming::isolatedCopy const): Added code to copy over the server timing entries. * loader/ResourceTiming.h: (WebCore::ResourceTiming::ResourceTiming): Accept collection of server timing entries in c'tor. * loader/ServerTiming.cpp: Added. (WebCore::ServerTiming::setParameter): Set named parameters, ignoring unrecognized or duplicates. (WebCore::ServerTiming::isolatedCopy const): Return a new pointer to the object. * loader/ServerTiming.h: Added. (WebCore::ServerTiming::ServerTiming): Added struct for the data needed by a server timing entry. (WebCore::ServerTiming::name const): Added name field of a server timing entry. (WebCore::ServerTiming::duration const): Added duration field of a server timing entry. (WebCore::ServerTiming::description const): Added description field of a server timing entry. * loader/ServerTimingParser.cpp: Added. (WebCore::ServerTimingParser::parseServerTiming): Parses the header generating a collection of server timing structs. * loader/ServerTimingParser.h: Added. * loader/WorkerThreadableLoader.h: Fix build. * page/Performance.cpp: (WebCore::Performance::addResourceTiming): Fixed a typo. * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): Given a ResourceTiming object, populate our collection of PerformanceServerTiming objects. * page/PerformanceResourceTiming.h: Added serverTiming member and getter. * page/PerformanceResourceTiming.idl: Added serverTiming member to interface. * platform/network/HTTPHeaderNames.in: Added "Server-Timing" to the header enum. * platform/network/ResourceResponseBase.cpp: Added "Server-Timing" to isSafeCrossOriginResponseHeader whitelist. LayoutTests: * imported/w3c/web-platform-tests/server-timing/cross_origin-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/resource_timing_idl-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/resource_timing_idl.https-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/server_timing_header-parsing-expected.txt: Added. * imported/w3c/web-platform-tests/server-timing/server_timing_header-parsing.https-expected.txt: Added. Canonical link: https://commits.webkit.org/201126@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-15 19:24:30 +00:00
});
[Resource Timing] Support Resource Timing in Workers https://bugs.webkit.org/show_bug.cgi?id=168086 <rdar://problem/30430117> Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/idlharness-expected.txt: * web-platform-tests/resource-timing/resource-timing-expected.txt: * web-platform-tests/resource-timing/resource_cached-expected.txt: * web-platform-tests/resource-timing/resource_connection_reuse-expected.txt: Progressions. * web-platform-tests/resource-timing/resources/data.json: Added. * web-platform-tests/resource-timing/resources/rt-iframe-1.html: Added. * web-platform-tests/resource-timing/resources/rt-iframe-2.html: Added. * web-platform-tests/resource-timing/resources/rt-module.js: Added. * web-platform-tests/resource-timing/resources/rt-sub-module.js: Added. * web-platform-tests/resource-timing/resources/rt-utilities.js: Added. * web-platform-tests/resource-timing/resources/rt-worker-resources.js: Added. New Resources. * web-platform-tests/resource-timing/rt-cors-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.html: Added. * web-platform-tests/resource-timing/rt-cors.js: Added. * web-platform-tests/resource-timing/rt-cors.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.worker.html: Added. * web-platform-tests/resource-timing/rt-cors.worker.js: Added. Tests for redirects and cross origin data hiding. * web-platform-tests/resource-timing/rt-initiatorType-css-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-css.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-element-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-element.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.js: Added. * web-platform-tests/resource-timing/rt-initiatorType-other-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-other.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.js: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.html: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.js: Added. Tests for producing different initiator types. * web-platform-tests/resource-timing/rt-initiatorType-media-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-media.html: Added. We currently fail these tests, so they are marked as fail. * web-platform-tests/resource-timing/rt-performance-extensions-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.js: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.js: Added. Tests for the new Performance APIs. * web-platform-tests/resource-timing/rt-serialization-expected.txt: Added. * web-platform-tests/resource-timing/rt-serialization.html: Added. Tests for JSON serialization. * web-platform-tests/resource-timing/rt-resource-errors-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-errors.html: Added. * web-platform-tests/resource-timing/rt-resource-ignored-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-ignored.html: Added. Tests for when PerformanceResourceTiming entries should not be included. * web-platform-tests/resource-timing/rt-resources-per-frame-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-frame.html: Added. * web-platform-tests/resource-timing/rt-resources-per-worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-worker.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers.html: Added. Tests for different entries in different contexts. * web-platform-tests/serve: Make executable. Source/WebCore: Worker's load resources through the Document that loaded them. However, their PerformanceResourceTiming entries should be added to the Performance object inside the Worker context, not the Document's context. This change adds an InitiatorContext to ResourceLoadOptions so that loaders can determine if the load was initiated by the Document or a Worker. This allows loaders to then know if the ResourceTiming data they collect should be added to the Document's Performance object or forwarded on to the Worker's. This adds a new ThreadableLoaderClient method intended only for the purpose of adding the ResourceTiming information to the Worker's Performance object. Unlike other ThreadableLoaderClient methods that are bridged and forwarded on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this method never needs to be handled by clients and can be uniformly handled by the WorkerThreadableLoader itself. We also add a new ResourceTiming object that encapsulates all of the data ultimately needed for a PerformanceResourceTimingEntry object. This allows for all of the information to be gathered while loading on the Document before serializing across to the Worker. That includes the Timing-Allow-Origin check which uses the SecurityOrigin of the Worker. This also modernizes and addresses issues in the Resource Timing implementation. Better handling cases like loading from the Cache, Synchronous Loads, and improving initiatorType information. Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html imported/w3c/web-platform-tests/resource-timing/rt-serialization.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html performance-api/resource-timing-apis.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: New files. * platform/network/NetworkLoadTiming.h: (WebCore::NetworkLoadTiming::reset): Deleted. We no longer need to reset. * loader/ResourceTiming.cpp: Added. (WebCore::passesTimingAllowCheck): (WebCore::ResourceTiming::fromCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: Added. (WebCore::ResourceTiming::url): (WebCore::ResourceTiming::initiator): (WebCore::ResourceTiming::loadTiming): (WebCore::ResourceTiming::networkLoadTiming): (WebCore::ResourceTiming::allowTimingDetails): (WebCore::ResourceTiming::overrideInitiatorName): (WebCore::ResourceTiming::ResourceTiming): Class that encapsulates all of the data needed for a PerformanceResourceTiming entry. There are three static constructors indicating the different ways this object can be constructed and the different data available at the time of construction. * loader/ResourceLoaderOptions.h: Add the new InitiatorContext, default to Document. * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishTiming): New client method only used by WorkerThreadableLoader. * loader/WorkerThreadableLoader.h: * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming): All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker. Add timing information to the Performance object when received. No need to inform clients. * loader/DocumentThreadableLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad): (WebCore::DocumentThreadableLoader::loadRequest): Provide APIs to pass timing data on to a WorkerThreadableLoader. Create ResourceTiming data for synchronous loads. * loader/LoadTiming.h: * loader/LoadTiming.cpp: (WebCore::LoadTiming::isolatedCopy): Add isolatedCopy to allow this data to be passed across to a Worker. * loader/ResourceTimingInformation.h: * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): (WebCore::ResourceTimingInformation::addResourceTiming): (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Refactor to remove unused / unnecessary bits. Extract out some helpful code. Changed this to match when Blink decides when to add or ignore entries, however this may change over time. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::notifyDone): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::finishedTimingForWorkerLoad): * loader/cache/CachedRawResource.h: * loader/cache/CachedRawResourceClient.h: (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad): Plumbing to report timing information to Worker if this resource was loaded for a Worker. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): * loader/cache/CachedResource.h: (WebCore::CachedResource::initiatorName): Store the initiator name on the CachedResource like other data added to the original CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and cleans up other hacks that worked around this later on. * loader/cache/CachedResourceLoader.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::revalidateResource): (WebCore::CachedResourceLoader::loadResource): Simply the creation of a ResourceTiming object for cache hits. Report timing information to Worker if this resource was loaded for a Worker. (WebCore::CachedResourceLoader::loadDone): Eliminate this redundant point attempting to add a ResourceTiming entry. * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName): Update to match the spec. The fallback is "other". * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::setResourceTimingBufferSize): (WebCore::Performance::addResourceTiming): Update to support PerformanceObservers. Update to match spec (event should bubble). * page/PerformanceResourceTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::create): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::fetchStart): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): Construct with a ResourceTiming object containing all the data we need for the entry. Update to match spec for what is required, should fallback, should be zero, etc. (WebCore::passesTimingAllowCheck): Deleted. Extracted this to ResourceTiming creation time in the loading context, since this can't be determined on the Worker context without also having all of the header information from each resource response. * page/PerformanceResourceTiming.idl: Expose to Workers! LayoutTests: * TestExpectations: Pre-emptively mark some tests as flakey that have seen flakiness. * platform/mac/TestExpectations: Skip some tests on ElCapitan because the network timing numbers appear incorrect. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: PerformanceResourceTiming is now available in Workers. * performance-api/resource-timing-apis-expected.txt: Added. * performance-api/resource-timing-apis.html: Added. * performance-api/resources/resource-timing-api.js: Added. Basic API test. We expect to fail nextHopProtocol and size properties right now. Canonical link: https://commits.webkit.org/185464@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-16 19:18:32 +00:00
}
ResourceTiming ResourceTiming::isolatedCopy() 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 ResourceTiming(
m_url.isolatedCopy(),
m_initiator.isolatedCopy(),
m_resourceLoadTiming.isolatedCopy(),
m_networkLoadMetrics.isolatedCopy(),
crossThreadCopy(m_serverTiming)
);
[Resource Timing] Support Resource Timing in Workers https://bugs.webkit.org/show_bug.cgi?id=168086 <rdar://problem/30430117> Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/resource-timing/idlharness-expected.txt: * web-platform-tests/resource-timing/resource-timing-expected.txt: * web-platform-tests/resource-timing/resource_cached-expected.txt: * web-platform-tests/resource-timing/resource_connection_reuse-expected.txt: Progressions. * web-platform-tests/resource-timing/resources/data.json: Added. * web-platform-tests/resource-timing/resources/rt-iframe-1.html: Added. * web-platform-tests/resource-timing/resources/rt-iframe-2.html: Added. * web-platform-tests/resource-timing/resources/rt-module.js: Added. * web-platform-tests/resource-timing/resources/rt-sub-module.js: Added. * web-platform-tests/resource-timing/resources/rt-utilities.js: Added. * web-platform-tests/resource-timing/resources/rt-worker-resources.js: Added. New Resources. * web-platform-tests/resource-timing/rt-cors-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.html: Added. * web-platform-tests/resource-timing/rt-cors.js: Added. * web-platform-tests/resource-timing/rt-cors.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-cors.worker.html: Added. * web-platform-tests/resource-timing/rt-cors.worker.js: Added. Tests for redirects and cross origin data hiding. * web-platform-tests/resource-timing/rt-initiatorType-css-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-css.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-element-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-element.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-fetch.js: Added. * web-platform-tests/resource-timing/rt-initiatorType-other-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-other.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-script-module.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html: Added. * web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.js: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.html: Added. * web-platform-tests/resource-timing/rt-initiatorType.worker.js: Added. Tests for producing different initiator types. * web-platform-tests/resource-timing/rt-initiatorType-media-expected.txt: Added. * web-platform-tests/resource-timing/rt-initiatorType-media.html: Added. We currently fail these tests, so they are marked as fail. * web-platform-tests/resource-timing/rt-performance-extensions-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.js: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.html: Added. * web-platform-tests/resource-timing/rt-performance-extensions.worker.js: Added. Tests for the new Performance APIs. * web-platform-tests/resource-timing/rt-serialization-expected.txt: Added. * web-platform-tests/resource-timing/rt-serialization.html: Added. Tests for JSON serialization. * web-platform-tests/resource-timing/rt-resource-errors-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-errors.html: Added. * web-platform-tests/resource-timing/rt-resource-ignored-expected.txt: Added. * web-platform-tests/resource-timing/rt-resource-ignored.html: Added. Tests for when PerformanceResourceTiming entries should not be included. * web-platform-tests/resource-timing/rt-resources-per-frame-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-frame.html: Added. * web-platform-tests/resource-timing/rt-resources-per-worker-expected.txt: Added. * web-platform-tests/resource-timing/rt-resources-per-worker.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-frames.html: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers-expected.txt: Added. * web-platform-tests/resource-timing/rt-shared-resource-in-workers.html: Added. Tests for different entries in different contexts. * web-platform-tests/serve: Make executable. Source/WebCore: Worker's load resources through the Document that loaded them. However, their PerformanceResourceTiming entries should be added to the Performance object inside the Worker context, not the Document's context. This change adds an InitiatorContext to ResourceLoadOptions so that loaders can determine if the load was initiated by the Document or a Worker. This allows loaders to then know if the ResourceTiming data they collect should be added to the Document's Performance object or forwarded on to the Worker's. This adds a new ThreadableLoaderClient method intended only for the purpose of adding the ResourceTiming information to the Worker's Performance object. Unlike other ThreadableLoaderClient methods that are bridged and forwarded on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this method never needs to be handled by clients and can be uniformly handled by the WorkerThreadableLoader itself. We also add a new ResourceTiming object that encapsulates all of the data ultimately needed for a PerformanceResourceTimingEntry object. This allows for all of the information to be gathered while loading on the Document before serializing across to the Worker. That includes the Timing-Allow-Origin check which uses the SecurityOrigin of the Worker. This also modernizes and addresses issues in the Resource Timing implementation. Better handling cases like loading from the Cache, Synchronous Loads, and improving initiatorType information. Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html imported/w3c/web-platform-tests/resource-timing/rt-serialization.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html performance-api/resource-timing-apis.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: New files. * platform/network/NetworkLoadTiming.h: (WebCore::NetworkLoadTiming::reset): Deleted. We no longer need to reset. * loader/ResourceTiming.cpp: Added. (WebCore::passesTimingAllowCheck): (WebCore::ResourceTiming::fromCache): (WebCore::ResourceTiming::fromLoad): (WebCore::ResourceTiming::fromSynchronousLoad): (WebCore::ResourceTiming::ResourceTiming): (WebCore::ResourceTiming::isolatedCopy): * loader/ResourceTiming.h: Added. (WebCore::ResourceTiming::url): (WebCore::ResourceTiming::initiator): (WebCore::ResourceTiming::loadTiming): (WebCore::ResourceTiming::networkLoadTiming): (WebCore::ResourceTiming::allowTimingDetails): (WebCore::ResourceTiming::overrideInitiatorName): (WebCore::ResourceTiming::ResourceTiming): Class that encapsulates all of the data needed for a PerformanceResourceTiming entry. There are three static constructors indicating the different ways this object can be constructed and the different data available at the time of construction. * loader/ResourceLoaderOptions.h: Add the new InitiatorContext, default to Document. * loader/ThreadableLoaderClient.h: (WebCore::ThreadableLoaderClient::didFinishTiming): New client method only used by WorkerThreadableLoader. * loader/WorkerThreadableLoader.h: * loader/WorkerThreadableLoader.cpp: (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge): (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming): All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker. Add timing information to the Performance object when received. No need to inform clients. * loader/DocumentThreadableLoader.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad): (WebCore::DocumentThreadableLoader::loadRequest): Provide APIs to pass timing data on to a WorkerThreadableLoader. Create ResourceTiming data for synchronous loads. * loader/LoadTiming.h: * loader/LoadTiming.cpp: (WebCore::LoadTiming::isolatedCopy): Add isolatedCopy to allow this data to be passed across to a Worker. * loader/ResourceTimingInformation.h: * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::shouldAddResourceTiming): (WebCore::ResourceTimingInformation::addResourceTiming): (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Refactor to remove unused / unnecessary bits. Extract out some helpful code. Changed this to match when Blink decides when to add or ignore entries, however this may change over time. * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): (WebCore::SubresourceLoader::notifyDone): (WebCore::SubresourceLoader::reportResourceTiming): * loader/SubresourceLoader.h: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::finishedTimingForWorkerLoad): * loader/cache/CachedRawResource.h: * loader/cache/CachedRawResourceClient.h: (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad): Plumbing to report timing information to Worker if this resource was loaded for a Worker. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): * loader/cache/CachedResource.h: (WebCore::CachedResource::initiatorName): Store the initiator name on the CachedResource like other data added to the original CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and cleans up other hacks that worked around this later on. * loader/cache/CachedResourceLoader.h: * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::revalidateResource): (WebCore::CachedResourceLoader::loadResource): Simply the creation of a ResourceTiming object for cache hits. Report timing information to Worker if this resource was loaded for a Worker. (WebCore::CachedResourceLoader::loadDone): Eliminate this redundant point attempting to add a ResourceTiming entry. * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::initiatorName): Update to match the spec. The fallback is "other". * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::setResourceTimingBufferSize): (WebCore::Performance::addResourceTiming): Update to support PerformanceObservers. Update to match spec (event should bubble). * page/PerformanceResourceTiming.h: * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::create): (WebCore::PerformanceResourceTiming::PerformanceResourceTiming): (WebCore::PerformanceResourceTiming::fetchStart): (WebCore::PerformanceResourceTiming::domainLookupStart): (WebCore::PerformanceResourceTiming::domainLookupEnd): (WebCore::PerformanceResourceTiming::connectStart): (WebCore::PerformanceResourceTiming::connectEnd): (WebCore::PerformanceResourceTiming::secureConnectionStart): (WebCore::PerformanceResourceTiming::requestStart): (WebCore::PerformanceResourceTiming::responseStart): (WebCore::PerformanceResourceTiming::responseEnd): (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp): Construct with a ResourceTiming object containing all the data we need for the entry. Update to match spec for what is required, should fallback, should be zero, etc. (WebCore::passesTimingAllowCheck): Deleted. Extracted this to ResourceTiming creation time in the loading context, since this can't be determined on the Worker context without also having all of the header information from each resource response. * page/PerformanceResourceTiming.idl: Expose to Workers! LayoutTests: * TestExpectations: Pre-emptively mark some tests as flakey that have seen flakiness. * platform/mac/TestExpectations: Skip some tests on ElCapitan because the network timing numbers appear incorrect. * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: PerformanceResourceTiming is now available in Workers. * performance-api/resource-timing-apis-expected.txt: Added. * performance-api/resource-timing-apis.html: Added. * performance-api/resources/resource-timing-api.js: Added. Basic API test. We expect to fail nextHopProtocol and size properties right now. Canonical link: https://commits.webkit.org/185464@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-16 19:18:32 +00:00
}
} // namespace WebCore