Title: [293418] trunk
Revision
293418
Author
[email protected]
Date
2022-04-26 00:34:40 -0700 (Tue, 26 Apr 2022)

Log Message

Service Worker loads should not expose some ResourceTiming information
https://bugs.webkit.org/show_bug.cgi?id=239608

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/service-worker/resource-timing-fetch-variants.https-expected.txt:

Source/WebCore:

Filter out some resource timing info when the load is served from a service worker.
While we could do the filtering on service worker side, it is best to do it within PerformanceResourceTiming
as native clients might still want to use non filtered data in case the service worker is returning a network load
as the response.

Covered by rebased test.

* loader/ResourceTiming.cpp:
(WebCore::ResourceTiming::ResourceTiming):
* loader/ResourceTiming.h:
(WebCore::ResourceTiming::isLoadedFromServiceWorker const):
* page/PerformanceResourceTiming.cpp:
(WebCore::PerformanceResourceTiming::nextHopProtocol const):
(WebCore::PerformanceResourceTiming::redirectStart const):
(WebCore::PerformanceResourceTiming::redirectEnd const):
(WebCore::PerformanceResourceTiming::domainLookupStart const):
(WebCore::PerformanceResourceTiming::domainLookupEnd const):
(WebCore::PerformanceResourceTiming::connectStart const):
(WebCore::PerformanceResourceTiming::connectEnd const):
* page/PerformanceResourceTiming.h:
(WebCore::PerformanceResourceTiming::isLoadedFromServiceWorker const):

LayoutTests:

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (293417 => 293418)


--- trunk/LayoutTests/ChangeLog	2022-04-26 06:57:34 UTC (rev 293417)
+++ trunk/LayoutTests/ChangeLog	2022-04-26 07:34:40 UTC (rev 293418)
@@ -1,3 +1,12 @@
+2022-04-26  Youenn Fablet  <[email protected]>
+
+        Service Worker loads should not expose some ResourceTiming information
+        https://bugs.webkit.org/show_bug.cgi?id=239608
+
+        Reviewed by Alex Christensen.
+
+        * TestExpectations:
+
 2022-04-25  Devin Rousso  <[email protected]>
 
         Web Inspector: add UI for blocking requests

Modified: trunk/LayoutTests/TestExpectations (293417 => 293418)


--- trunk/LayoutTests/TestExpectations	2022-04-26 06:57:34 UTC (rev 293417)
+++ trunk/LayoutTests/TestExpectations	2022-04-26 07:34:40 UTC (rev 293418)
@@ -854,7 +854,6 @@
 imported/w3c/web-platform-tests/html/webappapis/system-state-and-capabilities/the-navigator-object/plugins-and-mimetypes.html [ Failure Pass ]
 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/anonymous-iframe/sharedworker-partitioning.tentative.https.window.html [ Failure Pass ]
 imported/w3c/web-platform-tests/service-workers/service-worker/navigation-timing-extended.https.html [ Failure Pass ]
-imported/w3c/web-platform-tests/service-workers/service-worker/resource-timing-fetch-variants.https.html [ Failure Pass ]
 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface/mediaElementAudioSourceToScriptProcessorTest.html [ Failure Pass ]
 
 imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-error-events.html [ DumpJSConsoleLogInStdErr ]

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (293417 => 293418)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-04-26 06:57:34 UTC (rev 293417)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-04-26 07:34:40 UTC (rev 293418)
@@ -1,3 +1,12 @@
+2022-04-26  Youenn Fablet  <[email protected]>
+
+        Service Worker loads should not expose some ResourceTiming information
+        https://bugs.webkit.org/show_bug.cgi?id=239608
+
+        Reviewed by Alex Christensen.
+
+        * web-platform-tests/service-workers/service-worker/resource-timing-fetch-variants.https-expected.txt:
+
 2022-04-25  Youenn Fablet  <[email protected]>
 
         Service workers should not intercept embed/object related loads

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/resource-timing-fetch-variants.https-expected.txt (293417 => 293418)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/resource-timing-fetch-variants.https-expected.txt	2022-04-26 06:57:34 UTC (rev 293417)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/resource-timing-fetch-variants.https-expected.txt	2022-04-26 07:34:40 UTC (rev 293418)
@@ -1,5 +1,5 @@
 
-FAIL Redirects done from within a service-worker should not be exposed to client ResourceTiming assert_equals: expected (number) 0 but got (string) "same"
+PASS Redirects done from within a service-worker should not be exposed to client ResourceTiming
 PASS Connection info from within a service-worker should not be exposed to client ResourceTiming
 PASS requestStart should never be before fetchStart
 FAIL Delay from within service-worker (after internal fetching) should be accessible through `responseStart` assert_equals: expected "responseStart" but got "after"

Modified: trunk/Source/WebCore/ChangeLog (293417 => 293418)


--- trunk/Source/WebCore/ChangeLog	2022-04-26 06:57:34 UTC (rev 293417)
+++ trunk/Source/WebCore/ChangeLog	2022-04-26 07:34:40 UTC (rev 293418)
@@ -1,3 +1,32 @@
+2022-04-26  Youenn Fablet  <[email protected]>
+
+        Service Worker loads should not expose some ResourceTiming information
+        https://bugs.webkit.org/show_bug.cgi?id=239608
+
+        Reviewed by Alex Christensen.
+
+        Filter out some resource timing info when the load is served from a service worker.
+        While we could do the filtering on service worker side, it is best to do it within PerformanceResourceTiming
+        as native clients might still want to use non filtered data in case the service worker is returning a network load
+        as the response.
+
+        Covered by rebased test.
+
+        * loader/ResourceTiming.cpp:
+        (WebCore::ResourceTiming::ResourceTiming):
+        * loader/ResourceTiming.h:
+        (WebCore::ResourceTiming::isLoadedFromServiceWorker const):
+        * page/PerformanceResourceTiming.cpp:
+        (WebCore::PerformanceResourceTiming::nextHopProtocol const):
+        (WebCore::PerformanceResourceTiming::redirectStart const):
+        (WebCore::PerformanceResourceTiming::redirectEnd const):
+        (WebCore::PerformanceResourceTiming::domainLookupStart const):
+        (WebCore::PerformanceResourceTiming::domainLookupEnd const):
+        (WebCore::PerformanceResourceTiming::connectStart const):
+        (WebCore::PerformanceResourceTiming::connectEnd const):
+        * page/PerformanceResourceTiming.h:
+        (WebCore::PerformanceResourceTiming::isLoadedFromServiceWorker const):
+
 2022-04-25  Youenn Fablet  <[email protected]>
 
         Service workers should not intercept embed/object related loads

Modified: trunk/Source/WebCore/loader/ResourceTiming.cpp (293417 => 293418)


--- trunk/Source/WebCore/loader/ResourceTiming.cpp	2022-04-26 06:57:34 UTC (rev 293417)
+++ trunk/Source/WebCore/loader/ResourceTiming.cpp	2022-04-26 07:34:40 UTC (rev 293418)
@@ -56,6 +56,7 @@
     , m_initiator(initiator)
     , m_resourceLoadTiming(timing)
     , m_networkLoadMetrics(networkLoadMetrics)
+    , m_isLoadedFromServiceWorker(response.source() == ResourceResponse::Source::ServiceWorker)
 {
     if (RuntimeEnabledFeatures::sharedFeatures().serverTimingEnabled() && !m_networkLoadMetrics.failsTAOCheck)
         m_serverTiming = ServerTimingParser::parseServerTiming(response.httpHeaderField(HTTPHeaderName::ServerTiming));

Modified: trunk/Source/WebCore/loader/ResourceTiming.h (293417 => 293418)


--- trunk/Source/WebCore/loader/ResourceTiming.h	2022-04-26 06:57:34 UTC (rev 293417)
+++ trunk/Source/WebCore/loader/ResourceTiming.h	2022-04-26 07:34:40 UTC (rev 293418)
@@ -55,6 +55,7 @@
     ResourceTiming isolatedCopy() &&;
 
     void overrideInitiatorName(const String& name) { m_initiator = name; }
+    bool isLoadedFromServiceWorker() const { return m_isLoadedFromServiceWorker; }
 
 private:
     ResourceTiming(const URL&, const String& initiator, const ResourceLoadTiming&, const NetworkLoadMetrics&, const ResourceResponse&, const SecurityOrigin&);
@@ -72,6 +73,7 @@
     ResourceLoadTiming m_resourceLoadTiming;
     NetworkLoadMetrics m_networkLoadMetrics;
     Vector<ServerTiming> m_serverTiming;
+    bool m_isLoadedFromServiceWorker { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/PerformanceResourceTiming.cpp (293417 => 293418)


--- trunk/Source/WebCore/page/PerformanceResourceTiming.cpp	2022-04-26 06:57:34 UTC (rev 293417)
+++ trunk/Source/WebCore/page/PerformanceResourceTiming.cpp	2022-04-26 07:34:40 UTC (rev 293418)
@@ -116,6 +116,9 @@
     if (m_resourceTiming.networkLoadMetrics().failsTAOCheck)
         return 0.0;
 
+    if (m_resourceTiming.isLoadedFromServiceWorker())
+        return 0.0;
+
     if (!m_resourceTiming.networkLoadMetrics().redirectCount)
         return 0.0;
 
@@ -127,6 +130,9 @@
     if (m_resourceTiming.networkLoadMetrics().failsTAOCheck)
         return 0.0;
 
+    if (m_resourceTiming.isLoadedFromServiceWorker())
+        return 0.0;
+
     if (!m_resourceTiming.networkLoadMetrics().redirectCount)
         return 0.0;
 
@@ -145,6 +151,9 @@
     if (m_resourceTiming.networkLoadMetrics().failsTAOCheck)
         return 0.0;
 
+    if (m_resourceTiming.isLoadedFromServiceWorker())
+        return fetchStart();
+
     if (!m_resourceTiming.networkLoadMetrics().domainLookupStart)
         return fetchStart();
 
@@ -156,6 +165,9 @@
     if (m_resourceTiming.networkLoadMetrics().failsTAOCheck)
         return 0.0;
 
+    if (m_resourceTiming.isLoadedFromServiceWorker())
+        return fetchStart();
+
     if (!m_resourceTiming.networkLoadMetrics().domainLookupEnd)
         return domainLookupStart();
 
@@ -167,6 +179,9 @@
     if (m_resourceTiming.networkLoadMetrics().failsTAOCheck)
         return 0.0;
 
+    if (m_resourceTiming.isLoadedFromServiceWorker())
+        return fetchStart();
+
     if (!m_resourceTiming.networkLoadMetrics().connectStart)
         return domainLookupEnd();
 
@@ -178,6 +193,9 @@
     if (m_resourceTiming.networkLoadMetrics().failsTAOCheck)
         return 0.0;
 
+    if (m_resourceTiming.isLoadedFromServiceWorker())
+        return fetchStart();
+
     if (!m_resourceTiming.networkLoadMetrics().connectEnd)
         return connectStart();
 

Modified: trunk/Source/WebCore/page/PerformanceResourceTiming.h (293417 => 293418)


--- trunk/Source/WebCore/page/PerformanceResourceTiming.h	2022-04-26 06:57:34 UTC (rev 293417)
+++ trunk/Source/WebCore/page/PerformanceResourceTiming.h	2022-04-26 07:34:40 UTC (rev 293418)
@@ -74,6 +74,8 @@
     PerformanceResourceTiming(MonotonicTime timeOrigin, ResourceTiming&&);
     ~PerformanceResourceTiming();
 
+    bool isLoadedFromServiceWorker() const { return m_resourceTiming.isLoadedFromServiceWorker(); }
+
     MonotonicTime m_timeOrigin;
     ResourceTiming m_resourceTiming;
     Vector<Ref<PerformanceServerTiming>> m_serverTiming;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to